Skip to content

Commit

Permalink
block: allocate request memory local to request queue
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David Rientjes <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
rientjes authored and axboe committed Mar 25, 2015
1 parent bfd343a commit 271508d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;

Expand Down

0 comments on commit 271508d

Please sign in to comment.