From patchwork Sun Feb 19 10:42:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A01B6C61DA4 for ; Sun, 19 Feb 2023 02:41:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229669AbjBSClc (ORCPT ); Sat, 18 Feb 2023 21:41:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbjBSCl2 (ORCPT ); Sat, 18 Feb 2023 21:41:28 -0500 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33E6311EB2; Sat, 18 Feb 2023 18:41:26 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4PK8v42lPhz4f3mLg; Sun, 19 Feb 2023 10:41:20 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S3; Sun, 19 Feb 2023 10:41:22 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 01/17] block, bfq: properly mark bfqq remained idle Date: Sun, 19 Feb 2023 18:42:53 +0800 Message-Id: <20230219104309.1511562-2-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Ww48Kr1xtrWrKF4kAFy7KFg_yoW8GrWUpa srGr4vqryrKrWrtF48Wa1rXF18K3s7Gr17XF15uw4UZ3yjqFn7tFsayw4FqryFvrWIkwsx ZwnrWr9xWr90kw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_Jr4l82xGYIkIc2x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2 F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjx v20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2 z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErc IFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0pR3PE3UUUUU = X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Bfqq activation will try to recover the "service hole" of bfqq which may issues requests greedily while remained idle for other reasons: CPU high load, bfqq not enjoying idling, I/O throttling somewhere in the path from the process to the I/O scheduler. So we should mark bfqq remained idle when expired for two reasons: BFQQE_NO_MORE_REQUESTS or BFQQE_TOO_IDLE. More details can be found in comment of bfq_bfqq_update_budg_for_activation. So we should mark bfqq remained idle expired for BFQQE_NO_MORE_REQUESTS or BFQQE_TOO_IDLE instead of (reason != BFQQE_BUDGET_TIMEOUT && reason != BFQQE_BUDGET_EXHAUSTED). Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 777dcab73c8e..3f5c740664ce 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -4420,8 +4420,8 @@ void bfq_bfqq_expire(struct bfq_data *bfqd, /* mark bfqq as waiting a request only if a bic still points to it */ if (!bfq_bfqq_busy(bfqq) && - reason != BFQQE_BUDGET_TIMEOUT && - reason != BFQQE_BUDGET_EXHAUSTED) { + reason == BFQQE_NO_MORE_REQUESTS && + reason == BFQQE_TOO_IDLE) { bfq_mark_bfqq_non_blocking_wait_rq(bfqq); /* * Not setting service to 0, because, if the next rq From patchwork Sun Feb 19 10:42:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3479C64ED6 for ; Sun, 19 Feb 2023 02:41:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229628AbjBSCl3 (ORCPT ); Sat, 18 Feb 2023 21:41:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjBSCl2 (ORCPT ); Sat, 18 Feb 2023 21:41:28 -0500 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27F4411EA1; Sat, 18 Feb 2023 18:41:26 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4PK8v456gdz4f3lbQ; Sun, 19 Feb 2023 10:41:20 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S4; Sun, 19 Feb 2023 10:41:22 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 02/17] block, bfq: try preemption if bfqq has higher weight and the same priority class Date: Sun, 19 Feb 2023 18:42:54 +0800 Message-Id: <20230219104309.1511562-3-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S4 X-Coremail-Antispam: 1UD129KBjvJXoW7AF4xWF43Cw4fZFW7Wr13CFg_yoW8Gryk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o: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org We will compare priority class and weight of current bfqq with in_service_queue to check if bfqq could preempt in_service_queue. Currently we will try to preempt in_service_queue if bfqq has higher weight than in_service_queue even with lower priority class. Actually, we will only serve bfqq with higher priority class (see bfq_lookup_next_entity), so bfqq with higher weight and lower priority class will not be a candidate to preempt in_service_queue. Compare weight of bfqqs with the same priority in bfq_bfqq_higher_class_or_weight to make preemption check more reasonable. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 3f5c740664ce..4868538c9745 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1768,6 +1768,10 @@ static bool bfq_bfqq_higher_class_or_weight(struct bfq_queue *bfqq, if (bfqq->ioprio_class < in_serv_bfqq->ioprio_class) return true; + /* only try weight comparison with same priority class */ + if (bfqq->ioprio_class != in_serv_bfqq->ioprio_class) + return false; + if (in_serv_bfqq->entity.parent == bfqq->entity.parent) { bfqq_weight = bfqq->entity.weight; in_serv_weight = in_serv_bfqq->entity.weight; From patchwork Sun Feb 19 10:42:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AEAEC61DA4 for ; Sun, 19 Feb 2023 02:41:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229605AbjBSCl3 (ORCPT ); Sat, 18 Feb 2023 21:41:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbjBSCl2 (ORCPT ); Sat, 18 Feb 2023 21:41:28 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E9E011EB8; Sat, 18 Feb 2023 18:41:26 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PK8v50zc2z4f3pBt; Sun, 19 Feb 2023 10:41:21 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S5; Sun, 19 Feb 2023 10:41:23 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 03/17] block, bfq: only preempt plugged in_service_queue if bfq_better_to_idle say no Date: Sun, 19 Feb 2023 18:42:55 +0800 Message-Id: <20230219104309.1511562-4-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S5 X-Coremail-Antispam: 1UD129KBjvJXoW7WrW3Gr15GFy7ZFWfuw4rXwb_yoW8WrWfpF WqkryfXw1xta15Zry7X3yUJFy3uF93G3saqr4xZF4Yq34xAr97C3ZIy34Yqr48Wrs7Aw43 XFyrC3sIgw1UAw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPSb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUWwA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l 84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zV CS5cI20VAGYxC7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E 5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAV WUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY 1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI 0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7s RNiiSUUUUUU== X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Why we preempt in_service_queue when bfq_better_to_idle say no is (from comment above the preemption expiration): As for throughput, we ask bfq_better_to_idle() whether we still need to plug I/O dispatching. If bfq_better_to_idle() says no, then plugging is not needed any longer, either to boost throughput or to perserve service guarantees. Then the best option is to stop plugging I/O, as not doing so would certainly lower throughput. This preemption only makes sense that IO of in_service_queue is currently plugged and then there is a need to stop plugging. Make sure bfqq is plugged before bfq_better_to_idle check to improve this. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 4868538c9745..7b416f9471b3 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1978,8 +1978,9 @@ static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, if (bfqd->in_service_queue && ((bfqq_wants_to_preempt && bfqq->wr_coeff >= bfqd->in_service_queue->wr_coeff) || - bfq_bfqq_higher_class_or_weight(bfqq, bfqd->in_service_queue) || - !bfq_better_to_idle(bfqd->in_service_queue)) && + bfq_bfqq_higher_class_or_weight(bfqq, bfqd->in_service_queue) || + (bfq_bfqq_wait_request(bfqq) && + !bfq_better_to_idle(bfqd->in_service_queue))) && next_queue_may_preempt(bfqd)) bfq_bfqq_expire(bfqd, bfqd->in_service_queue, false, BFQQE_PREEMPTED); From patchwork Sun Feb 19 10:42:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 100E6C64ED9 for ; Sun, 19 Feb 2023 02:41:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229557AbjBSClb (ORCPT ); Sat, 18 Feb 2023 21:41:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbjBSCl2 (ORCPT ); Sat, 18 Feb 2023 21:41:28 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67EC212043; Sat, 18 Feb 2023 18:41:26 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PK8v53SpCz4f3p1G; Sun, 19 Feb 2023 10:41:21 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S6; Sun, 19 Feb 2023 10:41:23 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 04/17] block, bfq: recover the "service hole" if enough budget is left Date: Sun, 19 Feb 2023 18:42:56 +0800 Message-Id: <20230219104309.1511562-5-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S6 X-Coremail-Antispam: 1UD129KBjvJXoW7ZF48ury5Kw18CFWfAF4kXrb_yoW8XF18pa 9rKryS9rn5WFn8Xa1Iv3W3X34rX3Wfury7t3yFv3yrJa9xZw129F4ay345tayIqFZ7trWa vr1DXryUWw4UZrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xv wVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFc xC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_ Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2 IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0pRvJPtU UUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org If budget left is less than budget need by next request, the activated bfqq will be expired if it preempts the in-service queue. Avoid to cause useless overhead to check budget left is enough for next request. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 7b416f9471b3..edbf5c9aeb47 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1588,13 +1588,15 @@ static bool bfq_bfqq_update_budg_for_activation(struct bfq_data *bfqd, /* * In the next compound condition, we check also whether there - * is some budget left, because otherwise there is no point in - * trying to go on serving bfqq with this same budget: bfqq - * would be expired immediately after being selected for - * service. This would only cause useless overhead. + * is some budget left for next request to serve, because + * otherwise there is no point in trying to go on serving bfqq + * with this same budget: bfqq would be expired immediately + * after being selected for service. This would only cause + * useless overhead. */ if (bfq_bfqq_non_blocking_wait_rq(bfqq) && arrived_in_time && - bfq_bfqq_budget_left(bfqq) > 0) { + bfq_bfqq_budget_left(bfqq) >= + bfq_serv_to_charge(bfqq->next_rq, bfqq)) { /* * We do not clear the flag non_blocking_wait_rq here, as * the latter is used in bfq_activate_bfqq to signal From patchwork Sun Feb 19 10:42:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB779C677F1 for ; Sun, 19 Feb 2023 02:41:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229633AbjBSCla (ORCPT ); Sat, 18 Feb 2023 21:41:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbjBSCl2 (ORCPT ); Sat, 18 Feb 2023 21:41:28 -0500 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2A5B1204D; Sat, 18 Feb 2023 18:41:26 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4PK8v54774z4f3npn; Sun, 19 Feb 2023 10:41:21 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S7; Sun, 19 Feb 2023 10:41:23 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 05/17] block, bfq: Update bfqd->max_budget with bfqd->lock held Date: Sun, 19 Feb 2023 18:42:57 +0800 Message-Id: <20230219104309.1511562-6-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S7 X-Coremail-Antispam: 1UD129KBjvJXoW7WF17Gr47JFy8XF1rurW5Awb_yoW8AF18pa sFq34Sqr1UJ39aqrsrGa18X3WagwsxWrZrKw4Fqw17JF92yF1Iy3Wjq3WagF4rJF4fAwsr Z3Wvga9Yqa42yrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xv wVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFc xC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_ Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2 IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0pRvJPtU UUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org bfq_max_budget and bfq_user_max_budget maybe be in inconsisten state if bfq_max_budget configuration and bfq_max_budget auto-update happen concurrently. Example sequence: config auto-update bfqd->bfq_max_budget = __data if (bfqd->bfq_user_max_budget == 0) bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); bfqd->bfq_user_max_budget = __data; Users may set bfq_max_budget successfully while read a different value from they set. bfq_max_budget is only update in update_thr_responsiveness_params and configuration code. As update_thr_responsiveness_params is always called under bfqd->lock, fix this by holding lock in configuration code. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index edbf5c9aeb47..5b08711cbaf6 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -7489,6 +7489,7 @@ static ssize_t bfq_max_budget_store(struct elevator_queue *e, if (ret) return ret; + spin_lock_irq(&bfqd->lock); if (__data == 0) bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); else { @@ -7498,6 +7499,7 @@ static ssize_t bfq_max_budget_store(struct elevator_queue *e, } bfqd->bfq_user_max_budget = __data; + spin_unlock_irq(&bfqd->lock); return count; } @@ -7523,8 +7525,11 @@ static ssize_t bfq_timeout_sync_store(struct elevator_queue *e, __data = INT_MAX; bfqd->bfq_timeout = msecs_to_jiffies(__data); + + spin_lock_irq(&bfqd->lock); if (bfqd->bfq_user_max_budget == 0) bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); + spin_unlock_irq(&bfqd->lock); return count; } From patchwork Sun Feb 19 10:42:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2D42C64ED8 for ; Sun, 19 Feb 2023 02:41:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbjBSCla (ORCPT ); Sat, 18 Feb 2023 21:41:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbjBSCl2 (ORCPT ); Sat, 18 Feb 2023 21:41:28 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA67112051; Sat, 18 Feb 2023 18:41:26 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PK8v60GP2z4f3pBy; Sun, 19 Feb 2023 10:41:22 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S8; Sun, 19 Feb 2023 10:41:24 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 06/17] block, bfq: correct bfq_max_budget and bfq_min_budget Date: Sun, 19 Feb 2023 18:42:58 +0800 Message-Id: <20230219104309.1511562-7-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S8 X-Coremail-Antispam: 1UD129KBjvJXoW7Jry5Zw15WF1UWrW3tr47Jwb_yoW8JrW5pa 4qqw10gF17JrZxXrs7K3WUX3W5twsxZF4kKr1YqrWjyF4IyF1ayF18Zw18X3WfKrWIyry5 X3sru34DXa12kaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xv wVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFc xC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_ Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2 IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0pRvJPtU UUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org For case that user set a max_budget, we should use bfq_max_budget set by user instead of bfq_default_max_budget when budgets_assigned is not enough to compulte auto-tuning max_budget. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 5b08711cbaf6..b32bae5259d5 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1458,7 +1458,8 @@ static int bfq_bfqq_budget_left(struct bfq_queue *bfqq) */ static int bfq_max_budget(struct bfq_data *bfqd) { - if (bfqd->budgets_assigned < bfq_stats_min_budgets) + if (bfqd->budgets_assigned < bfq_stats_min_budgets && + bfqd->bfq_user_max_budget == 0) return bfq_default_max_budget; else return bfqd->bfq_max_budget; @@ -1470,7 +1471,8 @@ static int bfq_max_budget(struct bfq_data *bfqd) */ static int bfq_min_budget(struct bfq_data *bfqd) { - if (bfqd->budgets_assigned < bfq_stats_min_budgets) + if (bfqd->budgets_assigned < bfq_stats_min_budgets && + bfqd->bfq_user_max_budget == 0) return bfq_default_max_budget / 32; else return bfqd->bfq_max_budget / 32; From patchwork Sun Feb 19 10:42:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145768 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E05EC677F1 for ; Sun, 19 Feb 2023 02:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229441AbjBSClc (ORCPT ); Sat, 18 Feb 2023 21:41:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbjBSCl2 (ORCPT ); Sat, 18 Feb 2023 21:41:28 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 079E912057; Sat, 18 Feb 2023 18:41:26 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PK8v635HWz4f3p1D; Sun, 19 Feb 2023 10:41:22 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S9; Sun, 19 Feb 2023 10:41:24 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 07/17] block, bfq: correct interactive weight-raise check in bfq_set_budget_timeout Date: Sun, 19 Feb 2023 18:42:59 +0800 Message-Id: <20230219104309.1511562-8-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S9 X-Coremail-Antispam: 1UD129KBjvdXoWrtF17AF1UJFyUZF47AFW3trb_yoWkWFb_C3 Z5tr1rJF1kGr93CFsrt34rAryDKw18J3WkC34xKrnFgr42yFs2k34qgr90yFZ8Za9F9Fy3 JFsYqF1UJrsrZjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbDkFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M28IrcIa0xkI8V A2jI8067AKxVWUAVCq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJ M28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2I x0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK 6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4 xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8 JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20V AGYxC7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc4 0Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AK xVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr 1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7sRiVbyDUU UUU== X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org After weight-raise finished, bfqq->wr_coeff is reset to 1 while bfqq->wr_cur_max_time may not be reset. For example, Function bfq_update_bfqq_wr_on_rq_arrival will only reset wr_coeff to 1 if bfqq is created in burst creation. Function bfq_set_budget_timeout will be called when bfqq is selected while it's wr_cur_max_time is set and wr_coeff is 1. Fix this by check wr_coeff > 1 along with check wr_cur_max_time check like other code do. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index b32bae5259d5..5610a7dcacdf 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -3297,7 +3297,8 @@ static void bfq_set_budget_timeout(struct bfq_data *bfqd, { unsigned int timeout_coeff; - if (bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time) + if (bfqq->wr_coeff > 1 && + bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time) timeout_coeff = 1; else timeout_coeff = bfqq->entity.weight / bfqq->entity.orig_weight; From patchwork Sun Feb 19 10:43:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145764 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AAF6C678D5 for ; Sun, 19 Feb 2023 02:41:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbjBSClb (ORCPT ); Sat, 18 Feb 2023 21:41:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229593AbjBSCl2 (ORCPT ); Sat, 18 Feb 2023 21:41:28 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C9EB12849; Sat, 18 Feb 2023 18:41:27 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PK8v65Q1jz4f3pFW; Sun, 19 Feb 2023 10:41:22 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S10; Sun, 19 Feb 2023 10:41:24 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 08/17] block, bfq: start service_from_wr accumulating of async queues correctly Date: Sun, 19 Feb 2023 18:43:00 +0800 Message-Id: <20230219104309.1511562-9-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S10 X-Coremail-Antispam: 1UD129KBjvdXoW7Wr1fXw13uF17Ar43Xw47Arb_yoWftFX_Gw s5Gr1DCFWkGr4rCrsayFW5XFZ5KayrZF1qyFnxKr1UXF1Sq3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: X-Mailing-List: linux-block@vger.kernel.org Start accumulating service_from_wr when async queues are weight raised. The service_from_wr for async queues is accumulated and checked to finish weight-raise as sync queues. We need charge service_from_wr for async queues or service_from_wr will keep accumulating and async queues will finish weight-raise soon after weight-raise starts. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 5610a7dcacdf..7a0283f08aed 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2323,6 +2323,7 @@ static void bfq_add_request(struct request *rq) time_is_before_jiffies( bfqq->last_wr_start_finish + bfqd->bfq_wr_min_inter_arr_async)) { + bfqq->service_from_wr = 0; bfqq->wr_coeff = bfqd->bfq_wr_coeff; bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); From patchwork Sun Feb 19 10:43:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24AF8C64ED6 for ; Sun, 19 Feb 2023 02:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbjBSCld (ORCPT ); Sat, 18 Feb 2023 21:41:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbjBSCl2 (ORCPT ); Sat, 18 Feb 2023 21:41:28 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F95512863; Sat, 18 Feb 2023 18:41:27 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PK8v70DGSz4f3pBv; Sun, 19 Feb 2023 10:41:23 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S11; Sun, 19 Feb 2023 10:41:25 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 09/17] block, bfq: stop to detect queue as waker queue if it already is now Date: Sun, 19 Feb 2023 18:43:01 +0800 Message-Id: <20230219104309.1511562-10-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S11 X-Coremail-Antispam: 1UD129KBjvdXoW7Xry5Ar18Gw13Cr1fJF4kXrb_yoWfXrbEya yFgr18Aan8Jay5Cr1YvryUtwnrua18Xw1kJFs8tFnrWFn8J3Z5C3sFqrW3AFs8WayxWFya yrsaq3Z8tr4IyjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbDAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M28IrcIa0xkI8V A2jI8067AKxVWUAVCq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJ M28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2I x0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK 6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4 xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8 JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20V AGYxC7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc4 0Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AK xVWxJVW8Jr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0pRvJPtU UUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org If last_completed_rq_bfqq is the current waker queue of bfqq, it's no meaning to execute the detection logic as nothing will change whether detection successes or fails. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 7a0283f08aed..0a11a381ee7d 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2147,7 +2147,8 @@ static void bfq_check_waker(struct bfq_data *bfqd, struct bfq_queue *bfqq, bfq_bfqq_has_short_ttime(bfqq) || now_ns - bfqd->last_completion >= 4 * NSEC_PER_MSEC || bfqd->last_completed_rq_bfqq == &bfqd->oom_bfqq || - bfqq == &bfqd->oom_bfqq) + bfqq == &bfqd->oom_bfqq || + bfqd->last_completed_rq_bfqq == bfqq->waker_bfqq) return; /* From patchwork Sun Feb 19 10:43:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D2E1C636D7 for ; Sun, 19 Feb 2023 02:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229682AbjBSCld (ORCPT ); Sat, 18 Feb 2023 21:41:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbjBSCl2 (ORCPT ); Sat, 18 Feb 2023 21:41:28 -0500 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2F0612864; Sat, 18 Feb 2023 18:41:27 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4PK8v719P1z4f3npw; Sun, 19 Feb 2023 10:41:23 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S12; Sun, 19 Feb 2023 10:41:25 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 10/17] block, bfq: fix typo in comment Date: Sun, 19 Feb 2023 18:43:02 +0800 Message-Id: <20230219104309.1511562-11-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S12 X-Coremail-Antispam: 1UD129KBjvJXoW7tw4fuw1fGr13KF18Wr45Jrb_yoW8Xr1rpa srKF1fZr4xKF45XFW8Wa15Xr93Aan5Cr9rJFZFvw4jvrW7u3Z2qanIk348XF1Iqr93CF4D ZwnFqryDZr4xGr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xv wVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFc xC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_ Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2 IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JV WxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjTRKfOw UUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org IO/ -> I/O bfq_fqq_update_budg_for_activation -> bfq_bfqq_update_budg_for_activation Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 2 +- block/bfq-wf2q.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 0a11a381ee7d..2559343593bb 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -5734,7 +5734,7 @@ bfq_do_early_stable_merge(struct bfq_data *bfqd, struct bfq_queue *bfqq, * * Putting these two facts together, this commits merges stably the * bfq_queues associated with these I/O flows, i.e., with the - * processes that generate these IO/ flows, regardless of how many the + * processes that generate these I/O flows, regardless of how many the * involved processes are. * * To decide whether a set of bfq_queues is actually associated with diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 7941b6f07391..1b8d05bae116 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -931,7 +931,7 @@ static void __bfq_activate_entity(struct bfq_entity *entity, bool backshifted = false; unsigned long long min_vstart; - /* See comments on bfq_fqq_update_budg_for_activation */ + /* See comments on bfq_bfqq_update_budg_for_activation */ if (non_blocking_wait_rq && bfq_gt(st->vtime, entity->finish)) { backshifted = true; min_vstart = entity->finish; From patchwork Sun Feb 19 10:43:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145770 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56E24C64ED8 for ; Sun, 19 Feb 2023 02:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229689AbjBSCle (ORCPT ); Sat, 18 Feb 2023 21:41:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbjBSCl2 (ORCPT ); Sat, 18 Feb 2023 21:41:28 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4309912865; Sat, 18 Feb 2023 18:41:28 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PK8v74QlLz4f3pBn; Sun, 19 Feb 2023 10:41:23 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S13; Sun, 19 Feb 2023 10:41:25 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 11/17] block, bfq: simpfy computation of bfqd->budgets_assigned Date: Sun, 19 Feb 2023 18:43:03 +0800 Message-Id: <20230219104309.1511562-12-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S13 X-Coremail-Antispam: 1UD129KBjvJXoWrtw17JrW7ZrWktw13AFW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fo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The computation of budgets_assigned is a little confusing as we only need to check if it's updated more than 10 times. Simpfy the computation to improve readability. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 2559343593bb..a8cb0a0d36f3 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -175,7 +175,7 @@ static const int bfq_back_penalty = 2; static u64 bfq_slice_idle = NSEC_PER_SEC / 125; /* Minimum number of assigned budgets for which stats are safe to compute. */ -static const int bfq_stats_min_budgets = 194; +static const int bfq_stats_min_budgets = 11; /* Default maximum budget values, in sectors and number of requests. */ static const int bfq_default_max_budget = 16 * 1024; @@ -3317,7 +3317,7 @@ static void __bfq_set_in_service_queue(struct bfq_data *bfqd, if (bfqq) { bfq_clear_bfqq_fifo_expire(bfqq); - bfqd->budgets_assigned = (bfqd->budgets_assigned * 7 + 256) / 8; + bfqd->budgets_assigned++; if (time_is_before_jiffies(bfqq->last_wr_start_finish) && bfqq->wr_coeff > 1 && From patchwork Sun Feb 19 10:43:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F7D9C6FA99 for ; Sun, 19 Feb 2023 02:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229693AbjBSClf (ORCPT ); Sat, 18 Feb 2023 21:41:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229630AbjBSCl3 (ORCPT ); Sat, 18 Feb 2023 21:41:29 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 887BA11EA1; Sat, 18 Feb 2023 18:41:28 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PK8v76Vpwz4f3pC9; Sun, 19 Feb 2023 10:41:23 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S14; Sun, 19 Feb 2023 10:41:25 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 12/17] block, bfq: define and use soft_rt, in_burst and wr_or_deserves_wr only low_latency is enable Date: Sun, 19 Feb 2023 18:43:04 +0800 Message-Id: <20230219104309.1511562-13-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S14 X-Coremail-Antispam: 1UD129KBjvJXoW3WrW7CFW7Cw18ZF4DWry8Krg_yoW7XrWDpF WagFy3tr43JF4fZrW3Kw48Xr1Sv3WfGFWIkFZ0q34kAF1UCrn2qFyqyr1Fvas7ur9xCr43 XrWqqa97CF1kAF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xv wVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFc xC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_ Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2 IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JV WxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjTRKfOw UUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The soft_rt, in_burst and wr_or_deserves_wr are only used when low_latency is enable. Currently, these variables are computed even low_latency is disable. Define these variables in successful branch of bfqd->low_latency check and compute them if needed to remove redundant computation and improve readability. The interactive parameter will be used only if low_latency is enabled outside bfq_bfqq_handle_idle_busy_switch, so it's safe to move interactive assignment inside branch where low_latency is true. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 81 +++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index a8cb0a0d36f3..eda6669d0571 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1828,8 +1828,7 @@ static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, struct request *rq, bool *interactive) { - bool soft_rt, in_burst, wr_or_deserves_wr, - bfqq_wants_to_preempt, + bool bfqq_wants_to_preempt, idle_for_long_time = bfq_bfqq_idle_for_long_time(bfqd, bfqq), /* * See the comments on @@ -1840,43 +1839,6 @@ static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, bfqq->ttime.last_end_request + bfqd->bfq_slice_idle * 3; unsigned int act_idx = bfq_actuator_index(bfqd, rq->bio); - bool bfqq_non_merged_or_stably_merged = - bfqq->bic || RQ_BIC(rq)->bfqq_data[act_idx].stably_merged; - - /* - * bfqq deserves to be weight-raised if: - * - it is sync, - * - it does not belong to a large burst, - * - it has been idle for enough time or is soft real-time, - * - is linked to a bfq_io_cq (it is not shared in any sense), - * - has a default weight (otherwise we assume the user wanted - * to control its weight explicitly) - */ - in_burst = bfq_bfqq_in_large_burst(bfqq); - soft_rt = bfqd->bfq_wr_max_softrt_rate > 0 && - !BFQQ_TOTALLY_SEEKY(bfqq) && - !in_burst && - time_is_before_jiffies(bfqq->soft_rt_next_start) && - bfqq->dispatched == 0 && - bfqq->entity.new_weight == 40; - *interactive = !in_burst && idle_for_long_time && - bfqq->entity.new_weight == 40; - /* - * Merged bfq_queues are kept out of weight-raising - * (low-latency) mechanisms. The reason is that these queues - * are usually created for non-interactive and - * non-soft-real-time tasks. Yet this is not the case for - * stably-merged queues. These queues are merged just because - * they are created shortly after each other. So they may - * easily serve the I/O of an interactive or soft-real time - * application, if the application happens to spawn multiple - * processes. So let also stably-merged queued enjoy weight - * raising. - */ - wr_or_deserves_wr = bfqd->low_latency && - (bfqq->wr_coeff > 1 || - (bfq_bfqq_sync(bfqq) && bfqq_non_merged_or_stably_merged && - (*interactive || soft_rt))); /* * Using the last flag, update budget and check whether bfqq @@ -1911,6 +1873,24 @@ static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, bfq_clear_bfqq_just_created(bfqq); if (bfqd->low_latency) { + bool soft_rt, in_burst, wr_or_deserves_wr; + bool bfqq_non_merged_or_stably_merged = + bfqq->bic || + RQ_BIC(rq)->bfqq_data[act_idx].stably_merged; + + /* + * bfqq deserves to be weight-raised if: + * - it is sync, + * - it does not belong to a large burst, + * - it has been idle for enough time or is soft real-time, + * - is linked to a bfq_io_cq (it is not shared in any sense), + * - has a default weight (otherwise we assume the user wanted + * to control its weight explicitly) + */ + in_burst = bfq_bfqq_in_large_burst(bfqq); + *interactive = !in_burst && idle_for_long_time && + bfqq->entity.new_weight == 40; + if (unlikely(time_is_after_jiffies(bfqq->split_time))) /* wraparound */ bfqq->split_time = @@ -1918,6 +1898,29 @@ static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, if (time_is_before_jiffies(bfqq->split_time + bfqd->bfq_wr_min_idle_time)) { + soft_rt = bfqd->bfq_wr_max_softrt_rate > 0 && + !BFQQ_TOTALLY_SEEKY(bfqq) && + !in_burst && + time_is_before_jiffies(bfqq->soft_rt_next_start) && + bfqq->dispatched == 0 && + bfqq->entity.new_weight == 40; + /* + * Merged bfq_queues are kept out of weight-raising + * (low-latency) mechanisms. The reason is that these queues + * are usually created for non-interactive and + * non-soft-real-time tasks. Yet this is not the case for + * stably-merged queues. These queues are merged just because + * they are created shortly after each other. So they may + * easily serve the I/O of an interactive or soft-real time + * application, if the application happens to spawn multiple + * processes. So let also stably-merged queued enjoy weight + * raising. + */ + wr_or_deserves_wr = (bfqq->wr_coeff > 1 || + (bfq_bfqq_sync(bfqq) && + bfqq_non_merged_or_stably_merged && + (*interactive || soft_rt))); + bfq_update_bfqq_wr_on_rq_arrival(bfqd, bfqq, old_wr_coeff, wr_or_deserves_wr, From patchwork Sun Feb 19 10:43:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79ED0C64ED8 for ; Sun, 19 Feb 2023 02:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbjBSCli (ORCPT ); Sat, 18 Feb 2023 21:41:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbjBSCla (ORCPT ); Sat, 18 Feb 2023 21:41:30 -0500 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6EB211EA6; Sat, 18 Feb 2023 18:41:28 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4PK8v80V46z4f3mLw; Sun, 19 Feb 2023 10:41:24 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S15; Sun, 19 Feb 2023 10:41:26 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 13/17] block, bfq: remove unnecessary "wr" part of wr_or_deserves_wr Date: Sun, 19 Feb 2023 18:43:05 +0800 Message-Id: <20230219104309.1511562-14-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S15 X-Coremail-Antispam: 1UD129KBjvJXoW7Aw1rCFW7Xr47Aw4kKFy5twb_yoW8tr13pr WrK3W2qry5Jr15ZFWrta18XF1av3WfXFW7tanIqr95Xr4UJr92qa4qyw1rtF93WrZ3Kr47 Z34DW3y8ZF1kAaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xv wVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFc xC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_ Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2 IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JV WxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjTRKfOw UUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Before commit 96a291c38c3299 ("block, bfq: preempt lower-weight or lower-priority queues"), wr_or_deserves_wr is used to check if preempt is wanted. Currently, wr_or_deserves_wr is only used in bfq_update_bfqq_wr_on_rq_arrival to check if weight raising is needed, so the "wr" part of wr_or_deserves_wr is not needed anymore. Rename wr_or_deserves_wr to deserves_wr and remove unnecessary bfqq->wr_coeff > 1 for original wr_or_deserves_wr. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index eda6669d0571..6a8ea9a451cc 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1656,12 +1656,12 @@ static unsigned long bfq_smallest_from_now(void) static void bfq_update_bfqq_wr_on_rq_arrival(struct bfq_data *bfqd, struct bfq_queue *bfqq, unsigned int old_wr_coeff, - bool wr_or_deserves_wr, + bool deserves_wr, bool interactive, bool in_burst, bool soft_rt) { - if (old_wr_coeff == 1 && wr_or_deserves_wr) { + if (old_wr_coeff == 1 && deserves_wr) { /* start a weight-raising period */ if (interactive) { bfqq->service_from_wr = 0; @@ -1873,7 +1873,7 @@ static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, bfq_clear_bfqq_just_created(bfqq); if (bfqd->low_latency) { - bool soft_rt, in_burst, wr_or_deserves_wr; + bool soft_rt, in_burst, deserves_wr; bool bfqq_non_merged_or_stably_merged = bfqq->bic || RQ_BIC(rq)->bfqq_data[act_idx].stably_merged; @@ -1916,14 +1916,13 @@ static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, * processes. So let also stably-merged queued enjoy weight * raising. */ - wr_or_deserves_wr = (bfqq->wr_coeff > 1 || - (bfq_bfqq_sync(bfqq) && + deserves_wr = (bfq_bfqq_sync(bfqq) && bfqq_non_merged_or_stably_merged && - (*interactive || soft_rt))); + (*interactive || soft_rt)); bfq_update_bfqq_wr_on_rq_arrival(bfqd, bfqq, old_wr_coeff, - wr_or_deserves_wr, + deserves_wr, *interactive, in_burst, soft_rt); From patchwork Sun Feb 19 10:43:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145774 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E75FC64ED6 for ; Sun, 19 Feb 2023 02:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbjBSClf (ORCPT ); Sat, 18 Feb 2023 21:41:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjBSCl3 (ORCPT ); Sat, 18 Feb 2023 21:41:29 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1935511EB2; Sat, 18 Feb 2023 18:41:29 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PK8v84Blqz4f3nTp; Sun, 19 Feb 2023 10:41:24 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S16; Sun, 19 Feb 2023 10:41:26 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 14/17] block, bfq: remove redundant oom_bfqq check for bfqq from bfq_find_close_cooperator Date: Sun, 19 Feb 2023 18:43:06 +0800 Message-Id: <20230219104309.1511562-15-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S16 X-Coremail-Antispam: 1UD129KBjvdXoW7GrWUCw4Utr4DCr4UXFy7Wrg_yoWfCrg_Aw 4vgrZrJFW8JFW5tw4akr4jyF4YyFW3Xw1DXryFqr13G3W3JFn5C3srKrZxZFZ8CayIya43 Ja1qqr4UJw1xCjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbDAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M28IrcIa0xkI8V A2jI8067AKxVWUAVCq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJ M28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2I x0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK 6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4 xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8 JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20V AGYxC7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc4 0Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r4j6ryUMIIF0xvE2Ix0cI8IcVCY1x0267AK xVWxJVW8Jr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0pRvJPtU UUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The oom_bfqq is never added to tree in bfq_pos_tree_add_move, so bfqq returned from bfq_find_close_cooperator is no need to be checked if it's oom_bfqq. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 6a8ea9a451cc..ee02c7502394 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -3038,8 +3038,7 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, new_bfqq = bfq_find_close_cooperator(bfqd, bfqq, bfq_io_struct_pos(io_struct, request)); - if (new_bfqq && likely(new_bfqq != &bfqd->oom_bfqq) && - bfq_may_be_close_cooperator(bfqq, new_bfqq)) + if (new_bfqq && bfq_may_be_close_cooperator(bfqq, new_bfqq)) return bfq_setup_merge(bfqq, new_bfqq); return NULL; From patchwork Sun Feb 19 10:43:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28F1AC64EC4 for ; Sun, 19 Feb 2023 02:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229622AbjBSClh (ORCPT ); Sat, 18 Feb 2023 21:41:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbjBSCla (ORCPT ); Sat, 18 Feb 2023 21:41:30 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60D0B11EB8; Sat, 18 Feb 2023 18:41:29 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PK8v86GY0z4f3t7T; Sun, 19 Feb 2023 10:41:24 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S17; Sun, 19 Feb 2023 10:41:26 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 15/17] block, bfq: some cleanups for function bfq_pos_tree_add_move Date: Sun, 19 Feb 2023 18:43:07 +0800 Message-Id: <20230219104309.1511562-16-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-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Ik0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JV WxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjTRKfOw UUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org There are three cleanups in this patch: 1. The oom_bfqq is never inserted to tree, so return immediately for oom_bfqq before unnecessary NULL check of bfqq->pos_root. 2. Only set bfqq->pos_root after bfq_rq_pos_tree_lookup successes rather than set bfqq->pos_root unconditionally and reset to NULL if bfq_rq_pos_tree_lookup fails. 3. Remove unnecessary local variable __bfqq which is only used to check return value of bfq_rq_pos_tree_lookup. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index ee02c7502394..6ba096e9aec6 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -783,17 +783,16 @@ void __cold bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq) { struct rb_node **p, *parent; - struct bfq_queue *__bfqq; + + /* oom_bfqq does not participate in queue merging */ + if (bfqq == &bfqd->oom_bfqq) + return; if (bfqq->pos_root) { rb_erase(&bfqq->pos_node, bfqq->pos_root); bfqq->pos_root = NULL; } - /* oom_bfqq does not participate in queue merging */ - if (bfqq == &bfqd->oom_bfqq) - return; - /* * bfqq cannot be merged any longer (see comments in * bfq_setup_cooperator): no point in adding bfqq into the @@ -807,14 +806,13 @@ bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq) if (!bfqq->next_rq) return; + if (bfq_rq_pos_tree_lookup(bfqd, &bfqq_group(bfqq)->rq_pos_tree, + blk_rq_pos(bfqq->next_rq), &parent, &p)) + return; + bfqq->pos_root = &bfqq_group(bfqq)->rq_pos_tree; - __bfqq = bfq_rq_pos_tree_lookup(bfqd, bfqq->pos_root, - blk_rq_pos(bfqq->next_rq), &parent, &p); - if (!__bfqq) { - rb_link_node(&bfqq->pos_node, parent, p); - rb_insert_color(&bfqq->pos_node, bfqq->pos_root); - } else - bfqq->pos_root = NULL; + rb_link_node(&bfqq->pos_node, parent, p); + rb_insert_color(&bfqq->pos_node, bfqq->pos_root); } /* From patchwork Sun Feb 19 10:43:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F9D3C636D7 for ; Sun, 19 Feb 2023 02:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229506AbjBSClg (ORCPT ); Sat, 18 Feb 2023 21:41:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbjBSCla (ORCPT ); Sat, 18 Feb 2023 21:41:30 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6AFE12043; Sat, 18 Feb 2023 18:41:29 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PK8v911Lsz4f3pBV; Sun, 19 Feb 2023 10:41:25 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S18; Sun, 19 Feb 2023 10:41:27 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 16/17] block, bfq: remove unnecessary goto tag in __bfq_weights_tree_remove Date: Sun, 19 Feb 2023 18:43:08 +0800 Message-Id: <20230219104309.1511562-17-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S18 X-Coremail-Antispam: 1UD129KBjvdXoWrtw4UCw15KryUJw17Kw13twb_yoWDWrg_C3 WvvrykKr4DC398Cr4xtrWaqw1DA393ZFy8GFsxGF1fuw17JasIk3s2qrZ8Jan5Xan2gFZx GrZ5tw13ZF1jkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbqxFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M28IrcIa0xkI8V A2jI8067AKxVWUAVCq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJ M28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2I x0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK 6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4 xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8 JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20V AGYxC7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc4 0Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r4j6ryUMIIF0xvE2Ix0cI8IcVCY1x0267AK xVW8Jr0_Cr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JV WxJwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7sRiVb yDUUUUU== X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Do free work if num_active == 0 and remove unnecessary tag reset_entity_pointer. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 6ba096e9aec6..2705a24ab146 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -976,13 +976,11 @@ void bfq_weights_tree_remove(struct bfq_queue *bfqq) root = &bfqq->bfqd->queue_weights_tree; bfqq->weight_counter->num_active--; - if (bfqq->weight_counter->num_active > 0) - goto reset_entity_pointer; - - rb_erase_cached(&bfqq->weight_counter->weights_node, root); - kfree(bfqq->weight_counter); + if (bfqq->weight_counter->num_active == 0) { + rb_erase_cached(&bfqq->weight_counter->weights_node, root); + kfree(bfqq->weight_counter); + } -reset_entity_pointer: bfqq->weight_counter = NULL; bfq_put_queue(bfqq); } From patchwork Sun Feb 19 10:43:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13145772 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 138FFC61DA4 for ; Sun, 19 Feb 2023 02:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229725AbjBSClh (ORCPT ); Sat, 18 Feb 2023 21:41:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbjBSCla (ORCPT ); Sat, 18 Feb 2023 21:41:30 -0500 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14A2611EB2; Sat, 18 Feb 2023 18:41:30 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4PK8v92Pnxz4f3jHn; Sun, 19 Feb 2023 10:41:25 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgBH7utQjPFjPmleDw--.7604S19; Sun, 19 Feb 2023 10:41:27 +0800 (CST) From: Kemeng Shi To: paolo.valente@linaro.org, axboe@kernel.dk, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH 17/17] block, bfq: remove unnecessary local variable __bfqq in bfq_setup_merge Date: Sun, 19 Feb 2023 18:43:09 +0800 Message-Id: <20230219104309.1511562-18-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230219104309.1511562-1-shikemeng@huaweicloud.com> References: <20230219104309.1511562-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: Syh0CgBH7utQjPFjPmleDw--.7604S19 X-Coremail-Antispam: 1UD129KBjvdXoW7GFykWr4fKFyruF1xXF47Arb_yoWkGrb_tF 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vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org We could traversal bfqq->new_bfqq list without a local variable easily and intuitively. So remove unnecessary local variable __bfqq. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 2705a24ab146..037f73a25567 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2752,7 +2752,6 @@ static struct bfq_queue * bfq_setup_merge(struct bfq_queue *bfqq, struct bfq_queue *new_bfqq) { int process_refs, new_process_refs; - struct bfq_queue *__bfqq; /* * If there are no process references on the new_bfqq, then it is @@ -2764,10 +2763,9 @@ bfq_setup_merge(struct bfq_queue *bfqq, struct bfq_queue *new_bfqq) return NULL; /* Avoid a circular list and skip interim queue merges. */ - while ((__bfqq = new_bfqq->new_bfqq)) { - if (__bfqq == bfqq) + while ((new_bfqq = new_bfqq->new_bfqq)) { + if (new_bfqq == bfqq) return NULL; - new_bfqq = __bfqq; } process_refs = bfqq_process_refs(bfqq);