From patchwork Thu Sep 27 22:55:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10618719 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 6852E175A for ; Thu, 27 Sep 2018 22:56:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C52E2B54B for ; Thu, 27 Sep 2018 22:56:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5068C2B568; Thu, 27 Sep 2018 22:56:33 +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,DKIM_SIGNED, DKIM_VALID,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 DA47D2B561 for ; Thu, 27 Sep 2018 22:56:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726081AbeI1FRJ (ORCPT ); Fri, 28 Sep 2018 01:17:09 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34140 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725957AbeI1FRJ (ORCPT ); Fri, 28 Sep 2018 01:17:09 -0400 Received: by mail-pf1-f195.google.com with SMTP id k19-v6so2920283pfi.1 for ; Thu, 27 Sep 2018 15:56:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6RxSj5+6EBg3qzf9tC3pVGES1JNyglFu1U7aXTvybls=; b=ukKI58cgg11xsZTYODXlxn0OP0VgXKQLM8OVsUPdAEGcR89mZEvzLnN5uWC28gW7Xe FmWliDJf5SoujHSlhcov/Qi3e23h5MDloRxrmwwqjL1lrgcfV39Bh9FX+lQcYX6M2YIt Pkppe9gMudRGkX+tmrURmTBnbRqi8OXzBSipSsBfFGHamc+Ijt+wNKxz7rzUnOx/cFlg is9m5/Fw6l+n7pOS+jtN+nwxcZgyUwnRdH3NV4tREuofZmAzz0bxTFYIYi+MK6Fj5C4f EFg0Vk6ZSx05yDZg1fbeGNM3Cyzp6q6XUUkDpv3SjJ2NLOlvvuuJdvzdFGUnaR+HErpX s7Uw== 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:mime-version:content-transfer-encoding; bh=6RxSj5+6EBg3qzf9tC3pVGES1JNyglFu1U7aXTvybls=; b=UlNjI/Pomj2VZL5zr2Hd39LaLno32KEgZ9qZYzRrP2+y5kN59sprNDqE2dLRCbToD+ rPtpndlALhxM1eMgOaRsNVWyhL2ohoKmOtOIKOjIsuc+kMuZTLHtJu1cv7ZGJBE9rBh+ AJdUT+PjBLl8xGe9/alJp9e6Wiif6KQTn3SZK60AXdnO985MEOe4d1TWzRVDKUPyj74J 5okxwKJJGhWneQ5qWL1QWPZz6B72qm7t3PAr+Xa0OR+XfTkUIjvJNH6NTdeEX02LD4Su WJITfZ/LbyELV3xOr4jCQ4qGeJZAzsA1X7ltw2zL+MnSCUv/T0+ZiHn3PZ8ezPJ1uNw+ eRiQ== X-Gm-Message-State: ABuFfohDYwFgV9P7hlrsypePt63vEi8B1jV1KE9x5RkMbNuOsxMzbET1 kMOIw5MAvXNlb7N0+2mtoQpHBV0MFkc= X-Google-Smtp-Source: ACcGV623x4OqUs5gNNS4H2JxQEAWtbX4pp57J5+guNnPaFkw6kb2aOihpukYqD9cTV3W35mIrDmIzw== X-Received: by 2002:a63:4281:: with SMTP id p123-v6mr12105256pga.91.1538088991081; Thu, 27 Sep 2018 15:56:31 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::5:3e64]) by smtp.gmail.com with ESMTPSA id t1-v6sm3716721pgp.32.2018.09.27.15.56.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 15:56:30 -0700 (PDT) From: Omar Sandoval To: linux-block@vger.kernel.org Cc: Jens Axboe , kernel-team@fb.com Subject: [PATCH v2 1/5] block: move call of scheduler's ->completed_request() hook Date: Thu, 27 Sep 2018 15:55:51 -0700 Message-Id: <0af9e13d8c4e092f4b407f83c39421be1b90b7f1.1538088475.git.osandov@fb.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 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 From: Omar Sandoval Commit 4bc6339a583c ("block: move blk_stat_add() to __blk_mq_end_request()") consolidated some calls using ktime_get() so we'd only need to call it once. Kyber's ->completed_request() hook also calls ktime_get(), so let's move it to the same place, too. Signed-off-by: Omar Sandoval --- block/blk-mq-sched.h | 4 ++-- block/blk-mq.c | 5 +++-- block/kyber-iosched.c | 5 ++--- include/linux/elevator.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/block/blk-mq-sched.h b/block/blk-mq-sched.h index 4e028ee42430..8a9544203173 100644 --- a/block/blk-mq-sched.h +++ b/block/blk-mq-sched.h @@ -49,12 +49,12 @@ blk_mq_sched_allow_merge(struct request_queue *q, struct request *rq, return true; } -static inline void blk_mq_sched_completed_request(struct request *rq) +static inline void blk_mq_sched_completed_request(struct request *rq, u64 now) { struct elevator_queue *e = rq->q->elevator; if (e && e->type->ops.mq.completed_request) - e->type->ops.mq.completed_request(rq); + e->type->ops.mq.completed_request(rq, now); } static inline void blk_mq_sched_started_request(struct request *rq) diff --git a/block/blk-mq.c b/block/blk-mq.c index d384ab700afd..1e72d53e8f2d 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -528,6 +528,9 @@ inline void __blk_mq_end_request(struct request *rq, blk_status_t error) blk_stat_add(rq, now); } + if (rq->internal_tag != -1) + blk_mq_sched_completed_request(rq, now); + blk_account_io_done(rq, now); if (rq->end_io) { @@ -564,8 +567,6 @@ static void __blk_mq_complete_request(struct request *rq) if (!blk_mq_mark_complete(rq)) return; - if (rq->internal_tag != -1) - blk_mq_sched_completed_request(rq); if (!test_bit(QUEUE_FLAG_SAME_COMP, &rq->q->queue_flags)) { rq->q->softirq_done_fn(rq); diff --git a/block/kyber-iosched.c b/block/kyber-iosched.c index a1660bafc912..95d062c07c61 100644 --- a/block/kyber-iosched.c +++ b/block/kyber-iosched.c @@ -558,12 +558,12 @@ static void kyber_finish_request(struct request *rq) rq_clear_domain_token(kqd, rq); } -static void kyber_completed_request(struct request *rq) +static void kyber_completed_request(struct request *rq, u64 now) { struct request_queue *q = rq->q; struct kyber_queue_data *kqd = q->elevator->elevator_data; unsigned int sched_domain; - u64 now, latency, target; + u64 latency, target; /* * Check if this request met our latency goal. If not, quickly gather @@ -585,7 +585,6 @@ static void kyber_completed_request(struct request *rq) if (blk_stat_is_active(kqd->cb)) return; - now = ktime_get_ns(); if (now < rq->io_start_time_ns) return; diff --git a/include/linux/elevator.h b/include/linux/elevator.h index a02deea30185..015bb59c0331 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h @@ -111,7 +111,7 @@ struct elevator_mq_ops { void (*insert_requests)(struct blk_mq_hw_ctx *, struct list_head *, bool); struct request *(*dispatch_request)(struct blk_mq_hw_ctx *); bool (*has_work)(struct blk_mq_hw_ctx *); - void (*completed_request)(struct request *); + void (*completed_request)(struct request *, u64); void (*started_request)(struct request *); void (*requeue_request)(struct request *); struct request *(*former_request)(struct request_queue *, struct request *);