Re: [patch 1/9] GFP_ZERO fix

Manfred Spraul
2005-04-14T11:54:16Z

Andrew Morton wrote:

>Nick Piggin <nickpiggin@yahoo.com.au> wrote:
>
>
>> #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_COLD|__GFP_NOWARN|__GFP_REPEAT|__GFP_NOFAIL| \
>> + __GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP|__GFP_ZERO)
>>
>>
>
>Passing GFP_ZERO into kmem_cache_alloc() is such a bizarre thing to do,
>perhaps a BUG is the correct response.
>
>I guess it could be argued that the kmem_cache_alloc() callers "knows" that
>the ctor will be zeroing out all the objects, but it would seem cleaner to
>me to pass the "you should use GFP_ZERO" hint into kmem_cache_create()
>rather than kmem_cache_alloc().
>
>
Right now, slab is not really suitable for GFP_ZERO:
- if debug is enabled, then objects are definitively not 0-initialized.
- if a ctor is used for zero initialization, then objects would have to
be zeroed before kmem_cache_free: The ctor is only called at object
creation, not before object reuse. But memset(,0,) just before free
would be a bit silly.

Probably a BUG_ON or WARN_ON should be added into kmem_flagcheck() and
into kmem_cache_create().

Should I write a patch?
--
Manfred