linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] blk-mq: prefer local cpu on allocating request
@ 2020-01-02 14:01 Hillf Danton
  0 siblings, 0 replies; only message in thread
From: Hillf Danton @ 2020-01-02 14:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jens Axboe, Ming Lin, Christoph Hellwig, Keith Busch, linux-mm,
	Hillf Danton


Use local cpu in order to avoid the risk of overloading the first mapped
one if completing requests has to be on the cpu where requests are
dispatched.

Signed-off-by: Hillf Danton <hdanton@sina.com>
---

--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -426,7 +426,6 @@ struct request *blk_mq_alloc_request_hct
 {
 	struct blk_mq_alloc_data alloc_data = { .flags = flags, .cmd_flags = op };
 	struct request *rq;
-	unsigned int cpu;
 	int ret;
 
 	/*
@@ -454,8 +453,14 @@ struct request *blk_mq_alloc_request_hct
 		blk_queue_exit(q);
 		return ERR_PTR(-EXDEV);
 	}
-	cpu = cpumask_first_and(alloc_data.hctx->cpumask, cpu_online_mask);
-	alloc_data.ctx = __blk_mq_get_ctx(q, cpu);
+
+	/* prefer local cpu if it's mapped to hw queue */
+	if (!cpumask_test_cpu(raw_smp_processor_id(), alloc_data.hctx->cpumask)) {
+		unsigned int cpu;
+		cpu = cpumask_first_and(alloc_data.hctx->cpumask, cpu_online_mask);
+		if (cpu < nr_cpu_ids)
+			alloc_data.ctx = __blk_mq_get_ctx(q, cpu);
+	}
 
 	rq = blk_mq_get_request(q, NULL, &alloc_data);
 	blk_queue_exit(q);



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-01-02 14:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-02 14:01 [RFC PATCH] blk-mq: prefer local cpu on allocating request Hillf Danton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).