* [patch 3/9] slab: have index_of bug at compile time
@ 2006-01-03 20:25 Pekka Enberg
0 siblings, 0 replies; only message in thread
From: Pekka Enberg @ 2006-01-03 20:25 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, manfred, colpatch, rostedt, clameter, penberg
From: Steven Rostedt <rostedt@goodmis.org>
I noticed the code for index_of is a creative way of finding the cache
index using the compiler to optimize to a single hard coded number. But
I couldn't help noticing that it uses two methods to let you know that
someone used it wrong. One is at compile time (the correct way), and
the other is at run time (not good).
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
mm/slab.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
Index: 2.6/mm/slab.c
===================================================================
--- 2.6.orig/mm/slab.c
+++ 2.6/mm/slab.c
@@ -315,6 +315,8 @@ struct kmem_list3 __initdata initkmem_li
*/
static __always_inline int index_of(const size_t size)
{
+ extern void __bad_size(void);
+
if (__builtin_constant_p(size)) {
int i = 0;
@@ -325,12 +327,9 @@ static __always_inline int index_of(cons
i++;
#include "linux/kmalloc_sizes.h"
#undef CACHE
- {
- extern void __bad_size(void);
- __bad_size();
- }
+ __bad_size();
} else
- BUG();
+ __bad_size();
return 0;
}
--
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-01-03 20:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-03 20:25 [patch 3/9] slab: have index_of bug at compile time Pekka Enberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox