From patchwork Tue Jul 10 19:15:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 10517965 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 D83FD600CA for ; Tue, 10 Jul 2018 19:15:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8BFB2920A for ; Tue, 10 Jul 2018 19:15:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCF9F29273; Tue, 10 Jul 2018 19:15:57 +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,UNPARSEABLE_RELAY 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 8EEC12920A for ; Tue, 10 Jul 2018 19:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732237AbeGJTQU (ORCPT ); Tue, 10 Jul 2018 15:16:20 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:38747 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732337AbeGJTQU (ORCPT ); Tue, 10 Jul 2018 15:16:20 -0400 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R191e4; CH=green; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01f04446; MF=bo.liu@linux.alibaba.com; NM=1; PH=DS; RN=1; SR=0; TI=SMTPD_---0T4Mojys_1531250143; Received: from localhost(mailfrom:bo.liu@linux.alibaba.com fp:SMTPD_---0T4Mojys_1531250143) by smtp.aliyun-inc.com(127.0.0.1); Wed, 11 Jul 2018 03:15:43 +0800 From: Liu Bo To: Subject: [PATCH] Block: blk-throttle: skip wait time calculation if not asked Date: Wed, 11 Jul 2018 03:15:29 +0800 Message-Id: <1531250129-18354-1-git-send-email-bo.liu@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 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 tg_may_dispatch() uses @wait to retrieve how long the next bio can be dispatched, but if it doesn't ask for that, it's OK for tg_with_in_{bps,iops}_limit() to return immediately. Signed-off-by: Liu Bo --- block/blk-throttle.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 423551f92b2c..c70aa396a793 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -954,6 +954,9 @@ static bool tg_with_in_iops_limit(struct throtl_grp *tg, struct bio *bio, return true; } + if (!wait) + return false; + /* Calc approx time to dispatch */ jiffy_wait = ((tg->io_disp[rw] + 1) * HZ) / tg_iops_limit(tg, rw) + 1; @@ -962,8 +965,7 @@ static bool tg_with_in_iops_limit(struct throtl_grp *tg, struct bio *bio, else jiffy_wait = 1; - if (wait) - *wait = jiffy_wait; + *wait = jiffy_wait; return false; } @@ -995,6 +997,9 @@ static bool tg_with_in_bps_limit(struct throtl_grp *tg, struct bio *bio, return true; } + if (!wait) + return false; + /* Calc approx time to dispatch */ extra_bytes = tg->bytes_disp[rw] + bio_size - bytes_allowed; jiffy_wait = div64_u64(extra_bytes * HZ, tg_bps_limit(tg, rw)); @@ -1007,8 +1012,7 @@ static bool tg_with_in_bps_limit(struct throtl_grp *tg, struct bio *bio, * up we did. Add that time also. */ jiffy_wait = jiffy_wait + (jiffy_elapsed_rnd - jiffy_elapsed); - if (wait) - *wait = jiffy_wait; + *wait = jiffy_wait; return false; }