From patchwork Wed May 22 17:48:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10956411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50EFE112C for ; Wed, 22 May 2019 17:53:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4031728C71 for ; Wed, 22 May 2019 17:53:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E39D28C9E; Wed, 22 May 2019 17:53:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBFA428C71 for ; Wed, 22 May 2019 17:53:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728674AbfEVRxR (ORCPT ); Wed, 22 May 2019 13:53:17 -0400 Received: from mga07.intel.com ([134.134.136.100]:57850 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728533AbfEVRxQ (ORCPT ); Wed, 22 May 2019 13:53:16 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 May 2019 10:53:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,500,1549958400"; d="scan'208";a="174471731" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga002.fm.intel.com with ESMTP; 22 May 2019 10:53:15 -0700 From: Keith Busch To: Jens Axboe , Christoph Hellwig , linux-nvme@lists.infradead.org, linux-block@vger.kernel.org Cc: Ming Lei , Keith Busch Subject: [PATCH 1/2] blk-mq: provide way to reset rq deadline Date: Wed, 22 May 2019 11:48:11 -0600 Message-Id: <20190522174812.5597-2-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190522174812.5597-1-keith.busch@intel.com> References: <20190522174812.5597-1-keith.busch@intel.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If hardware has temporarily paused processing requests that its driver has dispatched, the driver may need to halt timeout detection during that temporary stoppage. When the hardware has un-paused request processing, the driver needs a way to rebase all dispatched request dealines using current jiffies so that time accrued during the paused state doesn't count against that request. Signed-off-by: Keith Busch --- block/blk-mq.c | 30 ++++++++++++++++++++++++++++++ include/linux/blk-mq.h | 1 + 2 files changed, 31 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index 08a6248d8536..9d85903d4e0c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -960,6 +960,36 @@ static void blk_mq_timeout_work(struct work_struct *work) blk_queue_exit(q); } +static bool blk_mq_reset_rq(struct blk_mq_hw_ctx *hctx, struct request *rq, + void *priv, bool reserved) +{ + if (blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT) + blk_add_timer(rq); + return true; +} + +/** + * blk_mq_reset_rqs - reset the timers on all inflight requests + * + * @q - request queue to iterate + * + * This is intended for use when a driver detects its hardware has temporarily + * paused processing commands. When the condition is initially detected, the + * driver should call blk_mq_quiesce_queue() to block new requests from + * dispatching, then blk_sync_queue() to halt any timeout work. When the + * hardware becomes operational again, the driver should call this function to + * reset previously dispatched request timers who's processing had been paused + * by the hardware, then call blk_mq_unquiesce_queue() to unblock future + * dispatch. + */ +void blk_mq_reset_rqs(struct request_queue *q) +{ + if (WARN_ON(!blk_queue_quiesced(q))) + return; + blk_mq_queue_tag_busy_iter(q, blk_mq_reset_rq, NULL); +} +EXPORT_SYMBOL_GPL(blk_mq_reset_rqs); + struct flush_busy_ctx_data { struct blk_mq_hw_ctx *hctx; struct list_head *list; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 15d1aa53d96c..28c421ba5094 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -327,6 +327,7 @@ void blk_freeze_queue_start(struct request_queue *q); void blk_mq_freeze_queue_wait(struct request_queue *q); int blk_mq_freeze_queue_wait_timeout(struct request_queue *q, unsigned long timeout); +void blk_mq_reset_rqs(struct request_queue *q); int blk_mq_map_queues(struct blk_mq_queue_map *qmap); void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues);