diff options
author | Tejun Heo <tj@kernel.org> | 2012-06-04 23:40:53 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-06-25 05:53:47 -0400 |
commit | a91a5ac6858fbf7477131e1210cb3e897b668e6f (patch) | |
tree | 01ff0eff5088efc3459cf139e349414e35068493 | |
parent | 159749937a3e1605068a454b1607cdc5714f16e6 (diff) |
mempool: add @gfp_mask to mempool_create_node()
mempool_create_node() currently assumes %GFP_KERNEL. Its only user,
blk_init_free_list(), is about to be updated to use other allocation
flags - add @gfp_mask argument to the function.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/blk-core.c | 4 | ||||
-rw-r--r-- | include/linux/mempool.h | 3 | ||||
-rw-r--r-- | mm/mempool.c | 12 |
3 files changed, 11 insertions, 8 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 93eb3e4f88ce..64f9a8668253 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -531,8 +531,8 @@ static int blk_init_free_list(struct request_queue *q) | |||
531 | init_waitqueue_head(&rl->wait[BLK_RW_ASYNC]); | 531 | init_waitqueue_head(&rl->wait[BLK_RW_ASYNC]); |
532 | 532 | ||
533 | rl->rq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab, | 533 | rl->rq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab, |
534 | mempool_free_slab, request_cachep, q->node); | 534 | mempool_free_slab, request_cachep, |
535 | 535 | GFP_KERNEL, q->node); | |
536 | if (!rl->rq_pool) | 536 | if (!rl->rq_pool) |
537 | return -ENOMEM; | 537 | return -ENOMEM; |
538 | 538 | ||
diff --git a/include/linux/mempool.h b/include/linux/mempool.h index 7c08052e3321..39ed62ab5b8a 100644 --- a/include/linux/mempool.h +++ b/include/linux/mempool.h | |||
@@ -26,7 +26,8 @@ typedef struct mempool_s { | |||
26 | extern mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn, | 26 | extern mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn, |
27 | mempool_free_t *free_fn, void *pool_data); | 27 | mempool_free_t *free_fn, void *pool_data); |
28 | extern mempool_t *mempool_create_node(int min_nr, mempool_alloc_t *alloc_fn, | 28 | extern mempool_t *mempool_create_node(int min_nr, mempool_alloc_t *alloc_fn, |
29 | mempool_free_t *free_fn, void *pool_data, int nid); | 29 | mempool_free_t *free_fn, void *pool_data, |
30 | gfp_t gfp_mask, int nid); | ||
30 | 31 | ||
31 | extern int mempool_resize(mempool_t *pool, int new_min_nr, gfp_t gfp_mask); | 32 | extern int mempool_resize(mempool_t *pool, int new_min_nr, gfp_t gfp_mask); |
32 | extern void mempool_destroy(mempool_t *pool); | 33 | extern void mempool_destroy(mempool_t *pool); |
diff --git a/mm/mempool.c b/mm/mempool.c index d9049811f352..54990476c049 100644 --- a/mm/mempool.c +++ b/mm/mempool.c | |||
@@ -63,19 +63,21 @@ EXPORT_SYMBOL(mempool_destroy); | |||
63 | mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn, | 63 | mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn, |
64 | mempool_free_t *free_fn, void *pool_data) | 64 | mempool_free_t *free_fn, void *pool_data) |
65 | { | 65 | { |
66 | return mempool_create_node(min_nr,alloc_fn,free_fn, pool_data,-1); | 66 | return mempool_create_node(min_nr,alloc_fn,free_fn, pool_data, |
67 | GFP_KERNEL, NUMA_NO_NODE); | ||
67 | } | 68 | } |
68 | EXPORT_SYMBOL(mempool_create); | 69 | EXPORT_SYMBOL(mempool_create); |
69 | 70 | ||
70 | mempool_t *mempool_create_node(int min_nr, mempool_alloc_t *alloc_fn, | 71 | mempool_t *mempool_create_node(int min_nr, mempool_alloc_t *alloc_fn, |
71 | mempool_free_t *free_fn, void *pool_data, int node_id) | 72 | mempool_free_t *free_fn, void *pool_data, |
73 | gfp_t gfp_mask, int node_id) | ||
72 | { | 74 | { |
73 | mempool_t *pool; | 75 | mempool_t *pool; |
74 | pool = kmalloc_node(sizeof(*pool), GFP_KERNEL | __GFP_ZERO, node_id); | 76 | pool = kmalloc_node(sizeof(*pool), gfp_mask | __GFP_ZERO, node_id); |
75 | if (!pool) | 77 | if (!pool) |
76 | return NULL; | 78 | return NULL; |
77 | pool->elements = kmalloc_node(min_nr * sizeof(void *), | 79 | pool->elements = kmalloc_node(min_nr * sizeof(void *), |
78 | GFP_KERNEL, node_id); | 80 | gfp_mask, node_id); |
79 | if (!pool->elements) { | 81 | if (!pool->elements) { |
80 | kfree(pool); | 82 | kfree(pool); |
81 | return NULL; | 83 | return NULL; |
@@ -93,7 +95,7 @@ mempool_t *mempool_create_node(int min_nr, mempool_alloc_t *alloc_fn, | |||
93 | while (pool->curr_nr < pool->min_nr) { | 95 | while (pool->curr_nr < pool->min_nr) { |
94 | void *element; | 96 | void *element; |
95 | 97 | ||
96 | element = pool->alloc(GFP_KERNEL, pool->pool_data); | 98 | element = pool->alloc(gfp_mask, pool->pool_data); |
97 | if (unlikely(!element)) { | 99 | if (unlikely(!element)) { |
98 | mempool_destroy(pool); | 100 | mempool_destroy(pool); |
99 | return NULL; | 101 | return NULL; |