Re: [PATCH] mm/mempool: warn about __GFP_ZERO usage

From: Andrew Morton
Date: Wed Apr 16 2014 - 17:16:11 EST


On Mon, 14 Apr 2014 19:23:34 +0200 (CEST) Sebastian Ott <sebott@xxxxxxxxxxxxxxxxxx> wrote:

> Memory obtained via mempool_alloc is not always zeroed even when
> called with __GFP_ZERO. Add a note and VM_BUG_ON statement to make
> that clear.
>
> ..
>
> @@ -200,6 +201,7 @@ void * mempool_alloc(mempool_t *pool, gf
> wait_queue_t wait;
> gfp_t gfp_temp;
>
> + VM_BUG_ON(gfp_mask & __GFP_ZERO);
> might_sleep_if(gfp_mask & __GFP_WAIT);
>
> gfp_mask |= __GFP_NOMEMALLOC; /* don't allocate emergency reserves */

hm, BUG is a bit harsh. How about

--- a/mm/mempool.c~mm-mempool-warn-about-__gfp_zero-usage-fix
+++ a/mm/mempool.c
@@ -201,7 +201,9 @@ void * mempool_alloc(mempool_t *pool, gf
wait_queue_t wait;
gfp_t gfp_temp;

- VM_BUG_ON(gfp_mask & __GFP_ZERO);
+#ifdef CONFIG_DEBUG_VM
+ WARN_ON_ONCE(gfp_mask & __GFP_ZERO); /* Where's VM_WARN_ON_ONCE()? */
+#endif
might_sleep_if(gfp_mask & __GFP_WAIT);

gfp_mask |= __GFP_NOMEMALLOC; /* don't allocate emergency reserves */

?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/