From patchwork Tue Jan 9 18:27:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10153005 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7C2FA603ED for ; Tue, 9 Jan 2018 18:27:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7840028615 for ; Tue, 9 Jan 2018 18:27:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CCE52861D; Tue, 9 Jan 2018 18:27:11 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 018D428615 for ; Tue, 9 Jan 2018 18:27:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753520AbeAIS1K (ORCPT ); Tue, 9 Jan 2018 13:27:10 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:43357 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751996AbeAIS1J (ORCPT ); Tue, 9 Jan 2018 13:27:09 -0500 Received: by mail-it0-f65.google.com with SMTP id u62so12708127ita.2 for ; Tue, 09 Jan 2018 10:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/2iN42rueRaZoe+ZL3qhSwF2BmxwffJVjyyRe5oOEsM=; b=O4R+0EtI7dKrh3VMNE+PSSOUslcQilJowy7UNzNmQIzVGBsak2K9FrbEQobNmg9/an cPH0NKCuLzXquNIstWAt344OE3pZ6uLuLNqPTu3xhIN93eAiI5IFxb9b9euiaic4gsQW 1B3vfSJyXB+RTDlL7VxSG8EU6gaL34j8fKvDgZvpNgZYovKr3Q/7SucTA6yA5nDBQG4/ euDr1brZev0Ie84XcXxPAeL9N9lVm/TCBe7GZF5e2l8GDvgUG3duA4tCecAxxqX1owuB MAVX/wnjX2zo14O7zr9Nb3F0XmytlpMH6BNEqGJ5coB89qsl2sOm2LD6OljCmlgzKmBV hpIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/2iN42rueRaZoe+ZL3qhSwF2BmxwffJVjyyRe5oOEsM=; b=Yx3kBXYPEvgzbKUsVAAcUe6VovC94xXYLqR2tgnIc2pX3myEMAHmRCalh/ZSPkXTLc JoPppaq4YMXMsudCv9K7re3IscXNcLndaPNtXxvk1RQ9eTAsy/ol6Qa0dRJ2luF1s61/ IbYVb9v8oz263S1PljJ6yEysvN0BBaPVxIhpdo3CmU1rXMzWnYSge2kW5Y6Om6O9y8zK 3/dh5kn8pLcBpgbZNi4hNzdm/wphjb5zcpc88QNqQ7hofHOeQfQyCme01jXypW3yUl8Y WKIaZSgA1md58EqySwykjLop3TxfVVE+KYEDnupRJyIsiNF5c165BOFYLAEiwcSm4kw+ T5UA== X-Gm-Message-State: AKGB3mJrrx0J0RdBRLE9zK5VCbQsNmXrqPWkMhNpizIkwJFBhYm4+TN7 tdJXvxya+4OUfIJ2c61XNdF4clQaCS8= X-Google-Smtp-Source: ACJfBovyHpRvJi8zQay+9EoPtQn1bdCbQMxX105kzvRrV5xUjXn58Scm2IyLY1Fr7Eas1B7MT/fxZg== X-Received: by 10.36.47.210 with SMTP id j201mr15503510itj.116.1515522428820; Tue, 09 Jan 2018 10:27:08 -0800 (PST) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id 202sm8885084ioz.84.2018.01.09.10.27.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jan 2018 10:27:08 -0800 (PST) From: Jens Axboe To: linux-block@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 2/4] block: add accessors for setting/querying request deadline Date: Tue, 9 Jan 2018 11:27:00 -0700 Message-Id: <1515522422-21596-3-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515522422-21596-1-git-send-email-axboe@kernel.dk> References: <1515522422-21596-1-git-send-email-axboe@kernel.dk> 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 We reduce the resolution of request expiry, but since we're already using jiffies for this where resolution depends on the kernel configuration and since the timeout resolution is coarse anyway, that should be fine. Signed-off-by: Jens Axboe --- block/blk-mq.c | 2 +- block/blk-timeout.c | 14 ++++++++------ block/blk.h | 13 +++++++++++++ include/linux/blkdev.h | 4 +++- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index faa31814983c..d875c51bcff8 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -858,7 +858,7 @@ static void blk_mq_check_expired(struct blk_mq_hw_ctx *hctx, while (true) { start = read_seqcount_begin(&rq->gstate_seq); gstate = READ_ONCE(rq->gstate); - deadline = rq->deadline; + deadline = blk_rq_deadline(rq); if (!read_seqcount_retry(&rq->gstate_seq, start)) break; cond_resched(); diff --git a/block/blk-timeout.c b/block/blk-timeout.c index ebe99963386c..a05e3676d24a 100644 --- a/block/blk-timeout.c +++ b/block/blk-timeout.c @@ -112,7 +112,9 @@ static void blk_rq_timed_out(struct request *req) static void blk_rq_check_expired(struct request *rq, unsigned long *next_timeout, unsigned int *next_set) { - if (time_after_eq(jiffies, rq->deadline)) { + const unsigned long deadline = blk_rq_deadline(rq); + + if (time_after_eq(jiffies, deadline)) { list_del_init(&rq->timeout_list); /* @@ -120,8 +122,8 @@ static void blk_rq_check_expired(struct request *rq, unsigned long *next_timeout */ if (!blk_mark_rq_complete(rq)) blk_rq_timed_out(rq); - } else if (!*next_set || time_after(*next_timeout, rq->deadline)) { - *next_timeout = rq->deadline; + } else if (!*next_set || time_after(*next_timeout, deadline)) { + *next_timeout = deadline; *next_set = 1; } } @@ -162,7 +164,7 @@ void blk_abort_request(struct request *req) * immediately and that scan sees the new timeout value. * No need for fancy synchronizations. */ - req->deadline = jiffies; + blk_rq_set_deadline(req, jiffies); mod_timer(&req->q->timeout, 0); } else { if (blk_mark_rq_complete(req)) @@ -213,7 +215,7 @@ void blk_add_timer(struct request *req) if (!req->timeout) req->timeout = q->rq_timeout; - req->deadline = jiffies + req->timeout; + blk_rq_set_deadline(req, jiffies + req->timeout); req->rq_flags &= ~RQF_MQ_TIMEOUT_EXPIRED; /* @@ -228,7 +230,7 @@ void blk_add_timer(struct request *req) * than an existing one, modify the timer. Round up to next nearest * second. */ - expiry = blk_rq_timeout(round_jiffies_up(req->deadline)); + expiry = blk_rq_timeout(round_jiffies_up(blk_rq_deadline(req))); if (!timer_pending(&q->timeout) || time_before(expiry, q->timeout.expires)) { diff --git a/block/blk.h b/block/blk.h index eb306c52121e..8b26a8872e05 100644 --- a/block/blk.h +++ b/block/blk.h @@ -237,6 +237,19 @@ static inline void req_set_nomerge(struct request_queue *q, struct request *req) } /* + * Steal a bit from this field for legacy IO path atomic IO marking + */ +static inline void blk_rq_set_deadline(struct request *rq, unsigned long time) +{ + rq->__deadline = time & ~0x1; +} + +static inline unsigned long blk_rq_deadline(struct request *rq) +{ + return rq->__deadline & ~0x1; +} + +/* * Internal io_context interface */ void get_io_context(struct io_context *ioc); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index ba31674d8581..aa6698cf483c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -257,7 +257,9 @@ struct request { struct u64_stats_sync aborted_gstate_sync; u64 aborted_gstate; - unsigned long deadline; + /* access through blk_rq_set_deadline, blk_rq_deadline */ + unsigned long __deadline; + struct list_head timeout_list; /*