Skip to content

Commit

Permalink
Merge branch 'refs/heads/upstream-HEAD' into repo-HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Delphix Engineering committed Oct 23, 2024
2 parents bf5c26d + 48b9629 commit ec8dc35
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 4 deletions.
4 changes: 3 additions & 1 deletion libdrgn/drgn.h
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,8 @@ typedef void *drgn_program_begin_blocking_fn(struct drgn_program *prog,
*
* @param[in] arg @c callback_arg passed to @ref
* drgn_program_set_blocking_callback().
* @param[in] state Return value of @ref drgn_program_begin_blocking_fn().
* @param[in] state Return value of matching call to @ref
* drgn_program_begin_blocking_fn().
*/
typedef void drgn_program_end_blocking_fn(struct drgn_program *prog,
void *arg, void *state);
Expand All @@ -1319,6 +1320,7 @@ typedef void drgn_program_end_blocking_fn(struct drgn_program *prog,
* long-running computations. They are intended for things like releasing the
* [global interpreter
* lock](https://docs.python.org/3/glossary.html#term-global-interpreter-lock).
* Calls to these callbacks may be nested, but they will always be matched.
*
* @param[in] begin_callback Callback called before a blocking operation. Can be
* @c NULL to unset.
Expand Down
4 changes: 4 additions & 0 deletions libdrgn/python/drgnpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
} while (0)
#endif

#if PY_VERSION_HEX < 0x030d00a1
#define PyThreadState_GetUnchecked _PyThreadState_UncheckedGet
#endif

#define DRGNPY_PUBLIC __attribute__((__visibility__("default")))

// PyLong_From* and PyLong_As* for stdint.h types. These use _Generic for
Expand Down
8 changes: 6 additions & 2 deletions libdrgn/python/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,16 @@ int Program_type_arg(Program *prog, PyObject *type_obj, bool can_be_none,

static void *drgnpy_begin_blocking(struct drgn_program *prog, void *arg)
{
return PyEval_SaveThread();
PyThreadState *state = PyThreadState_GetUnchecked();
if (state)
PyEval_ReleaseThread(state);
return state;
}

static void drgnpy_end_blocking(struct drgn_program *prog, void *arg, void *state)
{
PyEval_RestoreThread(state);
if (state)
PyEval_RestoreThread(state);
}

static Program *Program_new(PyTypeObject *subtype, PyObject *args,
Expand Down
4 changes: 3 additions & 1 deletion vmtest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
# For filesystem tests.
CONFIG_BTRFS_FS=m
# Don't waste time benchmarking in raid6_pq just to load the Btrfs module.
CONFIG_RAID6_PQ_BENCHMARK=n
CONFIG_EXT4_FS=m
CONFIG_XFS_FS=m
Expand Down Expand Up @@ -423,7 +425,7 @@ def kconfig_localversion(arch: Architecture, flavor: KernelFlavor, version: str)
vmtest_kernel_version = [
# Increment the major version to rebuild every
# architecture/flavor/version combination.
33,
34,
# The minor version makes the default flavor the "latest" version.
1 if flavor.name == "default" else 0,
]
Expand Down
8 changes: 8 additions & 0 deletions vmtest/kbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class _Patch(NamedTuple):
name="proc-kcore-allow-enabling-CONFIG_PROC_KCORE-on-ARM.patch",
versions=((None, None),),
),
_Patch(
name="9p-fix-slab-cache-name-creation-for-real.patch",
versions=((KernelVersion("6.12"), None),),
),
_Patch(
name="filelock-fix-name-of-file_lease-slab-cache.patch",
versions=((KernelVersion("6.9"), KernelVersion("6.10")),),
Expand Down Expand Up @@ -138,6 +142,10 @@ class _Patch(NamedTuple):
name="s390-crash-fix-proc-vmcore-reads.patch",
versions=((KernelVersion("5.18"), KernelVersion("6.0")),),
),
_Patch(
name="lib-raid6-add-option-to-skip-algo-benchmarking.patch",
versions=((None, KernelVersion("5.0")),),
),
)


Expand Down
50 changes: 50 additions & 0 deletions vmtest/patches/9p-fix-slab-cache-name-creation-for-real.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From a360f311f57a36e96d88fa8086b749159714dcd2 Mon Sep 17 00:00:00 2001
Message-ID: <a360f311f57a36e96d88fa8086b749159714dcd2.1729551875.git.osandov@fb.com>
From: Linus Torvalds <[email protected]>
Date: Mon, 21 Oct 2024 11:57:38 -0700
Subject: [PATCH] 9p: fix slab cache name creation for real

This was attempted by using the dev_name in the slab cache name, but as
Omar Sandoval pointed out, that can be an arbitrary string, eg something
like "/dev/root". Which in turn trips verify_dirent_name(), which fails
if a filename contains a slash.

So just make it use a sequence counter, and make it an atomic_t to avoid
any possible races or locking issues.

Reported-and-tested-by: Omar Sandoval <[email protected]>
Link: https://lore.kernel.org/all/[email protected]/
Fixes: 79efebae4afc ("9p: Avoid creating multiple slab caches with the same name")
Acked-by: Vlastimil Babka <[email protected]>
Cc: Dominique Martinet <[email protected]>
Cc: Thorsten Leemhuis <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
---
net/9p/client.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/9p/client.c b/net/9p/client.c
index 9e7b9151816d..09f8ced9f8bb 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -977,6 +977,7 @@ static int p9_client_version(struct p9_client *c)
struct p9_client *p9_client_create(const char *dev_name, char *options)
{
int err;
+ static atomic_t seqno = ATOMIC_INIT(0);
struct p9_client *clnt;
char *client_id;
char *cache_name;
@@ -1036,7 +1037,8 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
if (err)
goto close_trans;

- cache_name = kasprintf(GFP_KERNEL, "9p-fcall-cache-%s", dev_name);
+ cache_name = kasprintf(GFP_KERNEL,
+ "9p-fcall-cache-%u", atomic_inc_return(&seqno));
if (!cache_name) {
err = -ENOMEM;
goto close_trans;
--
2.47.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
From be85f93ae2df32dea0b20908316f1d894c3e0f64 Mon Sep 17 00:00:00 2001
Message-ID: <be85f93ae2df32dea0b20908316f1d894c3e0f64.1729542372.git.osandov@fb.com>
From: Daniel Verkamp <[email protected]>
Date: Mon, 12 Nov 2018 15:26:52 -0800
Subject: [PATCH] lib/raid6: add option to skip algo benchmarking

This is helpful for systems where fast startup time is important.
It is especially nice to avoid benchmarking RAID functions that are
never used (for example, BTRFS selects RAID6_PQ even if the parity RAID
mode is not in use).

This saves 250+ milliseconds of boot time on modern x86 and ARM systems
with a dozen or more available implementations.

The new option is defaulted to 'y' to match the previous behavior of
always benchmarking on init.

Signed-off-by: Daniel Verkamp <[email protected]>
Signed-off-by: Shaohua Li <[email protected]>
---
include/linux/raid/pq.h | 3 +++
lib/Kconfig | 8 ++++++++
lib/raid6/algos.c | 5 +++++
3 files changed, 16 insertions(+)

diff --git a/include/linux/raid/pq.h b/include/linux/raid/pq.h
index d7c99161bba2..605cf46c17bd 100644
--- a/include/linux/raid/pq.h
+++ b/include/linux/raid/pq.h
@@ -70,6 +70,9 @@ extern const char raid6_empty_zero_page[PAGE_SIZE];
#define MODULE_DESCRIPTION(desc)
#define subsys_initcall(x)
#define module_exit(x)
+
+#define IS_ENABLED(x) (x)
+#define CONFIG_RAID6_PQ_BENCHMARK 1
#endif /* __KERNEL__ */

/* Routine choices */
diff --git a/lib/Kconfig b/lib/Kconfig
index a9965f4af4dd..fcb05305a5a2 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -10,6 +10,14 @@ menu "Library routines"
config RAID6_PQ
tristate

+config RAID6_PQ_BENCHMARK
+ bool "Automatically choose fastest RAID6 PQ functions"
+ depends on RAID6_PQ
+ default y
+ help
+ Benchmark all available RAID6 PQ functions on init and choose the
+ fastest one.
+
config BITREVERSE
tristate

diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c
index a753ff56670f..7e4f7a8ffa8e 100644
--- a/lib/raid6/algos.c
+++ b/lib/raid6/algos.c
@@ -163,6 +163,11 @@ static inline const struct raid6_calls *raid6_choose_gen(
if ((*algo)->valid && !(*algo)->valid())
continue;

+ if (!IS_ENABLED(CONFIG_RAID6_PQ_BENCHMARK)) {
+ best = *algo;
+ break;
+ }
+
perf = 0;

preempt_disable();
--
2.47.0

0 comments on commit ec8dc35

Please sign in to comment.