summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@kernel.org>2026-06-02 11:09:34 +0200
committerPeter Zijlstra <peterz@infradead.org>2026-06-03 11:38:49 +0200
commit1f7f4816b9b05e5110bc1c8a05c3c478e2dae11b (patch)
treeb0d8ace13517c0d903ae848854bd853bb4c612bd /include/linux
parentd7b3f52c861f54ba2fff15696d3798277fb4c19f (diff)
downloadlwn-1f7f4816b9b05e5110bc1c8a05c3c478e2dae11b.tar.gz
lwn-1f7f4816b9b05e5110bc1c8a05c3c478e2dae11b.zip
futex: Move futex related mm_struct data into a struct
Having all these members in mm_struct along with the required #ifdeffery is annoying, does not allow efficient initializing of the data with memset() and makes extending it tedious. Move it into a data structure and fix up all usage sites. The extra struct for the private hash is intentional to make integration of other conditional mechanisms easier in terms of initialization and separation. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20260602090535.407756793@kernel.org
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/futex_types.h36
-rw-r--r--include/linux/mm_types.h12
2 files changed, 37 insertions, 11 deletions
diff --git a/include/linux/futex_types.h b/include/linux/futex_types.h
index 9c6c0dc4148d..d41557d2790d 100644
--- a/include/linux/futex_types.h
+++ b/include/linux/futex_types.h
@@ -3,6 +3,7 @@
#define _LINUX_FUTEX_TYPES_H
#ifdef CONFIG_FUTEX
+#include <linux/compiler_types.h>
#include <linux/mutex_types.h>
#include <linux/types.h>
@@ -29,8 +30,41 @@ struct futex_sched_data {
struct mutex exit_mutex;
unsigned int state;
};
-#else
+
+#ifdef CONFIG_FUTEX_PRIVATE_HASH
+/**
+ * struct futex_mm_phash - Futex private hash related per MM data
+ * @lock: Mutex to protect the private hash operations
+ * @hash: RCU managed pointer to the private hash
+ * @hash_new: Pointer to a newly allocated private hash
+ * @batches: Batch state for RCU synchronization
+ * @rcu: RCU head for call_rcu()
+ * @atomic: Aggregate value for @hash_ref
+ * @ref: Per CPU reference counter for a private hash
+ */
+struct futex_mm_phash {
+ struct mutex lock;
+ struct futex_private_hash __rcu *hash;
+ struct futex_private_hash *hash_new;
+ unsigned long batches;
+ struct rcu_head rcu;
+ atomic_long_t atomic;
+ unsigned int __percpu *ref;
+};
+#else /* CONFIG_FUTEX_ROBUST_UNLOCK */
+struct futex_mm_phash { };
+#endif /* !CONFIG_FUTEX_ROBUST_UNLOCK */
+
+/**
+ * struct futex_mm_data - Futex related per MM data
+ * @phash: Futex private hash related data
+ */
+struct futex_mm_data {
+ struct futex_mm_phash phash;
+};
+#else /* CONFIG_FUTEX */
struct futex_sched_data { };
+struct futex_mm_data { };
#endif /* !CONFIG_FUTEX */
#endif /* _LINUX_FUTEX_TYPES_H */
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index a308e2c23b82..1d0c8d8875aa 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -20,6 +20,7 @@
#include <linux/seqlock.h>
#include <linux/percpu_counter.h>
#include <linux/types.h>
+#include <linux/futex_types.h>
#include <linux/rseq_types.h>
#include <linux/bitmap.h>
@@ -1270,16 +1271,7 @@ struct mm_struct {
*/
seqcount_t mm_lock_seq;
#endif
-#ifdef CONFIG_FUTEX_PRIVATE_HASH
- struct mutex futex_hash_lock;
- struct futex_private_hash __rcu *futex_phash;
- struct futex_private_hash *futex_phash_new;
- /* futex-ref */
- unsigned long futex_batches;
- struct rcu_head futex_rcu;
- atomic_long_t futex_atomic;
- unsigned int __percpu *futex_ref;
-#endif
+ struct futex_mm_data futex;
unsigned long hiwater_rss; /* High-watermark of RSS usage */
unsigned long hiwater_vm; /* High-water virtual memory usage */