* [patch resend 1/3] block: allocate request memory local to request queue
@ 2015-03-24 23:21 David Rientjes
2015-03-24 23:22 ` [patch resend 2/3] block, drbd: fix drbd_req_new() initialization David Rientjes
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: David Rientjes @ 2015-03-24 23:21 UTC (permalink / raw)
To: Andrew Morton, Jens Axboe
Cc: Tejun Heo, Lars Ellenberg, drbd-user, linux-kernel
blk_init_rl() allocates a mempool using mempool_create_node() with node
local memory. This only allocates the mempool and element list locally
to the requeue queue node.
What we really want to do is allocate the request itself local to the
queue. To do this, we need our own alloc and free functions that will
allocate from request_cachep and pass the request queue node in to prefer
node local memory.
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: David Rientjes <rientjes@google.com>
---
block/blk-core.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -557,6 +557,18 @@ void blk_cleanup_queue(struct request_queue *q)
}
EXPORT_SYMBOL(blk_cleanup_queue);
+/* Allocate memory local to the request queue */
+static void *alloc_request_struct(gfp_t gfp_mask, void *data)
+{
+ int nid = (int)(long)data;
+ return kmem_cache_alloc_node(request_cachep, gfp_mask, nid);
+}
+
+static void free_request_struct(void *element, void *unused)
+{
+ kmem_cache_free(request_cachep, element);
+}
+
int blk_init_rl(struct request_list *rl, struct request_queue *q,
gfp_t gfp_mask)
{
@@ -569,9 +581,10 @@ int blk_init_rl(struct request_list *rl, struct request_queue *q,
init_waitqueue_head(&rl->wait[BLK_RW_SYNC]);
init_waitqueue_head(&rl->wait[BLK_RW_ASYNC]);
- rl->rq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab,
- mempool_free_slab, request_cachep,
- gfp_mask, q->node);
+ rl->rq_pool = mempool_create_node(BLKDEV_MIN_RQ, alloc_request_struct,
+ free_request_struct,
+ (void *)(long)q->node, gfp_mask,
+ q->node);
if (!rl->rq_pool)
return -ENOMEM;
^ permalink raw reply [flat|nested] 5+ messages in thread
* [patch resend 2/3] block, drbd: fix drbd_req_new() initialization
2015-03-24 23:21 [patch resend 1/3] block: allocate request memory local to request queue David Rientjes
@ 2015-03-24 23:22 ` David Rientjes
2015-03-25 2:01 ` Jens Axboe
2015-03-24 23:22 ` [patch resend 3/3] block, drbd: use mempool_create_slab_pool() David Rientjes
2015-03-25 2:01 ` [patch resend 1/3] block: allocate request memory local to request queue Jens Axboe
2 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2015-03-24 23:22 UTC (permalink / raw)
To: Andrew Morton, Jens Axboe
Cc: Tejun Heo, Lars Ellenberg, drbd-user, linux-kernel
mempool_alloc() does not support __GFP_ZERO since elements may come from
memory that has already been released by mempool_free().
Remove __GFP_ZERO from mempool_alloc() in drbd_req_new() and properly
initialize it to 0.
Cc: Lars Ellenberg <drbd-dev@lists.linbit.com>
Cc: Jens Axboe <axboe@fb.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
drivers/block/drbd/drbd_req.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -52,9 +52,10 @@ static struct drbd_request *drbd_req_new(struct drbd_device *device,
{
struct drbd_request *req;
- req = mempool_alloc(drbd_request_mempool, GFP_NOIO | __GFP_ZERO);
+ req = mempool_alloc(drbd_request_mempool, GFP_NOIO);
if (!req)
return NULL;
+ memset(req, 0, sizeof(*req));
drbd_req_make_private_bio(req, bio_src);
req->rq_state = bio_data_dir(bio_src) == WRITE ? RQ_WRITE : 0;
^ permalink raw reply [flat|nested] 5+ messages in thread
* [patch resend 3/3] block, drbd: use mempool_create_slab_pool()
2015-03-24 23:21 [patch resend 1/3] block: allocate request memory local to request queue David Rientjes
2015-03-24 23:22 ` [patch resend 2/3] block, drbd: fix drbd_req_new() initialization David Rientjes
@ 2015-03-24 23:22 ` David Rientjes
2015-03-25 2:01 ` [patch resend 1/3] block: allocate request memory local to request queue Jens Axboe
2 siblings, 0 replies; 5+ messages in thread
From: David Rientjes @ 2015-03-24 23:22 UTC (permalink / raw)
To: Andrew Morton, Jens Axboe
Cc: Tejun Heo, Lars Ellenberg, drbd-user, linux-kernel
Mempools created for slab caches should use
mempool_create_slab_pool().
Cc: Lars Ellenberg <drbd-dev@lists.linbit.com>
Cc: Jens Axboe <axboe@fb.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
drivers/block/drbd/drbd_main.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -2107,13 +2107,12 @@ static int drbd_create_mempools(void)
if (drbd_md_io_page_pool == NULL)
goto Enomem;
- drbd_request_mempool = mempool_create(number,
- mempool_alloc_slab, mempool_free_slab, drbd_request_cache);
+ drbd_request_mempool = mempool_create_slab_pool(number,
+ drbd_request_cache);
if (drbd_request_mempool == NULL)
goto Enomem;
- drbd_ee_mempool = mempool_create(number,
- mempool_alloc_slab, mempool_free_slab, drbd_ee_cache);
+ drbd_ee_mempool = mempool_create_slab_pool(number, drbd_ee_cache);
if (drbd_ee_mempool == NULL)
goto Enomem;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch resend 1/3] block: allocate request memory local to request queue
2015-03-24 23:21 [patch resend 1/3] block: allocate request memory local to request queue David Rientjes
2015-03-24 23:22 ` [patch resend 2/3] block, drbd: fix drbd_req_new() initialization David Rientjes
2015-03-24 23:22 ` [patch resend 3/3] block, drbd: use mempool_create_slab_pool() David Rientjes
@ 2015-03-25 2:01 ` Jens Axboe
2 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2015-03-25 2:01 UTC (permalink / raw)
To: David Rientjes, Andrew Morton
Cc: Tejun Heo, Lars Ellenberg, drbd-user, linux-kernel
On 03/24/2015 05:21 PM, David Rientjes wrote:
> blk_init_rl() allocates a mempool using mempool_create_node() with node
> local memory. This only allocates the mempool and element list locally
> to the requeue queue node.
>
> What we really want to do is allocate the request itself local to the
> queue. To do this, we need our own alloc and free functions that will
> allocate from request_cachep and pass the request queue node in to prefer
> node local memory.
Applied to for-4.1/core, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch resend 2/3] block, drbd: fix drbd_req_new() initialization
2015-03-24 23:22 ` [patch resend 2/3] block, drbd: fix drbd_req_new() initialization David Rientjes
@ 2015-03-25 2:01 ` Jens Axboe
0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2015-03-25 2:01 UTC (permalink / raw)
To: David Rientjes, Andrew Morton
Cc: Tejun Heo, Lars Ellenberg, drbd-user, linux-kernel
On 03/24/2015 05:22 PM, David Rientjes wrote:
> mempool_alloc() does not support __GFP_ZERO since elements may come from
> memory that has already been released by mempool_free().
>
> Remove __GFP_ZERO from mempool_alloc() in drbd_req_new() and properly
> initialize it to 0.
This (and the other drbd patch) queued up in for-4.1/drivers, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-03-25 2:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-24 23:21 [patch resend 1/3] block: allocate request memory local to request queue David Rientjes
2015-03-24 23:22 ` [patch resend 2/3] block, drbd: fix drbd_req_new() initialization David Rientjes
2015-03-25 2:01 ` Jens Axboe
2015-03-24 23:22 ` [patch resend 3/3] block, drbd: use mempool_create_slab_pool() David Rientjes
2015-03-25 2:01 ` [patch resend 1/3] block: allocate request memory local to request queue Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox