* [PATCH,RFC] Add __GFP_ZERO to GFP_LEVEL_MASK
@ 2006-10-13 20:25 Jonathan Corbet
2006-10-13 20:46 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Corbet @ 2006-10-13 20:25 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm
There is a very helpful comment in <linux/gfp.h>:
/* if you forget to add the bitmask here kernel will crash, period */
Well, my kernel has been crashing (period) at the BUG() in cache_grow();
the offending flag is __GFP_ZERO. I think it needs to be in
GFP_LEVEL_MASK. Anybody know a good reason why it's not there now?
jon
Add __GFP_ZERO to GFP_LEVEL_MASK and cut down on those unsightly oopses.
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
--- /k/t/2.6.19-rc2/include/linux/gfp.h 2006-10-13 13:04:17.000000000 -0600
+++ 19-rc2.jc/include/linux/gfp.h 2006-10-13 14:17:10.000000000 -0600
@@ -54,7 +54,8 @@ struct vm_area_struct;
#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \
__GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \
__GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \
- __GFP_NOMEMALLOC|__GFP_HARDWALL|__GFP_THISNODE)
+ __GFP_ZERO|__GFP_NOMEMALLOC|__GFP_HARDWALL|\
+ __GFP_THISNODE)
/* This equals 0, but use constants in case they ever change */
#define GFP_NOWAIT (GFP_ATOMIC & ~__GFP_HIGH)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH,RFC] Add __GFP_ZERO to GFP_LEVEL_MASK
2006-10-13 20:25 [PATCH,RFC] Add __GFP_ZERO to GFP_LEVEL_MASK Jonathan Corbet
@ 2006-10-13 20:46 ` Andrew Morton
2006-10-13 21:00 ` Jonathan Corbet
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2006-10-13 20:46 UTC (permalink / raw)
To: Jonathan Corbet; +Cc: linux-kernel
On Fri, 13 Oct 2006 14:25:16 -0600
Jonathan Corbet <corbet@lwn.net> wrote:
> There is a very helpful comment in <linux/gfp.h>:
>
> /* if you forget to add the bitmask here kernel will crash, period */
>
> Well, my kernel has been crashing (period) at the BUG() in cache_grow();
> the offending flag is __GFP_ZERO. I think it needs to be in
> GFP_LEVEL_MASK. Anybody know a good reason why it's not there now?
>
It would be a bit odd to pass __GFP_ZERO into the slab allocator. Slab
doesn't need that hint: it has its own ways of initialising the memory.
What is the callsite?
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH,RFC] Add __GFP_ZERO to GFP_LEVEL_MASK
2006-10-13 20:46 ` Andrew Morton
@ 2006-10-13 21:00 ` Jonathan Corbet
2006-10-13 21:31 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Corbet @ 2006-10-13 21:00 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
Andrew Morton <akpm@osdl.org> wrote:
> It would be a bit odd to pass __GFP_ZERO into the slab allocator. Slab
> doesn't need that hint: it has its own ways of initialising the memory.
>
> What is the callsite?
It's vmalloc_user(), which does this:
ret = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
jon
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH,RFC] Add __GFP_ZERO to GFP_LEVEL_MASK
2006-10-13 21:00 ` Jonathan Corbet
@ 2006-10-13 21:31 ` Andrew Morton
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2006-10-13 21:31 UTC (permalink / raw)
To: Jonathan Corbet; +Cc: linux-kernel
On Fri, 13 Oct 2006 15:00:22 -0600
corbet@lwn.net (Jonathan Corbet) wrote:
> Andrew Morton <akpm@osdl.org> wrote:
>
> > It would be a bit odd to pass __GFP_ZERO into the slab allocator. Slab
> > doesn't need that hint: it has its own ways of initialising the memory.
> >
> > What is the callsite?
>
> It's vmalloc_user(), which does this:
>
> ret = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
>
oic, yes, that was a recent change.
I guess this will do the trick?
diff -puN mm/vmalloc.c~vmalloc-dont-pass-__gfp_zero-to-slab mm/vmalloc.c
--- a/mm/vmalloc.c~vmalloc-dont-pass-__gfp_zero-to-slab
+++ a/mm/vmalloc.c
@@ -428,8 +428,11 @@ void *__vmalloc_area_node(struct vm_stru
if (array_size > PAGE_SIZE) {
pages = __vmalloc_node(array_size, gfp_mask, PAGE_KERNEL, node);
area->flags |= VM_VPAGES;
- } else
- pages = kmalloc_node(array_size, (gfp_mask & ~__GFP_HIGHMEM), node);
+ } else {
+ pages = kmalloc_node(array_size,
+ (gfp_mask & ~(__GFP_HIGHMEM | __GFP_ZERO)),
+ node);
+ }
area->pages = pages;
if (!area->pages) {
remove_vm_area(area->addr);
_
(hmm, __vmalloc_area_node and __vmalloc_node are mutually recursive. ick.)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-10-13 21:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-13 20:25 [PATCH,RFC] Add __GFP_ZERO to GFP_LEVEL_MASK Jonathan Corbet
2006-10-13 20:46 ` Andrew Morton
2006-10-13 21:00 ` Jonathan Corbet
2006-10-13 21:31 ` Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.