Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1364850

[PATCH 1/3] blk-mq: add an API to estimate hardware queue node

From Shaohua Li <shli@fb.com>
Newsgroups linux.kernel
Subject [PATCH 1/3] blk-mq: add an API to estimate hardware queue node
Date 2016-03-25 22:40 +0100
Message-ID <rgHCy-7Rl-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


we allocate most data structure in device's node, but some data
structures are not for DMA and mostly used by specific cpus/node which
could diff from device's node. Allocating such hot data in device's
node doesn't make sense. Add an API to estimate hardware queue node.
This can be used before blk-mq actually establishes the mapping. This
API runs slow, but it only used in initialization time.

Signed-off-by: Shaohua Li <shli@fb.com>
---
 block/blk-mq.c         | 21 +++++++++++++++++++++
 include/linux/blk-mq.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 050f7a1..ec214d3 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2330,6 +2330,27 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)
 }
 EXPORT_SYMBOL(blk_mq_free_tag_set);
 
+int blk_mq_estimate_hw_queue_node(unsigned int total_queues,
+	unsigned int index)
+{
+	unsigned int *map;
+	int node;
+
+	if (total_queues == 1)
+		return NUMA_NO_NODE;
+	map = kzalloc(sizeof(*map) * nr_cpu_ids, GFP_KERNEL);
+	if (!map)
+		return NUMA_NO_NODE;
+	if (blk_mq_update_queue_map(map, total_queues, cpu_online_mask)) {
+		kfree(map);
+		return NUMA_NO_NODE;
+	}
+	node = blk_mq_hw_queue_to_node(map, index);
+	kfree(map);
+	return node;
+}
+EXPORT_SYMBOL(blk_mq_estimate_hw_queue_node);
+
 int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)
 {
 	struct blk_mq_tag_set *set = q->tag_set;
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 15a73d4..892b41b 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -188,6 +188,8 @@ void blk_mq_insert_request(struct request *, bool, bool, bool);
 void blk_mq_free_request(struct request *rq);
 void blk_mq_free_hctx_request(struct blk_mq_hw_ctx *, struct request *rq);
 bool blk_mq_can_queue(struct blk_mq_hw_ctx *);
+int blk_mq_estimate_hw_queue_node(unsigned int total_queues,
+	unsigned int index);
 
 enum {
 	BLK_MQ_REQ_NOWAIT	= (1 << 0), /* return when out of requests */
-- 
2.8.0.rc2

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] blk-mq: add an API to estimate hardware queue node Shaohua Li <shli@fb.com> - 2016-03-25 22:40 +0100
  Re: [PATCH 1/3] blk-mq: add an API to estimate hardware queue node Christoph Hellwig <hch@infradead.org> - 2016-03-29 09:30 +0200
    Re: [PATCH 1/3] blk-mq: add an API to estimate hardware queue node Shaohua Li <shli@fb.com> - 2016-03-29 18:50 +0200
      Re: [PATCH 1/3] blk-mq: add an API to estimate hardware queue node Jens Axboe <axboe@fb.com> - 2016-03-29 19:00 +0200
        Re: [PATCH 1/3] blk-mq: add an API to estimate hardware queue node Christoph Hellwig <hch@infradead.org> - 2016-03-29 19:50 +0200
          Re: [PATCH 1/3] blk-mq: add an API to estimate hardware queue node Jens Axboe <axboe@fb.com> - 2016-03-29 23:00 +0200
            Re: [PATCH 1/3] blk-mq: add an API to estimate hardware queue node Christoph Hellwig <hch@infradead.org> - 2016-03-29 23:30 +0200
              Re: [PATCH 1/3] blk-mq: add an API to estimate hardware queue node Jens Axboe <axboe@fb.com> - 2016-03-29 23:30 +0200

csiph-web