public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] slab: Fix off by one in object max number tests.
@ 2014-05-05 20:20 David Miller
  2014-05-05 20:57 ` David Miller
  0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2014-05-05 20:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: iamjoonsoo.kim, sparclinux, hannes, cl, penberg, torvalds


If freelist_idx_t is a byte, SLAB_OBJ_MAX_NUM should be 255 not 256,
and likewise if freelist_idx_t is a short, then it should be 65535 not
65536.

Fixes: a41adfa ("slab: introduce byte sized index for the freelist of a slab")
Signed-off-by: David S. Miller <davem@davemloft.net>
---

This was leading to all kinds of random crashes on sparc64 where PAGE_SIZE
is 8192.  One problem shown was that if spinlock debugging was enabled,
we'd get deadlocks in copy_pte_range() or do_wp_page() with the same cpu
already holding a lock it shouldn't hold, or the lock belonging to a
completely unrelated process.

diff --git a/mm/slab.c b/mm/slab.c
index 388cb1a..37de3a7 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -166,7 +166,7 @@ typedef unsigned char freelist_idx_t;
 typedef unsigned short freelist_idx_t;
 #endif
 
-#define SLAB_OBJ_MAX_NUM (1 << sizeof(freelist_idx_t) * BITS_PER_BYTE)
+#define SLAB_OBJ_MAX_NUM ((1 << sizeof(freelist_idx_t) * BITS_PER_BYTE) - 1)
 
 /*
  * true if a page was allocated from pfmemalloc reserves for network-based

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

end of thread, other threads:[~2014-05-06  4:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-05 20:20 [PATCH] slab: Fix off by one in object max number tests David Miller
2014-05-05 20:57 ` David Miller
2014-05-05 21:05   ` Sam Ravnborg
2014-05-05 21:08     ` David Miller
2014-05-06  3:25       ` David Miller
2014-05-06  3:32         ` Linus Torvalds
2014-05-06  3:46           ` Linus Torvalds
2014-05-06  3:48             ` David Miller
2014-05-06  4:04           ` Pekka Enberg

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