mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-30 22:03:17 +01:00
futex: Relax the rcu_assign_pointer() assignment of mm->futex_phash in futex_mm_init()
The following commit added an rcu_assign_pointer() assignment to futex_mm_init() in <linux/futex.h>:bd54df5ea7("futex: Allow to resize the private local hash") Which breaks the build on older compilers (gcc-9, x86-64 defconfig): CC io_uring/futex.o In file included from ./arch/x86/include/generated/asm/rwonce.h:1, from ./include/linux/compiler.h:390, from ./include/linux/array_size.h:5, from ./include/linux/kernel.h:16, from io_uring/futex.c:2: ./include/linux/futex.h: In function 'futex_mm_init': ./include/linux/rcupdate.h:555:36: error: dereferencing pointer to incomplete type 'struct futex_private_hash' The problem is that this variant of rcu_assign_pointer() wants to know the full type of 'struct futex_private_hash', which type is local to futex.c: kernel/futex/core.c:struct futex_private_hash { There are a couple of mechanical solutions for this bug: - we can uninline futex_mm_init() and move it into futex/core.c - or we can share the structure definition with kernel/fork.c. But both of these solutions have disadvantages: the first one adds runtime overhead, while the second one dis-encapsulates private futex types. A third solution, implemented by this patch, is to just initialize mm->futex_phash with NULL like the patch below, it's not like this new MM's ->futex_phash can be observed externally until the task is inserted into the task list, which guarantees full store ordering. The relaxation of this initialization might also give a tiny speedup on certain platforms. Fixes:bd54df5ea7("futex: Allow to resize the private local hash") Signed-off-by: Ingo Molnar <[email protected]> Cc: André Almeida <[email protected]> Cc: Darren Hart <[email protected]> Cc: Davidlohr Bueso <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Sebastian Andrzej Siewior <[email protected]> Cc: Valentin Schneider <[email protected]> Cc: Waiman Long <[email protected]> Link: https://lore.kernel.org/r/[email protected]
This commit is contained in:
1 parent
01475aedfd
commit
094ac8cff7
1 file changed
+8
-1
@@ -88,7 +88,14 @@ void futex_hash_free(struct mm_struct *mm);
|
||||
|
||||
static inline void futex_mm_init(struct mm_struct *mm)
|
||||
{
|
||||
rcu_assign_pointer(mm->futex_phash, NULL);
|
||||
/*
|
||||
* No need for rcu_assign_pointer() here, as we can rely on
|
||||
* tasklist_lock write-ordering in copy_process(), before
|
||||
* the task's MM becomes visible and the ->futex_phash
|
||||
* becomes externally observable:
|
||||
*/
|
||||
mm->futex_phash = NULL;
|
||||
|
||||
mutex_init(&mm->futex_hash_lock);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user