mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] block: allocate request memory local to request queue
@ 2015-03-08  2:53 David Rientjes
  2015-03-08  3:01 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: David Rientjes @ 2015-03-08  2:53 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Tejun Heo, 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.

Cc: 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] 2+ messages in thread

* Re: [patch] block: allocate request memory local to request queue
  2015-03-08  2:53 [patch] block: allocate request memory local to request queue David Rientjes
@ 2015-03-08  3:01 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2015-03-08  3:01 UTC (permalink / raw)
  To: David Rientjes; +Cc: Jens Axboe, linux-kernel

On Sat, Mar 07, 2015 at 06:53:46PM -0800, 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.
> 
> Cc: Tejun Heo <tj@kernel.org>
> Signed-off-by: David Rientjes <rientjes@google.com>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-08  3:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-08  2:53 [patch] block: allocate request memory local to request queue David Rientjes
2015-03-08  3:01 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®