The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH -next] futex: fix futex_hashsize initialization
@ 2014-01-16 13:54 Heiko Carstens
  2014-01-16 14:18 ` [tip:core/locking] futexes: Fix " tip-bot for Heiko Carstens
  0 siblings, 1 reply; 2+ messages in thread
From: Heiko Carstens @ 2014-01-16 13:54 UTC (permalink / raw)
  To: Ingo Molnar, Davidlohr Bueso
  Cc: linux-next, linux-kernel, Thomas Gleixner, Darren Hart,
	Peter Zijlstra, Paul E. McKenney, Waiman Long, Jason Low

"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>
---
 kernel/futex.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index 3666aa0017ed..44a1261cb9ff 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2846,6 +2846,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
 static int __init futex_init(void)
 {
 	u32 curval;
+	unsigned int futex_shift;
 	unsigned long i;
 
 #if CONFIG_BASE_SMALL
@@ -2857,8 +2858,9 @@ static int __init futex_init(void)
 	futex_queues = alloc_large_system_hash("futex", sizeof(*futex_queues),
 					       futex_hashsize, 0,
 					       futex_hashsize < 256 ? HASH_SMALL : 0,
-					       NULL, NULL, futex_hashsize, futex_hashsize);
-
+					       &futex_shift, NULL,
+					       futex_hashsize, futex_hashsize);
+	futex_hashsize = 1UL << futex_shift;
 	/*
 	 * This will fail and we want it. Some arch implementations do
 	 * runtime detection of the futex_atomic_cmpxchg_inatomic()
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip:core/locking] futexes: Fix futex_hashsize initialization
  2014-01-16 13:54 [PATCH -next] futex: fix futex_hashsize initialization Heiko Carstens
@ 2014-01-16 14:18 ` tip-bot for Heiko Carstens
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Heiko Carstens @ 2014-01-16 14:18 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, dvhart, peterz, jason.low2, paulmck,
	Waiman.Long, heiko.carstens, tglx, davidlohr

Commit-ID:  63b1a81699c2a45c9f737419b1ec1da0ecf92812
Gitweb:     http://git.kernel.org/tip/63b1a81699c2a45c9f737419b1ec1da0ecf92812
Author:     Heiko Carstens <heiko.carstens@de.ibm.com>
AuthorDate: Thu, 16 Jan 2014 14:54:50 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 16 Jan 2014 15:14:32 +0100

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>
---
 kernel/futex.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/futex.c b/kernel/futex.c
index 30971b5..1ddc449 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2844,6 +2844,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
 static int __init futex_init(void)
 {
 	u32 curval;
+	unsigned int futex_shift;
 	unsigned long i;
 
 #if CONFIG_BASE_SMALL
@@ -2855,8 +2856,9 @@ static int __init futex_init(void)
 	futex_queues = alloc_large_system_hash("futex", sizeof(*futex_queues),
 					       futex_hashsize, 0,
 					       futex_hashsize < 256 ? HASH_SMALL : 0,
-					       NULL, NULL, futex_hashsize, futex_hashsize);
-
+					       &futex_shift, NULL,
+					       futex_hashsize, futex_hashsize);
+	futex_hashsize = 1UL << futex_shift;
 	/*
 	 * This will fail and we want it. Some arch implementations do
 	 * runtime detection of the futex_atomic_cmpxchg_inatomic()

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-16 14:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-16 13:54 [PATCH -next] futex: fix futex_hashsize initialization Heiko Carstens
2014-01-16 14:18 ` [tip:core/locking] futexes: Fix " tip-bot for Heiko Carstens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox