* [PATCH] fix weird kmalloc bug
@ 2003-06-15 2:28 Paul Mackerras
2003-06-15 6:07 ` David S. Miller
0 siblings, 1 reply; 2+ messages in thread
From: Paul Mackerras @ 2003-06-15 2:28 UTC (permalink / raw)
To: akpm, torvalds, linux-kernel; +Cc: manfred
Last night, Manfred and I found an interesting bug with kmalloc on
ppc32, where the kmalloc in alloc_super() (fs/super.c) was requesting
432 bytes but only getting 256 bytes. The reason was that PAGE_SIZE
wasn't defined at the point where the kmalloc() inline function
occurs. Thus the CACHE(32) entry got omitted from the list in
kmalloc_sizes.h, and kmalloc therefore used the entry in
malloc_sizes[] before the correct entry.
This patch fixes it by including asm/page.h and asm/cache.h in
linux/slab.h. The list in kmalloc_sizes.h depends on L1_CACHE_BYTES
as well as PAGE_SIZE, which is why I added asm/cache.h.
Paul.
diff -urN linux-2.5/include/linux/slab.h pmac-2.5-smp/include/linux/slab.h
--- linux-2.5/include/linux/slab.h 2003-06-12 10:43:55.000000000 +1000
+++ pmac-2.5/include/linux/slab.h 2003-06-14 22:16:14.000000000 +1000
@@ -13,6 +13,8 @@
#include <linux/gfp.h>
#include <linux/types.h>
+#include <asm/page.h>
+#include <asm/cache.h>
/* flags for kmem_cache_alloc() */
#define SLAB_NOFS GFP_NOFS
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] fix weird kmalloc bug
2003-06-15 2:28 [PATCH] fix weird kmalloc bug Paul Mackerras
@ 2003-06-15 6:07 ` David S. Miller
0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2003-06-15 6:07 UTC (permalink / raw)
To: Paul Mackerras; +Cc: akpm, torvalds, linux-kernel, manfred
On Sat, 2003-06-14 at 19:28, Paul Mackerras wrote:
> This patch fixes it by including asm/page.h and asm/cache.h in
> linux/slab.h. The list in kmalloc_sizes.h depends on L1_CACHE_BYTES
> as well as PAGE_SIZE, which is why I added asm/cache.h.
Please use linux/cache.h, we should provide some kind of
"#error don't directly include asm/blah.h" protection into
various headers such as asm/cache.h, asm/delay.h, etc.
--
David S. Miller <davem@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-06-15 5:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-15 2:28 [PATCH] fix weird kmalloc bug Paul Mackerras
2003-06-15 6:07 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®