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


Groups > linux.kernel > #1514799 > unrolled thread

[PATCH 3/5] block: move poll code to blk-mq

Started byJens Axboe <axboe@fb.com>
First post2016-11-03 20:50 +0100
Last post2016-11-04 15:50 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 3/5] block: move poll code to blk-mq Jens Axboe <axboe@fb.com> - 2016-11-03 20:50 +0100
    Re: [PATCH 3/5] block: move poll code to blk-mq Christoph Hellwig <hch@lst.de> - 2016-11-04 15:50 +0100

#1514799 — [PATCH 3/5] block: move poll code to blk-mq

FromJens Axboe <axboe@fb.com>
Date2016-11-03 20:50 +0100
Subject[PATCH 3/5] block: move poll code to blk-mq
Message-ID<szwbn-8dS-15@gated-at.bofh.it>
The poll code is blk-mq specific, let's move it to blk-mq.c. This
is a prep patch for improving the polling code.

Signed-off-by: Jens Axboe <axboe@fb.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-core.c | 36 +++++-------------------------------
 block/blk-mq.c   | 33 +++++++++++++++++++++++++++++++++
 block/blk-mq.h   |  2 ++
 3 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 9dc7e9314d4c..e500d4b0e3fd 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -3299,47 +3299,21 @@ EXPORT_SYMBOL(blk_finish_plug);
 
 bool blk_poll(struct request_queue *q, blk_qc_t cookie)
 {
-	struct blk_plug *plug;
-	long state;
-	unsigned int queue_num;
 	struct blk_mq_hw_ctx *hctx;
+	struct blk_plug *plug;
+	struct request *rq;
 
 	if (!q->mq_ops || !q->mq_ops->poll || !blk_qc_t_valid(cookie) ||
 	    !test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
 		return false;
 
-	queue_num = blk_qc_t_to_queue_num(cookie);
-	hctx = q->queue_hw_ctx[queue_num];
-	hctx->poll_considered++;
-
 	plug = current->plug;
 	if (plug)
 		blk_flush_plug_list(plug, false);
 
-	state = current->state;
-	while (!need_resched()) {
-		int ret;
-
-		hctx->poll_invoked++;
-
-		ret = q->mq_ops->poll(hctx, blk_qc_t_to_tag(cookie));
-		if (ret > 0) {
-			hctx->poll_success++;
-			set_current_state(TASK_RUNNING);
-			return true;
-		}
-
-		if (signal_pending_state(state, current))
-			set_current_state(TASK_RUNNING);
-
-		if (current->state == TASK_RUNNING)
-			return true;
-		if (ret < 0)
-			break;
-		cpu_relax();
-	}
-
-	return false;
+	hctx = q->queue_hw_ctx[blk_qc_t_to_queue_num(cookie)];
+	rq = blk_mq_tag_to_rq(hctx->tags, blk_qc_t_to_tag(cookie));
+	return blk_mq_poll(hctx, rq);
 }
 EXPORT_SYMBOL_GPL(blk_poll);
 
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 476b18e1991c..4883c2d97ea9 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2357,6 +2357,39 @@ void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues)
 }
 EXPORT_SYMBOL_GPL(blk_mq_update_nr_hw_queues);
 
+bool blk_mq_poll(struct blk_mq_hw_ctx *hctx, struct request *rq)
+{
+	struct request_queue *q = hctx->queue;
+	long state;
+
+	hctx->poll_considered++;
+
+	state = current->state;
+	while (!need_resched()) {
+		int ret;
+
+		hctx->poll_invoked++;
+
+		ret = q->mq_ops->poll(hctx, rq->tag);
+		if (ret > 0) {
+			hctx->poll_success++;
+			set_current_state(TASK_RUNNING);
+			return true;
+		}
+
+		if (signal_pending_state(state, current))
+			set_current_state(TASK_RUNNING);
+
+		if (current->state == TASK_RUNNING)
+			return true;
+		if (ret < 0)
+			break;
+		cpu_relax();
+	}
+
+	return false;
+}
+
 void blk_mq_disable_hotplug(void)
 {
 	mutex_lock(&all_q_mutex);
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 8cf16cb69f64..79ea86e0ed49 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -61,6 +61,8 @@ extern void blk_mq_rq_timed_out(struct request *req, bool reserved);
 
 void blk_mq_release(struct request_queue *q);
 
+extern bool blk_mq_poll(struct blk_mq_hw_ctx *, struct request *);
+
 static inline struct blk_mq_ctx *__blk_mq_get_ctx(struct request_queue *q,
 					   unsigned int cpu)
 {
-- 
2.7.4

[toc] | [next] | [standalone]


#1515227

FromChristoph Hellwig <hch@lst.de>
Date2016-11-04 15:50 +0100
Message-ID<szNYC-342-33@gated-at.bofh.it>
In reply to#1514799
On Thu, Nov 03, 2016 at 01:45:05PM -0600, Jens Axboe wrote:
> The poll code is blk-mq specific, let's move it to blk-mq.c. This
> is a prep patch for improving the polling code.
> 
> Signed-off-by: Jens Axboe <axboe@fb.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>

So I gave my ok earlier, but I spent some more time looking at this
this morning and now I wonder why we even bother to keep some
code in blk-core.c.  How about just renaming the whole damn thing
to blk_mq_poll and move it to blk-mq.c instead of that split?

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web