From patchwork Thu Aug 16 16:51:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10567879 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 4C3DB913 for ; Thu, 16 Aug 2018 16:52:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C4D22B47F for ; Thu, 16 Aug 2018 16:52:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30BFC2B4A8; Thu, 16 Aug 2018 16:52: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 D064F2B47F for ; Thu, 16 Aug 2018 16:52:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725895AbeHPTwJ (ORCPT ); Thu, 16 Aug 2018 15:52:09 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:32925 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727590AbeHPTvg (ORCPT ); Thu, 16 Aug 2018 15:51:36 -0400 Received: by mail-wm0-f68.google.com with SMTP id i134-v6so8769017wmf.0 for ; Thu, 16 Aug 2018 09:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gLZ7QU55IsLVhhisN3q0YJquTs5gtaPrOh82kVhuIcI=; b=Q9pA60BvtGVg5Qk9BZEC9RPwv6VE30CQG96npMXKKLFK687sa2wy5rmGfhusSXFe1y 6P4pAvKNB9K5o0+W9hW8qcfmjyx7QitMS0xwesCJ0X1vc960UZV3Rv2aPGzYPumCJQCc e9DKMRLroOeAn7gPZuXSrQ666mIhWcaGixrxk= 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=gLZ7QU55IsLVhhisN3q0YJquTs5gtaPrOh82kVhuIcI=; b=ly8XXa8TUiP3tYzHFPlnz0HoGNdljN6IUGsdb1QklmtEiUqlTG+Wsm97VM/FqPerAz IUWzj9Gc75O2+3xfpo/AlrD0HPtFBRv7H2dSFl0qRvp0IWqPCQEarVNtZKZICQTWS/A4 RZ/cylzOJc8ii7FyTS4bynnG+aX7FsUemU6hLAl53xc7a8HgmOXhzLWPf11ZrX5xB7Fm 1tws0UvhG8T3knKdnbq/Cl8kyOP/G3/FTO4/+CQng3D13IXZQKmqFMMQdm7unuoyln0m hqEkO2u0C/l6aZkiWXuLNojCH1jWaq0d8OODFhl7o/pzzjfKWNwVOmrk8kA1W3w3JKbz T5sA== X-Gm-Message-State: AOUpUlGHDzGgmojbqzIifHt7WFnohTKUEjb+66V7u7gssnmcTRE/0bGX eC3F7T3HozlKykV1o5frmHoMcA== X-Google-Smtp-Source: AA+uWPyQc/QmVFufHKF653DtcznVIl+PWJw7XwfaujV607gnewQr09bbFnhCJOQ9rPBbffEGh0fXsA== X-Received: by 2002:a1c:bb86:: with SMTP id l128-v6mr16316007wmf.26.1534438317067; Thu, 16 Aug 2018 09:51:57 -0700 (PDT) Received: from localhost.localdomain (146-241-5-103.dyn.eolo.it. [146.241.5.103]) by smtp.gmail.com with ESMTPSA id o3-v6sm30036180wrj.31.2018.08.16.09.51.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 09:51:56 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, Paolo Valente Subject: [PATCH BUGFIX/IMPROVEMENT 1/4] block, bfq: readd missing reset of parent-entity service Date: Thu, 16 Aug 2018 18:51:15 +0200 Message-Id: <20180816165118.17402-2-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180816165118.17402-1-paolo.valente@linaro.org> References: <20180816165118.17402-1-paolo.valente@linaro.org> 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 The received-service counter needs to be equal to 0 when an entity is set in service. Unfortunately, commit "block, bfq: fix service being wrongly set to zero in case of preemption" mistakenly removed the resetting of this counter for the parent entities of the bfq_queue being set in service. This commit fixes this issue by resetting service for parent entities, directly on the expiration of the in-service bfq_queue. Fixes: 9fae8dd59ff3 ("block, bfq: fix service being wrongly set to zero in case of preemption") Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 41d9036b1822..62efc1b97afb 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -3298,6 +3298,27 @@ void bfq_bfqq_expire(struct bfq_data *bfqd, */ } else entity->service = 0; + + /* + * Reset the received-service counter for every parent entity. + * Differently from what happens with bfqq->entity.service, + * the resetting of this counter never needs to be postponed + * for parent entities. In fact, in case bfqq may have a + * chance to go on being served using the last, partially + * consumed budget, bfqq->entity.service needs to be kept, + * because if bfqq then actually goes on being served using + * the same budget, the last value of bfqq->entity.service is + * needed to properly decrement bfqq->entity.budget by the + * portion already consumed. In contrast, it is not necessary + * to keep entity->service for parent entities too, because + * the bubble up of the new value of bfqq->entity.budget will + * make sure that the budgets of parent entities are correct, + * even in case bfqq and thus parent entities go on receiving + * service with the same budget. + */ + entity = entity->parent; + for_each_entity(entity) + entity->service = 0; } /* From patchwork Thu Aug 16 16:51:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10567877 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 6BE8D139A for ; Thu, 16 Aug 2018 16:52:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59DAF2B47F for ; Thu, 16 Aug 2018 16:52:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E3622B4A8; Thu, 16 Aug 2018 16:52:31 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 EEFB82B47F for ; Thu, 16 Aug 2018 16:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725762AbeHPTwG (ORCPT ); Thu, 16 Aug 2018 15:52:06 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35606 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730216AbeHPTvh (ORCPT ); Thu, 16 Aug 2018 15:51:37 -0400 Received: by mail-wr1-f67.google.com with SMTP id g1-v6so4766564wru.2 for ; Thu, 16 Aug 2018 09:51:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3znMJbeQWkhLxICWhFJ+SqqBYPCgwq4EtBhKQqaIsps=; b=Qdfz2LOkYSdPyOD6TF+CsHVZ1DQJ6SPsLHaTDZx6EUtQLd23d2RMLG1E8xYieWfmi0 35/AmLoOx83QJWTN1HZ9yU5Lspwkvbq6DJRAwJThsXqJ4BVXAZfMroynE6qWHx4R8AfY gF9ziapCrvqBV2WmxW7cYVl5wifsyBlZgE750= 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=3znMJbeQWkhLxICWhFJ+SqqBYPCgwq4EtBhKQqaIsps=; b=R8CVUgy60giS99sJHFpizxw1wd43j6a/sxQjVINVQHy3Gtgm9/hXNuW9QUnTcuN2iL Ag+ayZ4blr0fm8us6gMeZc+k7vwuzJm9Xsys7KvRJmZ72XDmER2VGKJM/YtxvtNXOKsh w5grvkefWA5X2+tvr/UnzuLnc8EzBuy9/jfJPaK3xkvPOqzLRbAzWvE8setgjBOfANDy TAnVc+avTsdzGCFPIozJcbwFLVGec3HviIur2JbdN5GIDILsJ91WyyImxUYyKoEP4vQ6 WI2AEupWbRCrxhuCLI0hRZkyqprAcasf0a/Vz6JipeI/JPfh3/gZuYpe2Lf9rDu9aBjv BU+w== X-Gm-Message-State: APzg51CLm5lbQyWc+ogkbYkDqY07IoAjE3ivA92GYfAHc4oJJuEfF2my Aawrucxqjt96RGgNZSyAb5Bs6Q== X-Google-Smtp-Source: AA+uWPwWS/QySF33dPVDrO2aBfFGPIBTJiu2eHnJV1CpMvyar4ur01j4J0pgrG6ck3LRNqv/bL4wJw== X-Received: by 2002:adf:ac41:: with SMTP id v59-v6mr632378wrc.7.1534438318284; Thu, 16 Aug 2018 09:51:58 -0700 (PDT) Received: from localhost.localdomain (146-241-5-103.dyn.eolo.it. [146.241.5.103]) by smtp.gmail.com with ESMTPSA id o3-v6sm30036180wrj.31.2018.08.16.09.51.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 09:51:57 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, Paolo Valente Subject: [PATCH BUGFIX/IMPROVEMENT 2/4] block, bfq: always update the budget of an entity when needed Date: Thu, 16 Aug 2018 18:51:16 +0200 Message-Id: <20180816165118.17402-3-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180816165118.17402-1-paolo.valente@linaro.org> References: <20180816165118.17402-1-paolo.valente@linaro.org> 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 When the next child entity to serve changes for a given parent entity, the budget of that parent entity must be updated accordingly. Unfortunately, this update is not performed, by mistake, for the entities that happen to switch from having no child entity to serve, to having one child entity to serve. Signed-off-by: Paolo Valente --- block/bfq-wf2q.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index dbc07b456059..d558fd26740c 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -130,10 +130,14 @@ static bool bfq_update_next_in_service(struct bfq_sched_data *sd, if (!change_without_lookup) /* lookup needed */ next_in_service = bfq_lookup_next_entity(sd, expiration); - if (next_in_service) - parent_sched_may_change = !sd->next_in_service || + if (next_in_service) { + bool new_budget_triggers_change = bfq_update_parent_budget(next_in_service); + parent_sched_may_change = !sd->next_in_service || + new_budget_triggers_change; + } + sd->next_in_service = next_in_service; if (!next_in_service) From patchwork Thu Aug 16 16:51:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10567873 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 476E8913 for ; Thu, 16 Aug 2018 16:52:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36B612B3EA for ; Thu, 16 Aug 2018 16:52:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B1582B48E; Thu, 16 Aug 2018 16:52:04 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 B4A6B2B3EA for ; Thu, 16 Aug 2018 16:52:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728722AbeHPTvj (ORCPT ); Thu, 16 Aug 2018 15:51:39 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42129 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730574AbeHPTvj (ORCPT ); Thu, 16 Aug 2018 15:51:39 -0400 Received: by mail-wr1-f68.google.com with SMTP id e7-v6so4739036wrs.9 for ; Thu, 16 Aug 2018 09:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pyZHAK8ZrpQtkw3weKOOEv6ell+gZqXbA4ONipLRAF4=; b=hy4r/kfdZPm+yqODJPunTxDsg5mue4mKmETW3Vw9NOCtlXc1ialmJEye/UWWyrYrBM +Wt8A+882lWG5AQk25HH2rxZFhVQH9J59Uqn8y4uoYbxKBFdZTJbZTohU69B0HOTHqgd WxAtxKPPbusR39V4+1FZfXujWLFoT34IVbrtc= 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=pyZHAK8ZrpQtkw3weKOOEv6ell+gZqXbA4ONipLRAF4=; b=Nvw8TvNdeQt+DsdKVu1Uf+dm2yhp8v4YyuuNIYVI/4UuVukPPvmFz134foDyV4eprU 6NCzuWipvl64+TP/2A1eTHIXmfHtKKYgxjmUMg8LcOp5OqNtrkrMT3SLbpZQHrfMyIet Oj04M7Npoj+4hvUcaUyThPdFV7DKQ3xH/CyLr9X+MCD2jROImUPe5z1IPeo426AZVRd7 WH0tRjuqH1sRhWk6zVDm9acyxWlv1QJR26jSmjwc2Ube6anDji5xHbX8Shc73ZAEAg6M qhtElIU4VE3rJiwmqHOQBwzkfv3WvjvDg4M0Hhb/yFPoUi+AkaJcHJeYJWCTe8raqPmy lpHw== X-Gm-Message-State: AOUpUlHqtOUSBxqA5tlHPlbH6h6nZ3ovO9htZgRBVgYo0e5nOoJ9ApYW ZFWARs7mawXpz/4wFj8fZ4og1w== X-Google-Smtp-Source: AA+uWPzcnKeeMkn4qq6gNXMTsm+xJXXxCGErS7gxz5c6zWSflh6ZSCAlK+QcuV4hcNGULGaW4/rq2A== X-Received: by 2002:a5d:51cf:: with SMTP id n15-v6mr20603741wrv.107.1534438319542; Thu, 16 Aug 2018 09:51:59 -0700 (PDT) Received: from localhost.localdomain (146-241-5-103.dyn.eolo.it. [146.241.5.103]) by smtp.gmail.com with ESMTPSA id o3-v6sm30036180wrj.31.2018.08.16.09.51.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 09:51:58 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, Paolo Valente Subject: [PATCH BUGFIX/IMPROVEMENT 3/4] block, bfq: reduce write overcharge Date: Thu, 16 Aug 2018 18:51:17 +0200 Message-Id: <20180816165118.17402-4-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180816165118.17402-1-paolo.valente@linaro.org> References: <20180816165118.17402-1-paolo.valente@linaro.org> 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 When a sync request is dispatched, the queue that contains that request, and all the ancestor entities of that queue, are charged with the number of sectors of the request. In constrast, if the request is async, then the queue and its ancestor entities are charged with the number of sectors of the request, multiplied by an overcharge factor. This throttles the bandwidth for async I/O, w.r.t. to sync I/O, and it is done to counter the tendency of async writes to steal I/O throughput to reads. On the opposite end, the lower this parameter, the stabler I/O control, in the following respect. The lower this parameter is, the less the bandwidth enjoyed by a group decreases - when the group does writes, w.r.t. to when it does reads; - when other groups do reads, w.r.t. to when they do writes. The fixes "block, bfq: always update the budget of an entity when needed" and "block, bfq: readd missing reset of parent-entity service" improved I/O control in bfq to such an extent that it has been possible to revise this overcharge factor downwards. This commit introduces the resulting, new value. Signed-off-by: Paolo Valente --- block/bfq-iosched.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 62efc1b97afb..653100fb719e 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -187,11 +187,25 @@ static const int bfq_stats_min_budgets = 194; static const int bfq_default_max_budget = 16 * 1024; /* - * Async to sync throughput distribution is controlled as follows: - * when an async request is served, the entity is charged the number - * of sectors of the request, multiplied by the factor below + * When a sync request is dispatched, the queue that contains that + * request, and all the ancestor entities of that queue, are charged + * with the number of sectors of the request. In constrast, if the + * request is async, then the queue and its ancestor entities are + * charged with the number of sectors of the request, multiplied by + * the factor below. This throttles the bandwidth for async I/O, + * w.r.t. to sync I/O, and it is done to counter the tendency of async + * writes to steal I/O throughput to reads. + * + * The current value of this parameter is the result of a tuning with + * several hardware and software configurations. We tried to find the + * lowest value for which writes do not cause noticeable problems to + * reads. In fact, the lower this parameter, the stabler I/O control, + * in the following respect. The lower this parameter is, the less + * the bandwidth enjoyed by a group decreases + * - when the group does writes, w.r.t. to when it does reads; + * - when other groups do reads, w.r.t. to when they do writes. */ -static const int bfq_async_charge_factor = 10; +static const int bfq_async_charge_factor = 3; /* Default timeout values, in jiffies, approximating CFQ defaults. */ const int bfq_timeout = HZ / 8; @@ -853,16 +867,7 @@ static unsigned long bfq_serv_to_charge(struct request *rq, if (bfq_bfqq_sync(bfqq) || bfqq->wr_coeff > 1) return blk_rq_sectors(rq); - /* - * If there are no weight-raised queues, then amplify service - * by just the async charge factor; otherwise amplify service - * by twice the async charge factor, to further reduce latency - * for weight-raised queues. - */ - if (bfqq->bfqd->wr_busy_queues == 0) - return blk_rq_sectors(rq) * bfq_async_charge_factor; - - return blk_rq_sectors(rq) * 2 * bfq_async_charge_factor; + return blk_rq_sectors(rq) * bfq_async_charge_factor; } /** From patchwork Thu Aug 16 16:51:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 10567875 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 34E4A913 for ; Thu, 16 Aug 2018 16:52:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 207842B3EA for ; Thu, 16 Aug 2018 16:52:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 132722B48E; Thu, 16 Aug 2018 16:52:16 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 B559C2B3EA for ; Thu, 16 Aug 2018 16:52:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728328AbeHPTvw (ORCPT ); Thu, 16 Aug 2018 15:51:52 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:39866 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730213AbeHPTvk (ORCPT ); Thu, 16 Aug 2018 15:51:40 -0400 Received: by mail-wm0-f67.google.com with SMTP id q8-v6so4977062wmq.4 for ; Thu, 16 Aug 2018 09:52:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MFwx1lYhKb+srSCn4IHsLo9KuWJaInJYfQS9cQKsfGY=; b=B0YQOoawMAWJoKCm802FdEDxe+UJlMEdwCA5khaGmZ6p39K7Gw81QwN3BK6cQ4Cne9 46NGpbhJ51XNytJO+w2Guj6f4a3QM5b4DzYQ/P7Jl+3njrMM9Gl05ABT3k3fsSn5Uk0z 9RhpKol9CpwSX/CrqFTSLyfqkPiX6+u3vJhvA= 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=MFwx1lYhKb+srSCn4IHsLo9KuWJaInJYfQS9cQKsfGY=; b=saFUy48g3DxIHQJAt7gfsCwz67R0SNqe1VaOISOYDIa2J0H6Lhi2VDtK0YEetbSzD5 jjLwbTAD7NouZe/6a6MfkFaWWddjYpGQn2dFpuZj+5prPp4Md5jAiRULJz2NsrxYGEVm M94RCDqR1l4YWtDBTCaMNcJa/qMMipcthTFg8E7iBRNkzmj4+F6o5AeKemA5UHGFWonf F8gD/6vfEmv4GgvTcuz5LmRCnF/Y4F8ueuw4e7yDefCiW1t+4nv0E7qSSAKs08zaGqBy hMWY0cQQbjX/8VK/sD9OdT48uD0QGlnbwvGtrEv7T2EgCfHxkcAUePqpFVYCBHVgAcOK /Hug== X-Gm-Message-State: AOUpUlHWeb9hp1UPDf+hlVt8sbZeQ+E54HVW051FPHIx4bWZUogAn/dp Q8TKAB56czGmyEC8Pd8iH8z4Ww== X-Google-Smtp-Source: AA+uWPwr8H40l7SBG7TeV8yJsewmFD/cOCOvAujDeuipc9hfqW98c0U7EWYT90WTsi6YFzKCFe3qlg== X-Received: by 2002:a1c:9550:: with SMTP id x77-v6mr15682250wmd.135.1534438320867; Thu, 16 Aug 2018 09:52:00 -0700 (PDT) Received: from localhost.localdomain (146-241-5-103.dyn.eolo.it. [146.241.5.103]) by smtp.gmail.com with ESMTPSA id o3-v6sm30036180wrj.31.2018.08.16.09.51.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 09:52:00 -0700 (PDT) From: Paolo Valente To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, Paolo Valente Subject: [PATCH BUGFIX/IMPROVEMENT 4/4] block, bfq: improve code of bfq_bfqq_charge_time Date: Thu, 16 Aug 2018 18:51:18 +0200 Message-Id: <20180816165118.17402-5-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180816165118.17402-1-paolo.valente@linaro.org> References: <20180816165118.17402-1-paolo.valente@linaro.org> 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 bfq_bfqq_charge_time contains some lengthy and redundant code. This commit trims and condenses that code. Signed-off-by: Paolo Valente --- block/bfq-wf2q.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index d558fd26740c..ae52bff43ce4 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -881,15 +881,11 @@ void bfq_bfqq_charge_time(struct bfq_data *bfqd, struct bfq_queue *bfqq, unsigned long time_ms) { struct bfq_entity *entity = &bfqq->entity; - int tot_serv_to_charge = entity->service; - unsigned int timeout_ms = jiffies_to_msecs(bfq_timeout); - - if (time_ms > 0 && time_ms < timeout_ms) - tot_serv_to_charge = - (bfqd->bfq_max_budget * time_ms) / timeout_ms; - - if (tot_serv_to_charge < entity->service) - tot_serv_to_charge = entity->service; + unsigned long timeout_ms = jiffies_to_msecs(bfq_timeout); + unsigned long bounded_time_ms = min(time_ms, timeout_ms); + int serv_to_charge_for_time = + (bfqd->bfq_max_budget * bounded_time_ms) / timeout_ms; + int tot_serv_to_charge = max(serv_to_charge_for_time, entity->service); /* Increase budget to avoid inconsistencies */ if (tot_serv_to_charge > entity->budget)