From patchwork Tue Nov 8 04:52:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13035860 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 8D619C43217 for ; Tue, 8 Nov 2022 04:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233128AbiKHEwn (ORCPT ); Mon, 7 Nov 2022 23:52:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232984AbiKHEwh (ORCPT ); Mon, 7 Nov 2022 23:52:37 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DDBA1BEB5; Mon, 7 Nov 2022 20:52:31 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N5wgS5XbdzHvmS; Tue, 8 Nov 2022 12:52:04 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 8 Nov 2022 12:52:27 +0800 From: Kemeng Shi To: , CC: , , Subject: [PATCH 01/10] block, bfq: correctly raise inject limit in bfq_choose_bfqq_for_injection Date: Tue, 8 Nov 2022 12:52:15 +0800 Message-ID: <20221108045224.19092-2-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221108045224.19092-1-shikemeng@huawei.com> References: <20221108045224.19092-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Inject limit could be temporarily raised if current inject_limit is 0. raised limit is saved in local variable "limit". The traverse below will reset raised "limit" to bfqd->in_service_queue which is 0 for limit raised condition and will invalidate the raised limit. After passing bfqd->rq_in_driver >= limit check above, we can be sure about two things in traverse: 1. Local variable "limit" is greater than 0 or bfqd->rq_in_driver >= limit check is always met. 2. For normal case (else case for large request to non-rotational drives), no need to check bfqd->rq_in_driver < limit again if local variable "limit" is not changed. Fix this by not overwriting local variable "limit" in traverse. As metioned in first thing above that limit is greater than 0, so result of min_t(unsigned int, 1, limit) is always 1. we can simply check whether rq_in_driver is less than 1 for case of large request to non-rotational drives and remove assignment to local variable "limit" in traverse. As metioned in second thing above, in normal case no futher check is needed if local variable "limit" is not chaged, so return directly in normal case. 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 7ea427817f7f..b0bee8ab65e6 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -4707,12 +4707,10 @@ bfq_choose_bfqq_for_injection(struct bfq_data *bfqd) */ if (blk_queue_nonrot(bfqd->queue) && blk_rq_sectors(bfqq->next_rq) >= - BFQQ_SECT_THR_NONROT) - limit = min_t(unsigned int, 1, limit); - else - limit = in_serv_bfqq->inject_limit; - - if (bfqd->rq_in_driver < limit) { + BFQQ_SECT_THR_NONROT && + bfqd->rq_in_driver >= 1) + continue; + else { bfqd->rqs_injected = true; return bfqq; } From patchwork Tue Nov 8 04:52:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13035861 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 6DE1CC433FE for ; Tue, 8 Nov 2022 04:52:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233173AbiKHEwo (ORCPT ); Mon, 7 Nov 2022 23:52:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233045AbiKHEwh (ORCPT ); Mon, 7 Nov 2022 23:52:37 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3887F1BE9F; Mon, 7 Nov 2022 20:52:31 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N5wgn4djDzRp44; Tue, 8 Nov 2022 12:52:21 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 8 Nov 2022 12:52:28 +0800 From: Kemeng Shi To: , CC: , , Subject: [PATCH 02/10] block, bfq: remove unsed parameter reason in bfq_bfqq_is_slow Date: Tue, 8 Nov 2022 12:52:16 +0800 Message-ID: <20221108045224.19092-3-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221108045224.19092-1-shikemeng@huawei.com> References: <20221108045224.19092-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Parameter reason is never used, just remove it. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index b0bee8ab65e6..fc71181a7e5d 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -4132,8 +4132,7 @@ static void __bfq_bfqq_recalc_budget(struct bfq_data *bfqd, * function to evaluate the I/O speed of a process. */ static bool bfq_bfqq_is_slow(struct bfq_data *bfqd, struct bfq_queue *bfqq, - bool compensate, enum bfqq_expiration reason, - unsigned long *delta_ms) + bool compensate, unsigned long *delta_ms) { ktime_t delta_ktime; u32 delta_usecs; @@ -4329,7 +4328,7 @@ void bfq_bfqq_expire(struct bfq_data *bfqd, /* * Check whether the process is slow (see bfq_bfqq_is_slow). */ - slow = bfq_bfqq_is_slow(bfqd, bfqq, compensate, reason, &delta); + slow = bfq_bfqq_is_slow(bfqd, bfqq, compensate, &delta); /* * As above explained, charge slow (typically seeky) and From patchwork Tue Nov 8 04:52:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13035865 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 831B7C433FE for ; Tue, 8 Nov 2022 04:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233039AbiKHEwr (ORCPT ); Mon, 7 Nov 2022 23:52:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233071AbiKHEwi (ORCPT ); Mon, 7 Nov 2022 23:52:38 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67E221C413; Mon, 7 Nov 2022 20:52:31 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N5wgk1SlFzmVhW; Tue, 8 Nov 2022 12:52:18 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 8 Nov 2022 12:52:29 +0800 From: Kemeng Shi To: , CC: , , Subject: [PATCH 03/10] block, bfq: initialize bfqq->decrease_time_jif correctly Date: Tue, 8 Nov 2022 12:52:17 +0800 Message-ID: <20221108045224.19092-4-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221108045224.19092-1-shikemeng@huawei.com> References: <20221108045224.19092-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Currently, decrease_time_jif is initialized to 0 and will be updated in function bfq_reset_inject_limit and bfq_update_inject_limit while these two functions are called when jiffies pasts decrease_time_jif with some extra time or think-time state changes. If jiffies is slightly larger than MAX_JIFFY_OFFSET, it will take a long time to meet the first condition. The second condition is heavily relies on process behavior. To be more specific: Function bfq_update_inject_limit maybe triggered when jiffies pasts decrease_time_jif + msecs_to_jiffies(10) in bfq_add_request by setting bfqd->wait_dispatch to true. Function bfq_reset_inject_limit are called in two conditions: 1. jiffies pasts bfqq->decrease_time_jif + msecs_to_jiffies(1000) in function bfq_add_request. 2. jiffies pasts bfqq->decrease_time_jif + msecs_to_jiffies(100) or bfq think-time state change from short to long. In worst case that jiffies is slightly larger than MAX_JIFFY_OFFSET and think-time state never changes, the service injection may be not triggered for a long time. Fix this by initializing bfqq->decrease_time_jif to current jiffies to trigger service injection soon when service injection conditions are met. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index fc71181a7e5d..01fa16047eb5 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -5557,6 +5557,8 @@ static void bfq_init_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, /* first request is almost certainly seeky */ bfqq->seek_history = 1; + + bfqq->decrease_time_jif = jiffies; } static struct bfq_queue **bfq_async_queue_prio(struct bfq_data *bfqd, From patchwork Tue Nov 8 04:52:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13035862 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 2352CC43219 for ; Tue, 8 Nov 2022 04:52:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233195AbiKHEwq (ORCPT ); Mon, 7 Nov 2022 23:52:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232967AbiKHEwi (ORCPT ); Mon, 7 Nov 2022 23:52:38 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C7D61C909; Mon, 7 Nov 2022 20:52:32 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N5wgV4YjwzHvfn; Tue, 8 Nov 2022 12:52:06 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 8 Nov 2022 12:52:29 +0800 From: Kemeng Shi To: , CC: , , Subject: [PATCH 04/10] block, bfq: use helper macro RQ_BFQQ to get bfqq of request Date: Tue, 8 Nov 2022 12:52:18 +0800 Message-ID: <20221108045224.19092-5-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221108045224.19092-1-shikemeng@huawei.com> References: <20221108045224.19092-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use helper macro RQ_BFQQ to get bfqq of request. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 01fa16047eb5..2c4fe286ead7 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -6748,14 +6748,14 @@ static struct bfq_queue *bfq_init_rq(struct request *rq) return NULL; /* - * Assuming that elv.priv[1] is set only if everything is set + * Assuming that RQ_BFQQ(rq) is set only if everything is set * for this rq. This holds true, because this function is * invoked only for insertion or merging, and, after such * events, a request cannot be manipulated any longer before * being removed from bfq. */ - if (rq->elv.priv[1]) - return rq->elv.priv[1]; + if (RQ_BFQQ(rq)) + return RQ_BFQQ(rq); bic = icq_to_bic(rq->elv.icq); From patchwork Tue Nov 8 04:52:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13035864 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 64423C4332F for ; Tue, 8 Nov 2022 04:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233219AbiKHEwt (ORCPT ); Mon, 7 Nov 2022 23:52:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233074AbiKHEwj (ORCPT ); Mon, 7 Nov 2022 23:52:39 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95F492ED7A; Mon, 7 Nov 2022 20:52:32 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N5wgq3Y4dzRp5C; Tue, 8 Nov 2022 12:52:23 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 8 Nov 2022 12:52:30 +0800 From: Kemeng Shi To: , CC: , , Subject: [PATCH 05/10] block, bfq: remove unnecessary pointer reference to get async_bfqq Date: Tue, 8 Nov 2022 12:52:19 +0800 Message-ID: <20221108045224.19092-6-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221108045224.19092-1-shikemeng@huawei.com> References: <20221108045224.19092-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The async_bfqq is assigned with bfqq->bic->bfqq[0], use it directly. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 2c4fe286ead7..aad88ca5e5a5 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -4901,7 +4901,7 @@ static struct bfq_queue *bfq_select_queue(struct bfq_data *bfqd) icq_to_bic(async_bfqq->next_rq->elv.icq) == bfqq->bic && bfq_serv_to_charge(async_bfqq->next_rq, async_bfqq) <= bfq_bfqq_budget_left(async_bfqq)) - bfqq = bfqq->bic->bfqq[0]; + bfqq = async_bfqq; else if (bfqq->waker_bfqq && bfq_bfqq_busy(bfqq->waker_bfqq) && bfqq->waker_bfqq->next_rq && From patchwork Tue Nov 8 04:52:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13035863 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 73839C43217 for ; Tue, 8 Nov 2022 04:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232494AbiKHEwu (ORCPT ); Mon, 7 Nov 2022 23:52:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233035AbiKHEwl (ORCPT ); Mon, 7 Nov 2022 23:52:41 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3783E2F028; Mon, 7 Nov 2022 20:52:33 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N5wgW63ZjzHvms; Tue, 8 Nov 2022 12:52:07 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 8 Nov 2022 12:52:31 +0800 From: Kemeng Shi To: , CC: , , Subject: [PATCH 06/10] block, bfq: remove redundant bfqd->rq_in_driver > 0 check in bfq_add_request Date: Tue, 8 Nov 2022 12:52:20 +0800 Message-ID: <20221108045224.19092-7-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221108045224.19092-1-shikemeng@huawei.com> References: <20221108045224.19092-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The bfqd->rq_in_driver > 0 check is along with previous "bfqd->rq_in_driver == 0 ||" check, so no need to re-check bfqd->rq_in_driver > 0. 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 aad88ca5e5a5..be923be48647 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2254,8 +2254,7 @@ static void bfq_add_request(struct request *rq) */ if (bfqq == bfqd->in_service_queue && (bfqd->rq_in_driver == 0 || - (bfqq->last_serv_time_ns > 0 && - bfqd->rqs_injected && bfqd->rq_in_driver > 0)) && + (bfqq->last_serv_time_ns > 0 && bfqd->rqs_injected)) && time_is_before_eq_jiffies(bfqq->decrease_time_jif + msecs_to_jiffies(10))) { bfqd->last_empty_occupied_ns = ktime_get_ns(); From patchwork Tue Nov 8 04:52:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13035866 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 025F6C433FE for ; Tue, 8 Nov 2022 04:52:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233253AbiKHEw4 (ORCPT ); Mon, 7 Nov 2022 23:52:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233098AbiKHEwm (ORCPT ); Mon, 7 Nov 2022 23:52:42 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE4D8326DE; Mon, 7 Nov 2022 20:52:33 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N5wbm6s1szpWBX; Tue, 8 Nov 2022 12:48:52 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 8 Nov 2022 12:52:31 +0800 From: Kemeng Shi To: , CC: , , Subject: [PATCH 07/10] block, bfq: remove redundant check in bfq_put_cooperator Date: Tue, 8 Nov 2022 12:52:21 +0800 Message-ID: <20221108045224.19092-8-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221108045224.19092-1-shikemeng@huawei.com> References: <20221108045224.19092-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org We have already avoided a circular list in bfq_setup_merge (see comments in bfq_setup_merge() for details), so bfq_queue will not appear in it's new_bfqq list. Just remove this check. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index be923be48647..cffc5ff66ee6 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -5339,8 +5339,6 @@ void bfq_put_cooperator(struct bfq_queue *bfqq) */ __bfqq = bfqq->new_bfqq; while (__bfqq) { - if (__bfqq == bfqq) - break; next = __bfqq->new_bfqq; bfq_put_queue(__bfqq); __bfqq = next; From patchwork Tue Nov 8 04:52:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13035867 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 4EE5CC433FE for ; Tue, 8 Nov 2022 04:53:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233314AbiKHExS (ORCPT ); Mon, 7 Nov 2022 23:53:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233135AbiKHEwn (ORCPT ); Mon, 7 Nov 2022 23:52:43 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76D8B326E2; Mon, 7 Nov 2022 20:52:34 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4N5wgp0BfMz15MSb; Tue, 8 Nov 2022 12:52:22 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 8 Nov 2022 12:52:32 +0800 From: Kemeng Shi To: , CC: , , Subject: [PATCH 08/10] block, bfq: remove unnecessary goto tag in bfq_dispatch_rq_from_bfqq Date: Tue, 8 Nov 2022 12:52:22 +0800 Message-ID: <20221108045224.19092-9-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221108045224.19092-1-shikemeng@huawei.com> References: <20221108045224.19092-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org We jump to tag only for returning current rq. Return directly to remove this tag. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index cffc5ff66ee6..64c1249d8eda 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -5031,7 +5031,7 @@ static struct request *bfq_dispatch_rq_from_bfqq(struct bfq_data *bfqd, bfq_dispatch_remove(bfqd->queue, rq); if (bfqq != bfqd->in_service_queue) - goto return_rq; + return rq; /* * If weight raising has to terminate for bfqq, then next @@ -5051,12 +5051,9 @@ static struct request *bfq_dispatch_rq_from_bfqq(struct bfq_data *bfqd, * belongs to CLASS_IDLE and other queues are waiting for * service. */ - if (!(bfq_tot_busy_queues(bfqd) > 1 && bfq_class_idle(bfqq))) - goto return_rq; + if ((bfq_tot_busy_queues(bfqd) > 1 && bfq_class_idle(bfqq))) + bfq_bfqq_expire(bfqd, bfqq, false, BFQQE_BUDGET_EXHAUSTED); - bfq_bfqq_expire(bfqd, bfqq, false, BFQQE_BUDGET_EXHAUSTED); - -return_rq: return rq; } From patchwork Tue Nov 8 04:52:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13035868 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 05547C4332F for ; Tue, 8 Nov 2022 04:53:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233328AbiKHExU (ORCPT ); Mon, 7 Nov 2022 23:53:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233140AbiKHEwn (ORCPT ); Mon, 7 Nov 2022 23:52:43 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A5121B1F2; Mon, 7 Nov 2022 20:52:35 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N5wgs6vr6zRp5b; Tue, 8 Nov 2022 12:52:25 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 8 Nov 2022 12:52:32 +0800 From: Kemeng Shi To: , CC: , , Subject: [PATCH 09/10] block, bfq: remove unused bfq_wr_max_time in struct bfq_data Date: Tue, 8 Nov 2022 12:52:23 +0800 Message-ID: <20221108045224.19092-10-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221108045224.19092-1-shikemeng@huawei.com> References: <20221108045224.19092-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org bfqd->bfq_wr_max_time is set to 0 in bfq_init_queue and is never changed. It is only used in bfq_wr_duration when bfq_wr_max_time > 0 which never meets, so bfqd->bfq_wr_max_time is not used actually. Just remove it. Signed-off-by: Kemeng Shi --- block/bfq-iosched.c | 4 ---- block/bfq-iosched.h | 2 -- 2 files changed, 6 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 64c1249d8eda..40ac219b2d8f 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1120,9 +1120,6 @@ static unsigned int bfq_wr_duration(struct bfq_data *bfqd) { u64 dur; - if (bfqd->bfq_wr_max_time > 0) - return bfqd->bfq_wr_max_time; - dur = bfqd->rate_dur_prod; do_div(dur, bfqd->peak_rate); @@ -7138,7 +7135,6 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) */ bfqd->bfq_wr_coeff = 30; bfqd->bfq_wr_rt_max_time = msecs_to_jiffies(300); - bfqd->bfq_wr_max_time = 0; bfqd->bfq_wr_min_idle_time = msecs_to_jiffies(2000); bfqd->bfq_wr_min_inter_arr_async = msecs_to_jiffies(500); bfqd->bfq_wr_max_softrt_rate = 7000; /* diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 71f721670ab6..48c147e5f9e0 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -719,8 +719,6 @@ struct bfq_data { * is multiplied. */ unsigned int bfq_wr_coeff; - /* maximum duration of a weight-raising period (jiffies) */ - unsigned int bfq_wr_max_time; /* Maximum weight-raising duration for soft real-time processes */ unsigned int bfq_wr_rt_max_time; From patchwork Tue Nov 8 04:52:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13035869 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 BF408C4332F for ; Tue, 8 Nov 2022 04:53:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233335AbiKHExV (ORCPT ); Mon, 7 Nov 2022 23:53:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233175AbiKHEwo (ORCPT ); Mon, 7 Nov 2022 23:52:44 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1889F326F9; Mon, 7 Nov 2022 20:52:36 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N5wcZ1b8DzJnVD; Tue, 8 Nov 2022 12:49:34 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 8 Nov 2022 12:52:33 +0800 From: Kemeng Shi To: , CC: , , Subject: [PATCH 10/10] block, bfq: remove check of bfq_wr_max_softrt_rate which is always greater than 0 Date: Tue, 8 Nov 2022 12:52:24 +0800 Message-ID: <20221108045224.19092-11-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221108045224.19092-1-shikemeng@huawei.com> References: <20221108045224.19092-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org bfqd->bfq_wr_max_softrt_rate is assigned with 7000 in bfq_init_queue and never changed. So we can remove bfqd->bfq_wr_max_softrt_rate > 0 check which is always true. 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 40ac219b2d8f..d0a867b2569b 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1840,8 +1840,7 @@ static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, * 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) && + soft_rt = !BFQQ_TOTALLY_SEEKY(bfqq) && !in_burst && time_is_before_jiffies(bfqq->soft_rt_next_start) && bfqq->dispatched == 0 && @@ -4350,8 +4349,7 @@ void bfq_bfqq_expire(struct bfq_data *bfqd, if (bfqd->low_latency && bfqq->wr_coeff == 1) bfqq->last_wr_start_finish = jiffies; - if (bfqd->low_latency && bfqd->bfq_wr_max_softrt_rate > 0 && - RB_EMPTY_ROOT(&bfqq->sort_list)) { + if (bfqd->low_latency && RB_EMPTY_ROOT(&bfqq->sort_list)) { /* * If we get here, and there are no outstanding * requests, then the request pattern is isochronous