* [PATCH] pid: reorder fields in pid_namespace to reduce false sharing
@ 2026-01-20 20:48 Mateusz Guzik
2026-01-21 9:27 ` Jan Kara
2026-01-23 10:26 ` Christian Brauner
0 siblings, 2 replies; 3+ messages in thread
From: Mateusz Guzik @ 2026-01-20 20:48 UTC (permalink / raw)
To: brauner; +Cc: viro, jack, linux-kernel, linux-fsdevel, Mateusz Guzik
alloc_pid() loads pid_cachep, level and pid_max prior to taking the
lock.
It dirties idr and pid_allocated with the lock.
Some of these fields share the cacheline as is, split them up.
No change in the size of the struct.
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
this is independent of other patches
i got an inconsistent win in terms of throughput rate, but relative
contention between pidmap lock and the rest went down
include/linux/pid_namespace.h | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index 0e7ae12c96d2..b20baaa7e62b 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -27,6 +27,13 @@ struct pid_namespace {
struct idr idr;
struct rcu_head rcu;
unsigned int pid_allocated;
+#ifdef CONFIG_SYSCTL
+#if defined(CONFIG_MEMFD_CREATE)
+ int memfd_noexec_scope;
+#endif
+ struct ctl_table_set set;
+ struct ctl_table_header *sysctls;
+#endif
struct task_struct *child_reaper;
struct kmem_cache *pid_cachep;
unsigned int level;
@@ -40,13 +47,6 @@ struct pid_namespace {
int reboot; /* group exit code if this pidns was rebooted */
struct ns_common ns;
struct work_struct work;
-#ifdef CONFIG_SYSCTL
- struct ctl_table_set set;
- struct ctl_table_header *sysctls;
-#if defined(CONFIG_MEMFD_CREATE)
- int memfd_noexec_scope;
-#endif
-#endif
} __randomize_layout;
extern struct pid_namespace init_pid_ns;
--
2.48.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pid: reorder fields in pid_namespace to reduce false sharing
2026-01-20 20:48 [PATCH] pid: reorder fields in pid_namespace to reduce false sharing Mateusz Guzik
@ 2026-01-21 9:27 ` Jan Kara
2026-01-23 10:26 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2026-01-21 9:27 UTC (permalink / raw)
To: Mateusz Guzik; +Cc: brauner, viro, jack, linux-kernel, linux-fsdevel
On Tue 20-01-26 21:48:20, Mateusz Guzik wrote:
> alloc_pid() loads pid_cachep, level and pid_max prior to taking the
> lock.
>
> It dirties idr and pid_allocated with the lock.
>
> Some of these fields share the cacheline as is, split them up.
>
> No change in the size of the struct.
>
> Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Looks ok. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
>
> this is independent of other patches
>
> i got an inconsistent win in terms of throughput rate, but relative
> contention between pidmap lock and the rest went down
>
> include/linux/pid_namespace.h | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
> index 0e7ae12c96d2..b20baaa7e62b 100644
> --- a/include/linux/pid_namespace.h
> +++ b/include/linux/pid_namespace.h
> @@ -27,6 +27,13 @@ struct pid_namespace {
> struct idr idr;
> struct rcu_head rcu;
> unsigned int pid_allocated;
> +#ifdef CONFIG_SYSCTL
> +#if defined(CONFIG_MEMFD_CREATE)
> + int memfd_noexec_scope;
> +#endif
> + struct ctl_table_set set;
> + struct ctl_table_header *sysctls;
> +#endif
> struct task_struct *child_reaper;
> struct kmem_cache *pid_cachep;
> unsigned int level;
> @@ -40,13 +47,6 @@ struct pid_namespace {
> int reboot; /* group exit code if this pidns was rebooted */
> struct ns_common ns;
> struct work_struct work;
> -#ifdef CONFIG_SYSCTL
> - struct ctl_table_set set;
> - struct ctl_table_header *sysctls;
> -#if defined(CONFIG_MEMFD_CREATE)
> - int memfd_noexec_scope;
> -#endif
> -#endif
> } __randomize_layout;
>
> extern struct pid_namespace init_pid_ns;
> --
> 2.48.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pid: reorder fields in pid_namespace to reduce false sharing
2026-01-20 20:48 [PATCH] pid: reorder fields in pid_namespace to reduce false sharing Mateusz Guzik
2026-01-21 9:27 ` Jan Kara
@ 2026-01-23 10:26 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2026-01-23 10:26 UTC (permalink / raw)
To: Mateusz Guzik; +Cc: Christian Brauner, viro, jack, linux-kernel, linux-fsdevel
On Tue, 20 Jan 2026 21:48:20 +0100, Mateusz Guzik wrote:
> alloc_pid() loads pid_cachep, level and pid_max prior to taking the
> lock.
>
> It dirties idr and pid_allocated with the lock.
>
> Some of these fields share the cacheline as is, split them up.
>
> [...]
Applied to the kernel-7.0.misc branch of the vfs/vfs.git tree.
Patches in the kernel-7.0.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: kernel-7.0.misc
[1/1] pid: reorder fields in pid_namespace to reduce false sharing
https://git.kernel.org/vfs/vfs/c/e7d0463629d1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-23 10:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-20 20:48 [PATCH] pid: reorder fields in pid_namespace to reduce false sharing Mateusz Guzik
2026-01-21 9:27 ` Jan Kara
2026-01-23 10:26 ` Christian Brauner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®