Skip to content

Commit 03aef06

Browse files
mjguzikbrauner
authored andcommitted
pid: reorder fields in pid_namespace to reduce false sharing
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> Link: https://patch.msgid.link/20260120204820.1497002-1-mjguzik@gmail.com Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 8021824 commit 03aef06

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

include/linux/pid_namespace.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ struct pid_namespace {
2727
struct idr idr;
2828
struct rcu_head rcu;
2929
unsigned int pid_allocated;
30+
#ifdef CONFIG_SYSCTL
31+
#if defined(CONFIG_MEMFD_CREATE)
32+
int memfd_noexec_scope;
33+
#endif
34+
struct ctl_table_set set;
35+
struct ctl_table_header *sysctls;
36+
#endif
3037
struct task_struct *child_reaper;
3138
struct kmem_cache *pid_cachep;
3239
unsigned int level;
@@ -40,13 +47,6 @@ struct pid_namespace {
4047
int reboot; /* group exit code if this pidns was rebooted */
4148
struct ns_common ns;
4249
struct work_struct work;
43-
#ifdef CONFIG_SYSCTL
44-
struct ctl_table_set set;
45-
struct ctl_table_header *sysctls;
46-
#if defined(CONFIG_MEMFD_CREATE)
47-
int memfd_noexec_scope;
48-
#endif
49-
#endif
5050
} __randomize_layout;
5151

5252
extern struct pid_namespace init_pid_ns;

0 commit comments

Comments
 (0)