Re: [patch 2/8] futex: Move futex related mm_struct data into a struct
From: Mathieu Desnoyers
Date: Mon Mar 16 2026 - 14:01:15 EST
On 2026-03-16 13:13, Thomas Gleixner wrote:
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.
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
---
include/linux/futex_types.h | 22 +++++++
include/linux/mm_types.h | 11 ---
kernel/futex/core.c | 123 ++++++++++++++++++++------------------------
3 files changed, 80 insertions(+), 76 deletions(-)
--- a/include/linux/futex_types.h
+++ b/include/linux/futex_types.h
@@ -31,4 +31,26 @@ struct futex_ctrl {
struct futex_ctrl { };
#endif /* !CONFIG_FUTEX */
+/**
+ * struct futex_mm_data - Futex related per MM data
+ * @phash_lock: Mutex to protect the private hash operations
+ * @phash: RCU managed pointer to the private hash
+ * @phash_new: Pointer to a newly allocated private hash
+ * @phash_batches: Batch state for RCU synchronization
+ * @phash_rcu: RCU head for call_rcu()
+ * @phash_atomic: Aggregate value for @phash_ref
+ * @phash_ref: Per CPU reference counter for a private hash
+ */
+struct futex_mm_data {
+#ifdef CONFIG_FUTEX_PRIVATE_HASH
+ struct mutex phash_lock;
+ struct futex_private_hash __rcu *phash;
+ struct futex_private_hash *phash_new;
+ unsigned long phash_batches;
+ struct rcu_head phash_rcu;
+ atomic_long_t phash_atomic;
+ unsigned int __percpu *phash_ref;
+#endif
+};
In the previous patch you use the approach of declaring an empty
structure within the #else, and here the content of the struct is
conditional. Preferably pick one approach ?
Other than this minor nit:
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com