From: Christoph Hellwig <hch@lst.de>
To: axboe@fb.com
Cc: hare@suse.de, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org
Subject: [PATCH, RFC] blk-mq: use a delayed work item for timeouts
Date: Mon, 12 Oct 2015 21:29:14 +0200 [thread overview]
Message-ID: <1444678154-24766-1-git-send-email-hch@lst.de> (raw)
For some pending NVMe work I'd really love to be able to get my timeouts
from process context. So far it seems only SCSI and NVMe use the blk-mq
timeout handler, and both don't seem to be particularly excited about
being called from time context. Does anyone have an objection against
the patch below that switches it to use a delayed work item? I could
make use of this quickly for NVMe, but for SCSI we still have to deal
with the old request code which can't be switched to a delayed work
as easily.
---
block/blk-mq.c | 11 ++++++-----
include/linux/blkdev.h | 5 ++++-
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index d921cd5..a7ae387 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -635,9 +635,10 @@ static void blk_mq_check_expired(struct blk_mq_hw_ctx *hctx,
}
}
-static void blk_mq_rq_timer(unsigned long priv)
+static void blk_mq_rq_timer_work(struct work_struct *work)
{
- struct request_queue *q = (struct request_queue *)priv;
+ struct request_queue *q =
+ container_of(work, struct request_queue, timeout_work.work);
struct blk_mq_timeout_data data = {
.next = 0,
.next_set = 0,
@@ -648,7 +649,7 @@ static void blk_mq_rq_timer(unsigned long priv)
if (data.next_set) {
data.next = blk_rq_timeout(round_jiffies_up(data.next));
- mod_timer(&q->timeout, data.next);
+ mod_delayed_work(system_wq, &q->timeout_work, data.next);
} else {
struct blk_mq_hw_ctx *hctx;
@@ -2008,7 +2009,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
PERCPU_REF_INIT_ATOMIC, GFP_KERNEL))
goto err_hctxs;
- setup_timer(&q->timeout, blk_mq_rq_timer, (unsigned long) q);
+ INIT_DELAYED_WORK(&q->timeout_work, blk_mq_rq_timer_work);
blk_queue_rq_timeout(q, set->timeout ? set->timeout : 30 * HZ);
q->nr_queues = nr_cpu_ids;
@@ -2173,7 +2174,7 @@ static int blk_mq_queue_reinit_notify(struct notifier_block *nb,
* timeout handler can't touch hw queue during the
* reinitialization
*/
- del_timer_sync(&q->timeout);
+ cancel_delayed_work_sync(&q->timeout_work);
}
list_for_each_entry(q, &all_q_list, all_q_node)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 19c2e94..ecce48f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -401,7 +401,10 @@ struct request_queue {
unsigned int request_fn_active;
unsigned int rq_timeout;
- struct timer_list timeout;
+ union {
+ struct timer_list timeout; /* legacy */
+ struct delayed_work timeout_work; /* blk-mq */
+ };
struct list_head timeout_list;
struct list_head icq_list;
--
1.9.1
next reply other threads:[~2015-10-12 19:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-12 19:29 Christoph Hellwig [this message]
2015-10-12 19:34 ` [PATCH, RFC] blk-mq: use a delayed work item for timeouts Jens Axboe
2015-10-12 20:08 ` Jens Axboe
2015-10-12 20:22 ` Christoph Hellwig
2015-10-12 20:26 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1444678154-24766-1-git-send-email-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@fb.com \
--cc=hare@suse.de \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox