Skip to content

Commit 63b1a81

Browse files
heicarstIngo Molnar
authored andcommitted
futexes: Fix futex_hashsize initialization
"futexes: Increase hash table size for better performance" introduces a new alloc_large_system_hash() call. alloc_large_system_hash() however may allocate less memory than requested, e.g. limited by MAX_ORDER. Hence pass a pointer to alloc_large_system_hash() which will contain the hash shift when the function returns. Afterwards correctly set futex_hashsize. Fixes a crash on s390 where the requested allocation size was 4MB but only 1MB was allocated. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Darren Hart <dvhart@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Waiman Long <Waiman.Long@hp.com> Cc: Jason Low <jason.low2@hp.com> Cc: Davidlohr Bueso <davidlohr@hp.com> Link: http://lkml.kernel.org/r/20140116135450.GA4345@osiris Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent f549ed1 commit 63b1a81

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/futex.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,6 +2844,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
28442844
static int __init futex_init(void)
28452845
{
28462846
u32 curval;
2847+
unsigned int futex_shift;
28472848
unsigned long i;
28482849

28492850
#if CONFIG_BASE_SMALL
@@ -2855,8 +2856,9 @@ static int __init futex_init(void)
28552856
futex_queues = alloc_large_system_hash("futex", sizeof(*futex_queues),
28562857
futex_hashsize, 0,
28572858
futex_hashsize < 256 ? HASH_SMALL : 0,
2858-
NULL, NULL, futex_hashsize, futex_hashsize);
2859-
2859+
&futex_shift, NULL,
2860+
futex_hashsize, futex_hashsize);
2861+
futex_hashsize = 1UL << futex_shift;
28602862
/*
28612863
* This will fail and we want it. Some arch implementations do
28622864
* runtime detection of the futex_atomic_cmpxchg_inatomic()

0 commit comments

Comments
 (0)