]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
futex: Create helper function to initialize a hash slot
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Wed, 16 Apr 2025 16:29:11 +0000 (18:29 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Sat, 3 May 2025 10:02:07 +0000 (12:02 +0200)
Factor out the futex_hash_bucket initialisation into a helpr function.
The helper function will be used in a follow up patch implementing
process private hash buckets.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250416162921.513656-12-bigeasy@linutronix.de
kernel/futex/core.c

index 1443a98dfa7fa8d5af8a9a53b0cfe0b8fce953ac..afc66780f84fc038cf07458843c207277c8026c0 100644 (file)
@@ -1160,6 +1160,13 @@ void futex_exit_release(struct task_struct *tsk)
        futex_cleanup_end(tsk, FUTEX_STATE_DEAD);
 }
 
+static void futex_hash_bucket_init(struct futex_hash_bucket *fhb)
+{
+       atomic_set(&fhb->waiters, 0);
+       plist_head_init(&fhb->chain);
+       spin_lock_init(&fhb->lock);
+}
+
 static int __init futex_init(void)
 {
        unsigned long hashsize, i;
@@ -1177,11 +1184,8 @@ static int __init futex_init(void)
                                               hashsize, hashsize);
        hashsize = 1UL << futex_shift;
 
-       for (i = 0; i < hashsize; i++) {
-               atomic_set(&futex_queues[i].waiters, 0);
-               plist_head_init(&futex_queues[i].chain);
-               spin_lock_init(&futex_queues[i].lock);
-       }
+       for (i = 0; i < hashsize; i++)
+               futex_hash_bucket_init(&futex_queues[i]);
 
        futex_hashmask = hashsize - 1;
        return 0;