* [PATCH] mm: remove broken 'kzalloc' mempool
[not found] ` <1249332888-13440-2-git-send-email-sage@newdream.net>
@ 2009-08-03 20:54 ` Sage Weil
2009-08-03 20:57 ` Sage Weil
0 siblings, 1 reply; 2+ messages in thread
From: Sage Weil @ 2009-08-03 20:54 UTC (permalink / raw)
To: linux-kernel; +Cc: Sage Weil, linux-mm
The kzalloc mempool zeros items when they are initially allocated, but
does not rezero used items that are returned to the pool. Consequently
mempool_alloc()s may return non-zeroed memory.
Since there are/were only two in-tree users for mempool_create_kzalloc_pool(),
and 'fixing' this in a way that will re-zero used (but not new) items
before first use is non-trivial, just remove it.
CC: <linux-mm@kvack.org>
Signed-off-by: Sage Weil <sage@newdream.net>
---
include/linux/mempool.h | 10 ++--------
mm/mempool.c | 7 -------
2 files changed, 2 insertions(+), 15 deletions(-)
diff --git a/include/linux/mempool.h b/include/linux/mempool.h
index 9be484d..7c08052 100644
--- a/include/linux/mempool.h
+++ b/include/linux/mempool.h
@@ -47,22 +47,16 @@ mempool_create_slab_pool(int min_nr, struct kmem_cache *kc)
}
/*
- * 2 mempool_alloc_t's and a mempool_free_t to kmalloc/kzalloc and kfree
- * the amount of memory specified by pool_data
+ * a mempool_alloc_t and a mempool_free_t to kmalloc and kfree the
+ * amount of memory specified by pool_data
*/
void *mempool_kmalloc(gfp_t gfp_mask, void *pool_data);
-void *mempool_kzalloc(gfp_t gfp_mask, void *pool_data);
void mempool_kfree(void *element, void *pool_data);
static inline mempool_t *mempool_create_kmalloc_pool(int min_nr, size_t size)
{
return mempool_create(min_nr, mempool_kmalloc, mempool_kfree,
(void *) size);
}
-static inline mempool_t *mempool_create_kzalloc_pool(int min_nr, size_t size)
-{
- return mempool_create(min_nr, mempool_kzalloc, mempool_kfree,
- (void *) size);
-}
/*
* A mempool_alloc_t and mempool_free_t for a simple page allocator that
diff --git a/mm/mempool.c b/mm/mempool.c
index a46eb1b..eea4f7d 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -308,13 +308,6 @@ void *mempool_kmalloc(gfp_t gfp_mask, void *pool_data)
}
EXPORT_SYMBOL(mempool_kmalloc);
-void *mempool_kzalloc(gfp_t gfp_mask, void *pool_data)
-{
- size_t size = (size_t) pool_data;
- return kzalloc(size, gfp_mask);
-}
-EXPORT_SYMBOL(mempool_kzalloc);
-
void mempool_kfree(void *element, void *pool_data)
{
kfree(element);
--
1.5.6.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mm: remove broken 'kzalloc' mempool
2009-08-03 20:54 ` [PATCH] mm: remove broken 'kzalloc' mempool Sage Weil
@ 2009-08-03 20:57 ` Sage Weil
0 siblings, 0 replies; 2+ messages in thread
From: Sage Weil @ 2009-08-03 20:57 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-mm
On Mon, 3 Aug 2009, Sage Weil wrote:
> The kzalloc mempool zeros items when they are initially allocated, but
> does not rezero used items that are returned to the pool. Consequently
> mempool_alloc()s may return non-zeroed memory.
>
> Since there are/were only two in-tree users for mempool_create_kzalloc_pool(),
> and 'fixing' this in a way that will re-zero used (but not new) items
> before first use is non-trivial, just remove it.
This should of course only be applied after the fixes for the two callers
(dm multipath and ibmvscsi), whatever the protocol for order that may
be...
sage
>
> CC: <linux-mm@kvack.org>
> Signed-off-by: Sage Weil <sage@newdream.net>
> ---
> include/linux/mempool.h | 10 ++--------
> mm/mempool.c | 7 -------
> 2 files changed, 2 insertions(+), 15 deletions(-)
>
> diff --git a/include/linux/mempool.h b/include/linux/mempool.h
> index 9be484d..7c08052 100644
> --- a/include/linux/mempool.h
> +++ b/include/linux/mempool.h
> @@ -47,22 +47,16 @@ mempool_create_slab_pool(int min_nr, struct kmem_cache *kc)
> }
>
> /*
> - * 2 mempool_alloc_t's and a mempool_free_t to kmalloc/kzalloc and kfree
> - * the amount of memory specified by pool_data
> + * a mempool_alloc_t and a mempool_free_t to kmalloc and kfree the
> + * amount of memory specified by pool_data
> */
> void *mempool_kmalloc(gfp_t gfp_mask, void *pool_data);
> -void *mempool_kzalloc(gfp_t gfp_mask, void *pool_data);
> void mempool_kfree(void *element, void *pool_data);
> static inline mempool_t *mempool_create_kmalloc_pool(int min_nr, size_t size)
> {
> return mempool_create(min_nr, mempool_kmalloc, mempool_kfree,
> (void *) size);
> }
> -static inline mempool_t *mempool_create_kzalloc_pool(int min_nr, size_t size)
> -{
> - return mempool_create(min_nr, mempool_kzalloc, mempool_kfree,
> - (void *) size);
> -}
>
> /*
> * A mempool_alloc_t and mempool_free_t for a simple page allocator that
> diff --git a/mm/mempool.c b/mm/mempool.c
> index a46eb1b..eea4f7d 100644
> --- a/mm/mempool.c
> +++ b/mm/mempool.c
> @@ -308,13 +308,6 @@ void *mempool_kmalloc(gfp_t gfp_mask, void *pool_data)
> }
> EXPORT_SYMBOL(mempool_kmalloc);
>
> -void *mempool_kzalloc(gfp_t gfp_mask, void *pool_data)
> -{
> - size_t size = (size_t) pool_data;
> - return kzalloc(size, gfp_mask);
> -}
> -EXPORT_SYMBOL(mempool_kzalloc);
> -
> void mempool_kfree(void *element, void *pool_data)
> {
> kfree(element);
> --
> 1.5.6.5
>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-08-03 20:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1249332888-13440-1-git-send-email-sage@newdream.net>
[not found] ` <1249332888-13440-2-git-send-email-sage@newdream.net>
2009-08-03 20:54 ` [PATCH] mm: remove broken 'kzalloc' mempool Sage Weil
2009-08-03 20:57 ` Sage Weil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox