From patchwork Tue Apr 20 11:20:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brookxu.cn" X-Patchwork-Id: 12213791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96524C433B4 for ; Tue, 20 Apr 2021 11:20:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E3BC613B2 for ; Tue, 20 Apr 2021 11:20:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231423AbhDTLVC (ORCPT ); Tue, 20 Apr 2021 07:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231660AbhDTLVA (ORCPT ); Tue, 20 Apr 2021 07:21:00 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72459C06138A; Tue, 20 Apr 2021 04:20:29 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id v13so5905949ple.9; Tue, 20 Apr 2021 04:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=k7foMZZRtisGPq+uUebUl4zeTE385Qk+YuiaUy6ZRfU=; b=D2nrbqQXFOAlluD1rWc2pfvpP1MJP3G6tlvBCQbJhv7F1+eV5k8to7bL1cVMMed2Gv stpC6/tKQG1vfxYRV3jwhi534xyJY8vY7wXJmIORtuj0Y18a512UXYeoFz2ljPLVk0Y+ H6YRwe5GfrkEO/wLu3avPYzuufGPPgSAk8E6CtcNM6yl/4cCDywBceM7Kwtlfaty5vRV VFj+vZiTK3aw4Ca7uS6F72ZshzYi7IigBpN7NfwZ2kYcuWMKIEZXxFzgM9TJE3TYLfA5 7MlgVhSGw5dPGo0IJAjuDBal2uzzfzmSVNfeG/ZCtudiFVaWKXS1XNKHgSQi5yhkPDX8 tRcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=k7foMZZRtisGPq+uUebUl4zeTE385Qk+YuiaUy6ZRfU=; b=M/uqVCWe0Gg0ZnlEtupM9P6nDgdyiJbMIL7VHJebuVS+BQ2bCxlABiMbwRD9ki9q8X EmO3xSxO4S7CKJUOKrwZDEr1lxQrKZ3knVRV4m9p0Dc+l6maobITofp9F200K9ExUhF8 p3qcGft9kpY1nR8mQbqOADMRx39lxsQH1BJz0INgIqkfSSlz+TQH96zN9/p/FtcL+z4w m6FOHDtlgbGFdHfXQjxo4ORABtTgwh29MoV6UU8opE7AiMHvtcpQ1+S+4Bf2bWzvPkVK jPxMw9ttkifroC9KEgpR8ISBlB7xwx+J+VC7DEX5YZpKg9QJO3Va0PHbN68lcdaW8jif dXPA== X-Gm-Message-State: AOAM532A0vLFxdyXD1u5rnBKiJQPfMBdZhk4I5Td17zeAH4kdpl+eZRR wD2FoNVWPySYG865D9/rnk0= X-Google-Smtp-Source: ABdhPJxZNhoIPNDlDI7FoU69B1Xr9dXt5bHcXFunC4cDlh+IjfVASzfH1Ewj8o6B9/Yq+KAkEIjuKw== X-Received: by 2002:a17:90b:1d88:: with SMTP id pf8mr4444598pjb.114.1618917629065; Tue, 20 Apr 2021 04:20:29 -0700 (PDT) Received: from VM-0-3-centos.localdomain ([101.32.213.191]) by smtp.gmail.com with ESMTPSA id s40sm14187367pfw.100.2021.04.20.04.20.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Apr 2021 04:20:28 -0700 (PDT) From: brookxu To: paolo.valente@linaro.org, axboe@kernel.dk, tj@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] bfq: introduce bfq_entity_to_bfqg helper method Date: Tue, 20 Apr 2021 19:20:18 +0800 Message-Id: <1ce935f1bb10e0c7ecea7b79b826ff4cfc89acf0.1618916839.git.brookxu@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chunguang Xu Introduce bfq_entity_to_bfqg() to make it easier to obtain the bfq_group corresponding to the entity. Signed-off-by: Chunguang Xu --- block/bfq-cgroup.c | 6 ++---- block/bfq-iosched.h | 1 + block/bfq-wf2q.c | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index b791e20..a5f544a 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -309,8 +309,7 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq) { struct bfq_entity *group_entity = bfqq->entity.parent; - return group_entity ? container_of(group_entity, struct bfq_group, - entity) : + return group_entity ? bfq_entity_to_bfqg(group_entity) : bfqq->bfqd->root_group; } @@ -610,8 +609,7 @@ struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd, */ entity = &bfqg->entity; for_each_entity(entity) { - struct bfq_group *curr_bfqg = container_of(entity, - struct bfq_group, entity); + struct bfq_group *curr_bfqg = bfq_entity_to_bfqg(entity); if (curr_bfqg != bfqd->root_group) { parent = bfqg_parent(curr_bfqg); if (!parent) diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index b8e793c..a6f98e9 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -941,6 +941,7 @@ struct bfq_group { #endif struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity); +struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity); /* --------------- main algorithm interface ----------------- */ diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 070e34a..5ff0028 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -149,7 +149,7 @@ struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq) if (!group_entity) group_entity = &bfqq->bfqd->root_group->entity; - return container_of(group_entity, struct bfq_group, entity); + return bfq_entity_to_bfqg(group_entity); } /* @@ -208,7 +208,7 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity) if (bfq_entity_to_bfqq(entity)) return true; - bfqg = container_of(entity, struct bfq_group, entity); + bfqg = bfq_entity_to_bfqg(entity); /* * The field active_entities does not always contain the @@ -266,6 +266,15 @@ struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity) return bfqq; } +struct bfq_group *bfq_entity_to_bfqg(struct bfq_entity *entity) +{ + struct bfq_group *bfqg = NULL; + + if (entity->my_sched_data) + bfqg = container_of(entity, struct bfq_group, entity); + + return bfqg; +} /** * bfq_delta - map service into the virtual time domain. @@ -1001,8 +1010,7 @@ static void __bfq_activate_entity(struct bfq_entity *entity, #ifdef CONFIG_BFQ_GROUP_IOSCHED if (!bfq_entity_to_bfqq(entity)) { /* bfq_group */ - struct bfq_group *bfqg = - container_of(entity, struct bfq_group, entity); + struct bfq_group *bfqg = bfq_entity_to_bfqg(entity); struct bfq_data *bfqd = bfqg->bfqd; if (!entity->in_groups_with_pending_reqs) { From patchwork Tue Apr 20 11:20:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brookxu.cn" X-Patchwork-Id: 12213795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 330CEC43460 for ; Tue, 20 Apr 2021 11:20:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC6E6613B2 for ; Tue, 20 Apr 2021 11:20:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231697AbhDTLVD (ORCPT ); Tue, 20 Apr 2021 07:21:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231640AbhDTLVC (ORCPT ); Tue, 20 Apr 2021 07:21:02 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F27BDC06174A; Tue, 20 Apr 2021 04:20:30 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id s22so5278499pgk.6; Tue, 20 Apr 2021 04:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=YXgpUa5T67Dw4AbYp5KoLO/kJdOhq1vLhGhKXZoWFNo=; b=GH2ig0nsuG2U8HvPMZwr/S/7fAM3RXR2E8yKMIVYIS6H//pgKckhhyRnJbUZtA7npX +4ZYf9kuSOURwDBg8pHfdLAwsYsmYm5Omn8H5QkK1DBC0dMYnkynPRMm2GiP2ElZ4a4T bauu/+3iRKL/TUA2YvR0wrAYzKK+PtpCkP12OvgNUdpFeUMk6EEnMyq0lpN2cMgI3dNV eV/RUofQUzJWz1dBSyLoREKm7feWgDLcQDuJwDN5cvdA64pWPA0FDVtyMV0rOe7wSb1c k9SkLpSzGvhCopB3w/8fkf27Q/aUL2WjsIe22EGczBPVlWazTOSbljtobrN609Xr8d+L 7oLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=YXgpUa5T67Dw4AbYp5KoLO/kJdOhq1vLhGhKXZoWFNo=; b=VnDQiDkFlJUYhTvXH9IceMaAB5ULgvIOTTJJvJcKQCDDTr77Q0jYZErz+Bro1WnDVR TFb0Uxp7roQcR79ao8EvefsbnMcdnM1Re2/gswdOztpGEcZXbQik5ZC41RDuUYqFeued Ox22HFmsXwP2fRmyXjEIInQRUt/o9TS/oUaHzjgfH29rlmEzp6va/SL53B7UFrL2oBXJ +XQzWhLFLU66fLXqwosoVlkf009r5yGAEE5fHcbTHc/36CDYTfpfSPoM82rWdb+NCBCO PuLtiqqkRyWIVyidGHmMQiQSyjcawxuT5DZ55E6FnQ+T8417YgEJUZsR5iOrSYw7vQHn D9qg== X-Gm-Message-State: AOAM5327I+zClUpmLUtUczTEdoxbAWDjGxgdGHwC0QmB996/TmPPB5NA HO4HR9xXUOPZMb1Ol7GqFC8= X-Google-Smtp-Source: ABdhPJwt6Wgtq/z5Y+kkE8MHl4OYvdLw4esQyiSJKo2RUVeQvs6dKU94anOaBlgSRcb/bxks0ZU/5g== X-Received: by 2002:a63:f40b:: with SMTP id g11mr16922042pgi.133.1618917630632; Tue, 20 Apr 2021 04:20:30 -0700 (PDT) Received: from VM-0-3-centos.localdomain ([101.32.213.191]) by smtp.gmail.com with ESMTPSA id s40sm14187367pfw.100.2021.04.20.04.20.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Apr 2021 04:20:30 -0700 (PDT) From: brookxu To: paolo.valente@linaro.org, axboe@kernel.dk, tj@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] bfq: convert the type of bfq_group.bfqd to bfq_data* Date: Tue, 20 Apr 2021 19:20:19 +0800 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chunguang Xu Setting bfq_group.bfqd to void* type does not seem to make much sense. This will cause unnecessary type conversion. Perhaps it would be better to change it to bfq_data* type. Signed-off-by: Chunguang Xu --- block/bfq-cgroup.c | 2 +- block/bfq-iosched.h | 2 +- block/bfq-wf2q.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index a5f544a..50d06c7 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -224,7 +224,7 @@ void bfqg_stats_update_io_add(struct bfq_group *bfqg, struct bfq_queue *bfqq, { blkg_rwstat_add(&bfqg->stats.queued, op, 1); bfqg_stats_end_empty_time(&bfqg->stats); - if (!(bfqq == ((struct bfq_data *)bfqg->bfqd)->in_service_queue)) + if (!(bfqq == bfqg->bfqd->in_service_queue)) bfqg_stats_set_start_group_wait_time(bfqg, bfqq_group(bfqq)); } diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index a6f98e9..28d8590 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -914,7 +914,7 @@ struct bfq_group { struct bfq_entity entity; struct bfq_sched_data sched_data; - void *bfqd; + struct bfq_data *bfqd; struct bfq_queue *async_bfqq[2][IOPRIO_BE_NR]; struct bfq_queue *async_idle_bfqq; diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 5ff0028..276f225 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -498,7 +498,7 @@ static void bfq_active_insert(struct bfq_service_tree *st, #ifdef CONFIG_BFQ_GROUP_IOSCHED sd = entity->sched_data; bfqg = container_of(sd, struct bfq_group, sched_data); - bfqd = (struct bfq_data *)bfqg->bfqd; + bfqd = bfqg->bfqd; #endif if (bfqq) list_add(&bfqq->bfqq_list, &bfqq->bfqd->active_list); @@ -597,7 +597,7 @@ static void bfq_active_extract(struct bfq_service_tree *st, #ifdef CONFIG_BFQ_GROUP_IOSCHED sd = entity->sched_data; bfqg = container_of(sd, struct bfq_group, sched_data); - bfqd = (struct bfq_data *)bfqg->bfqd; + bfqd = bfqg->bfqd; #endif if (bfqq) list_del(&bfqq->bfqq_list); @@ -743,7 +743,7 @@ struct bfq_service_tree * else { sd = entity->my_sched_data; bfqg = container_of(sd, struct bfq_group, sched_data); - bfqd = (struct bfq_data *)bfqg->bfqd; + bfqd = bfqg->bfqd; } #endif From patchwork Tue Apr 20 11:20:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brookxu.cn" X-Patchwork-Id: 12213797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E29B1C433ED for ; Tue, 20 Apr 2021 11:20:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF084613AF for ; Tue, 20 Apr 2021 11:20:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231804AbhDTLVI (ORCPT ); Tue, 20 Apr 2021 07:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231709AbhDTLVD (ORCPT ); Tue, 20 Apr 2021 07:21:03 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64685C06138A; Tue, 20 Apr 2021 04:20:32 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id i190so25313942pfc.12; Tue, 20 Apr 2021 04:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=GxLL6QnmEPTEzqADHSi/TrcJeIj4iMdkXLkWOx3ig7I=; b=f/GxmF//G+P7rb8pmjQBa4IVXX0FDe7U0Qpf6CzuPTbnlj8W6de+iMKco88AZrpQYG Ebnz0w00K96fChD1IQvQO4mkrz3MXU8MkwkQPaq/5lBRTPaxlsN5cvUlJYTpSB399BO5 ksZqBfyuw0pnJF0dLMnQESNcMiMNg39jcqSn2BvYPz0mr6m3ChwPWwMSiYXRQT1wpY13 gV5wzhhXOGgyscDj+H+UMNUkp/EDMPIgIdFvBKD6TtmxLLalLvAn/7kmumhhVDVgcCh7 UQgQtCD2aiOxUC/KNxlPOfTi/ZsTVZY+I7qmR2GMSEv3vkWkXlHQ3gMONXUl4eP5SOgM e42Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=GxLL6QnmEPTEzqADHSi/TrcJeIj4iMdkXLkWOx3ig7I=; b=nEiKJ6tvy4+3Xz9c93w7M6bZ0YlutdyGdHYjxZFnrb29YYLK8iGy4DY2/EOZBqpXA6 DTXt5mu5heamQTKMNHlpJflQ1qVLwUtmbzxWa/KlqDptrNnE1u0KDcYAjAXNcFFc98tF AliSY3EJDJI6c9UD3//n1Ut6H5jXo5/acufw25xc1gtEaM5sG45aORKvfJLhbH/AlFnX jyYnriOvA8bvL8UQrYrJ5R8OcbEMQtclkdBg2Hq5GyuXgqwZPeOl3HiKEk67IZCnpRvC CF92w191/ig89E/yrstHveifvidXzt8au7dj8K1jSq/FWYdfkMSq1MjEw3d7UYgGQVJJ rwFQ== X-Gm-Message-State: AOAM533WkjSgNqdnbACobkBxzTHYJmxIJnJofocrnjuKZCgM0y1RVdxm DCeJRx8t54i5fjr77DMvSt0= X-Google-Smtp-Source: ABdhPJyELyDhtylazbXz3zPw0msDvBjeWFZFvOQwjzR7F9AVpxWdDuI5ZBq2fwR1DM2L1ddT3f46Hg== X-Received: by 2002:a65:4d4c:: with SMTP id j12mr16127000pgt.346.1618917632065; Tue, 20 Apr 2021 04:20:32 -0700 (PDT) Received: from VM-0-3-centos.localdomain ([101.32.213.191]) by smtp.gmail.com with ESMTPSA id s40sm14187367pfw.100.2021.04.20.04.20.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Apr 2021 04:20:31 -0700 (PDT) From: brookxu To: paolo.valente@linaro.org, axboe@kernel.dk, tj@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] bfq: limit the IO depth of CLASS_IDLE to 1 Date: Tue, 20 Apr 2021 19:20:20 +0800 Message-Id: <34edd545a9f6f6b327fc6779fbd17fd3a519ed4c.1618916839.git.brookxu@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chunguang Xu The IO depth of queues belong to CLASS_IDLE is limited to 1, so that it can avoid introducing a larger tail latency under a device with a larger IO depth. Although limiting the IO depth may reduce the performance of idle_class, it is generally not a big problem, because idle_class usually does not have strict performance requirements. Signed-off-by: Chunguang Xu --- block/bfq-iosched.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index ec482e6..29940ec 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -4808,6 +4808,17 @@ static struct request *__bfq_dispatch_request(struct blk_mq_hw_ctx *hctx) if (!bfqq) goto exit; + /* + * Here, the IO depth of queues belong to CLASS_IDLE is limited + * to 1, so that it can avoid introducing a larger tail latency + * under a device with a larger IO depth. Although limiting the + * IO depth may reduce the performance of idle_class, it is + * generally not a big problem, because idle_class usually + * does not have strict performance requirements. + */ + if (bfq_class_idle(bfqq) && bfqq->dispatched) + goto exit; + rq = bfq_dispatch_rq_from_bfqq(bfqd, bfqq); if (rq) { From patchwork Tue Apr 20 11:20:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brookxu.cn" X-Patchwork-Id: 12213801 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76952C43461 for ; Tue, 20 Apr 2021 11:20:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40BFE613AF for ; Tue, 20 Apr 2021 11:20:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231810AbhDTLVI (ORCPT ); Tue, 20 Apr 2021 07:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231749AbhDTLVG (ORCPT ); Tue, 20 Apr 2021 07:21:06 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B088C06174A; Tue, 20 Apr 2021 04:20:34 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id b17so26385731pgh.7; Tue, 20 Apr 2021 04:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=W7KHjr39fzmJQi9Zt2knXhik0hSaJoZniPst+hezF7A=; b=pXt/uZII9z+7uXstbIUjfVXNrD30zz4nBJP7rCLOVoMCmcvScgZlqVqQ4Na9p3r5Ko TsWRNykOJPMzbD1K9Hs3FhQHhn9u0A3UUADANdTlAPZ+d8xZvM1WgEsfCPcwBXRgXueB IaNwbmQrXKNOfIJe+wwNmo3xp3rIl8FirTGMkDneQcunLuHY9s40SJ0F9l9mLblZYTWb HbQOxgZay0x0+pOCk/rqA4NqmZi9mcfwSnqsnmYErHHj3PezNt9xUSJNazlSdZxrD48G kEfhHY/cTDlyGzgzinodps0MvOZRrZKaHK2GOk1+oJXwQfEa0Lt/uvtG6spGXod9c0Nn OOrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=W7KHjr39fzmJQi9Zt2knXhik0hSaJoZniPst+hezF7A=; b=JGEoaTXXPidUw+QQbdYxiT1x9yiK2OPTjG3TmyzX7+QmRjjElIQ+EZkOwKaPxIeefl E9nmE1tyHTmVJGmPr0wjR4/5OASoAyjaAAfvkOGtpeZuAsZpBlDSyvOMEhAhtYzNYhDi l8NqrKF2doSBt/JmrWVdEFN4he/SOilu6c29evjFt4SckbpXoyKsz+/su1YDSQtzGEdl pIq2+fDxZicLjB+NtLcLGm7OO5QUct5eYptErbZh/ac1aqxqfKVL3ePZGxixgGssobnG kn2M2A6l+66a/ZYQ/mkmXIEcQByYVW5qfI/a8f9uXFORSdgI7wouleW+chG7QD6LGH41 SMbA== X-Gm-Message-State: AOAM532rOeNQ1lIGVRKR1UEPZDEuPAt1JXxPn885JNN8vgIzAecHK59d sH+oxuIB7+MqxMo9iyR/6f4= X-Google-Smtp-Source: ABdhPJyHa0dUDC5Q8QhNMbkBKKe7e7D36fT9U87newfq0vrTeLzGMi86avVClnVwtrNxJ9iVUMKxDg== X-Received: by 2002:a63:e13:: with SMTP id d19mr10434472pgl.36.1618917633780; Tue, 20 Apr 2021 04:20:33 -0700 (PDT) Received: from VM-0-3-centos.localdomain ([101.32.213.191]) by smtp.gmail.com with ESMTPSA id s40sm14187367pfw.100.2021.04.20.04.20.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Apr 2021 04:20:33 -0700 (PDT) From: brookxu To: paolo.valente@linaro.org, axboe@kernel.dk, tj@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/8] bfq: keep the minimun bandwidth for CLASS_BE Date: Tue, 20 Apr 2021 19:20:21 +0800 Message-Id: <49f0e733ab19bee96fce0bdd205366a5b0d3b51e.1618916839.git.brookxu@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chunguang Xu CLASS_RT will preempt other classes, which may starve. At present, CLASS_IDLE has alleviated the starvation problem through the minimum bandwidth mechanism. Similarly, we should do the same for CLASS_BE. Signed-off-by: Chunguang Xu --- block/bfq-iosched.c | 6 ++++-- block/bfq-iosched.h | 11 ++++++---- block/bfq-wf2q.c | 59 ++++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 53 insertions(+), 23 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 29940ec..89d4646 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -6537,9 +6537,11 @@ static void bfq_init_root_group(struct bfq_group *root_group, root_group->bfqd = bfqd; #endif root_group->rq_pos_tree = RB_ROOT; - for (i = 0; i < BFQ_IOPRIO_CLASSES; i++) + for (i = 0; i < BFQ_IOPRIO_CLASSES; i++) { root_group->sched_data.service_tree[i] = BFQ_SERVICE_TREE_INIT; - root_group->sched_data.bfq_class_idle_last_service = jiffies; + root_group->sched_data.bfq_class_last_service[i] = jiffies; + } + root_group->sched_data.class_timeout_last_check = jiffies; } static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 28d8590..da636a8 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -13,7 +13,7 @@ #include "blk-cgroup-rwstat.h" #define BFQ_IOPRIO_CLASSES 3 -#define BFQ_CL_IDLE_TIMEOUT (HZ/5) +#define BFQ_CLASS_TIMEOUT (HZ/5) #define BFQ_MIN_WEIGHT 1 #define BFQ_MAX_WEIGHT 1000 @@ -97,9 +97,12 @@ struct bfq_sched_data { struct bfq_entity *next_in_service; /* array of service trees, one per ioprio_class */ struct bfq_service_tree service_tree[BFQ_IOPRIO_CLASSES]; - /* last time CLASS_IDLE was served */ - unsigned long bfq_class_idle_last_service; - + /* last time the class was served */ + unsigned long bfq_class_last_service[BFQ_IOPRIO_CLASSES]; + /* last time class timeout was checked */ + unsigned long class_timeout_last_check; + /* next index to check class timeout */ + unsigned int next_class_index; }; /** diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 276f225..619ed21 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -1168,6 +1168,7 @@ bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree) { struct bfq_sched_data *sd = entity->sched_data; struct bfq_service_tree *st; + int idx = bfq_class_idx(entity); bool is_in_service; if (!entity->on_st_or_in_serv) /* @@ -1207,6 +1208,7 @@ bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree) else bfq_idle_insert(st, entity); + sd->bfq_class_last_service[idx] = jiffies; return true; } @@ -1435,6 +1437,45 @@ static struct bfq_entity *bfq_first_active_entity(struct bfq_service_tree *st, return entity; } +static int bfq_select_next_class(struct bfq_sched_data *sd) +{ + struct bfq_service_tree *st = sd->service_tree; + unsigned long last_check, last_serve; + int i, class_idx, next_class = 0; + bool found = false; + + /* + * we needed to guarantee a minimum bandwidth for each class (if + * there is some active entity in this class). This should also + * mitigate priority-inversion problems in case a low priority + * task is holding file system resources. + */ + last_check = sd->class_timeout_last_check; + if (time_is_after_jiffies(last_check + BFQ_CLASS_TIMEOUT)) + return next_class; + + sd->class_timeout_last_check = jiffies; + for (i = 0; i < BFQ_IOPRIO_CLASSES; i++) { + class_idx = (sd->next_class_index + i) % BFQ_IOPRIO_CLASSES; + last_serve = sd->bfq_class_last_service[class_idx]; + + if (time_is_after_jiffies(last_serve + BFQ_CLASS_TIMEOUT)) + continue; + + if (!RB_EMPTY_ROOT(&(st + class_idx)->active)) { + if (found) + continue; + + next_class = class_idx++; + class_idx %= BFQ_IOPRIO_CLASSES; + sd->next_class_index = class_idx; + found = true; + } + sd->bfq_class_last_service[class_idx] = jiffies; + } + return next_class; +} + /** * bfq_lookup_next_entity - return the first eligible entity in @sd. * @sd: the sched_data. @@ -1448,24 +1489,8 @@ static struct bfq_entity *bfq_lookup_next_entity(struct bfq_sched_data *sd, bool expiration) { struct bfq_service_tree *st = sd->service_tree; - struct bfq_service_tree *idle_class_st = st + (BFQ_IOPRIO_CLASSES - 1); struct bfq_entity *entity = NULL; - int class_idx = 0; - - /* - * Choose from idle class, if needed to guarantee a minimum - * bandwidth to this class (and if there is some active entity - * in idle class). This should also mitigate - * priority-inversion problems in case a low priority task is - * holding file system resources. - */ - if (time_is_before_jiffies(sd->bfq_class_idle_last_service + - BFQ_CL_IDLE_TIMEOUT)) { - if (!RB_EMPTY_ROOT(&idle_class_st->active)) - class_idx = BFQ_IOPRIO_CLASSES - 1; - /* About to be served if backlogged, or not yet backlogged */ - sd->bfq_class_idle_last_service = jiffies; - } + int class_idx = bfq_select_next_class(sd); /* * Find the next entity to serve for the highest-priority From patchwork Tue Apr 20 11:20:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brookxu.cn" X-Patchwork-Id: 12213803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C575EC43462 for ; Tue, 20 Apr 2021 11:20:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F0716139A for ; Tue, 20 Apr 2021 11:20:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231855AbhDTLVK (ORCPT ); Tue, 20 Apr 2021 07:21:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231811AbhDTLVI (ORCPT ); Tue, 20 Apr 2021 07:21:08 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88D34C06138A; Tue, 20 Apr 2021 04:20:35 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id lr7so3519780pjb.2; Tue, 20 Apr 2021 04:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=wHtH4uowNcGLatA4FtFRbjnON3Vo2NBBY5rs+rY1XYM=; b=c4/sSzQKcasmJkJFn4h93qpMW9dQmHFZ7rEnFMeO/cWgHkP/NKVhBySiwfSEEV2h2i SK5MMPJeJpi1qn2almMXadtczC26Q87pnBvU37VYCMbw4W0AYEI9jBE719Dettio+HQ6 seeW5eKU/He3sCV5m6pDsakF3+TDBLjSAHV2/F3Pc1+X+X8Q85HE3WTPoJVF1NbphZss bzMe0tQniY8bUcVw1a+uWbmWZRn1pZouTfonSXxir0csBmO5HlvCnPPtNSbiW0RTolww ETyeaXnSmqLdY45fGl0nDKhBRqiJo2RhwJJPiXXGrt2vqt2bnWjanK7z3OuaiHCqCKVY 5PZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=wHtH4uowNcGLatA4FtFRbjnON3Vo2NBBY5rs+rY1XYM=; b=QEMPpXGIrGRX3H0BC/S8WKImA2vEncRKTO3EtpORTkb1TiOKUJTyIPwVe3it0yU2f2 2vUNImizFijWd0gVMpwQJWK8opsi25Wp/4uXlAZJQOtlUn8xF42d/2LAriU2OgBZqJb2 tQZNOo6aVjw8aYp4GPFxP5vOHsWGa8WCzyd0YMfOtxyyq+66thd9vG1yiY9aspakk0eN 5oXbMyixobum7XpI6uegug5yDSzK8T8l76k9V7Kg7a2DDxgkr19XUlGeS3dA3KKH5Gc7 X85slANcJ2+nNWL7slZFbMS+UqDaB+Lnro2ExUfGM0Aw5EP3sRMG+zrSJzaHYu9gmHKk mr4Q== X-Gm-Message-State: AOAM530NTlgE5sV4DLbmvs3kv6iOzVtZBDjEUN32Yq0lmGta1h5GitRt rD6shFglQ6qTqUoC7I6EmvFRhcl9XKG7zA== X-Google-Smtp-Source: ABdhPJzxpmUrNZFFmUXZ+fGDda03R/VoG50oqI7bVzBOxaMsrqDWSkfK3RjtkMGHDa/Z+yBeIgemZQ== X-Received: by 2002:a17:90b:3649:: with SMTP id nh9mr4318932pjb.0.1618917635184; Tue, 20 Apr 2021 04:20:35 -0700 (PDT) Received: from VM-0-3-centos.localdomain ([101.32.213.191]) by smtp.gmail.com with ESMTPSA id s40sm14187367pfw.100.2021.04.20.04.20.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Apr 2021 04:20:34 -0700 (PDT) From: brookxu To: paolo.valente@linaro.org, axboe@kernel.dk, tj@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/8] bfq: remove unnecessary initialization logic Date: Tue, 20 Apr 2021 19:20:22 +0800 Message-Id: <686dd8506bb511ae181a99c9b45f287233aa2ecf.1618916839.git.brookxu@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chunguang Xu Since we will initialize sched_data.service_tree[] in bfq_init_root_group(), bfq_create_group_hierarchy() can ignore this part of the initialization, which can avoid repeated initialization. Signed-off-by: Chunguang Xu --- block/bfq-cgroup.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index 50d06c7..c8c68dc 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -1429,15 +1429,11 @@ void bfqg_and_blkg_put(struct bfq_group *bfqg) {} struct bfq_group *bfq_create_group_hierarchy(struct bfq_data *bfqd, int node) { struct bfq_group *bfqg; - int i; bfqg = kmalloc_node(sizeof(*bfqg), GFP_KERNEL | __GFP_ZERO, node); if (!bfqg) return NULL; - for (i = 0; i < BFQ_IOPRIO_CLASSES; i++) - bfqg->sched_data.service_tree[i] = BFQ_SERVICE_TREE_INIT; - return bfqg; } #endif /* CONFIG_BFQ_GROUP_IOSCHED */ From patchwork Tue Apr 20 11:20:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brookxu.cn" X-Patchwork-Id: 12213799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A29F7C43460 for ; Tue, 20 Apr 2021 11:20:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E4CE6139A for ; Tue, 20 Apr 2021 11:20:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231769AbhDTLVJ (ORCPT ); Tue, 20 Apr 2021 07:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231805AbhDTLVI (ORCPT ); Tue, 20 Apr 2021 07:21:08 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02832C06138C; Tue, 20 Apr 2021 04:20:37 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id y1so3847937plg.11; Tue, 20 Apr 2021 04:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=kfQ3tysIoxsatHCHD/2ZhyT8LCxPccS8PgExkIm8Ohw=; b=hXAE7fxzva1kCWVxkakrCakKQrPcHFhibFXiK+vF0uaHxUy5jfzQv6a97DjxPsJUKA AGCBJUZM7WuW5ysoVTFV7tz6fEs8fiByWd/TxegyE9xnU3jQcL6VETm1LYJ+ZnmVdmcO JPSt0cqR0rg2MGe6QkxWfpwOr20e3rsi1YP7llKF4YKe3k9IHETbxOwPo3vv/8nzzRM0 I/GcgiBRMbg9yA/roUSivUIlLa4CM0kuYEcT1dilIPmpZ2DbHAJdMTjI8trDWRp4henP EEIKj9pHwsdxmse7l+/IvDq8IlGkt48NXZZPCPYJOlbvIJ16xv9CaRsg/MG4jEVdSwx5 L4Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=kfQ3tysIoxsatHCHD/2ZhyT8LCxPccS8PgExkIm8Ohw=; b=f+MgIji45xQEyQNuCYI9XbPKOGr/RiXCWgF/qM3o/dznOAuK/RKBUhxm0ukDBdMJVJ CUG+TNnwRbsiJU2X+70gDvjnWt7c1qQ01AXEN0W3cp96sFO+VLohUDqAQ1UyU6CNxmGF emxtI6JmNnlxq9ZBbthMNwB1bzyVZGfT3C52RvJzpNczzrW4VdCmhr3JifDCm2PEn+Yd c+57GeCegab1rQcc7Lb3pI8guk8s+AcRi5SvLcOGwCFU+agO40cD10FKD7N6HJqn80PQ TNZXMy8IHoJwBDZwACwthZUhX9OZTAEaX1fbgR/QwbXxfMP38g67ZFW94030jP6Eyj/s VAWw== X-Gm-Message-State: AOAM533pjZXmLXDWyjf0B1fEyYIT0HsmOjduwko021KXdY86lFpVTnw7 A+w5fEOCxBQfcknvduNgrgiKoNkversBGA== X-Google-Smtp-Source: ABdhPJxxNbkRaBeT5aArcLlXmFXnWv+4UnnloMjashrlLk96pX2aGqacSyOI2C2tt4WLNFS8q9ojBA== X-Received: by 2002:a17:90b:1118:: with SMTP id gi24mr4344521pjb.30.1618917636634; Tue, 20 Apr 2021 04:20:36 -0700 (PDT) Received: from VM-0-3-centos.localdomain ([101.32.213.191]) by smtp.gmail.com with ESMTPSA id s40sm14187367pfw.100.2021.04.20.04.20.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Apr 2021 04:20:36 -0700 (PDT) From: brookxu To: paolo.valente@linaro.org, axboe@kernel.dk, tj@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/8] bfq: optimize the calculation of bfq_weight_to_ioprio() Date: Tue, 20 Apr 2021 19:20:23 +0800 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chunguang Xu The value range of ioprio is [0, 7], but the result of bfq_weight_to_ioprio() may exceed this range, so simple optimization is required. Signed-off-by: Chunguang Xu --- block/bfq-wf2q.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 619ed21..ea5b90d 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -527,8 +527,9 @@ unsigned short bfq_ioprio_to_weight(int ioprio) */ static unsigned short bfq_weight_to_ioprio(int weight) { - return max_t(int, 0, - IOPRIO_BE_NR * BFQ_WEIGHT_CONVERSION_COEFF - weight); + int ioprio = IOPRIO_BE_NR - weight / BFQ_WEIGHT_CONVERSION_COEFF; + + return ioprio < 0 ? 0 : min_t(int, ioprio, IOPRIO_BE_NR - 1); } static void bfq_get_entity(struct bfq_entity *entity) From patchwork Tue Apr 20 11:20:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brookxu.cn" X-Patchwork-Id: 12213805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F942C433ED for ; Tue, 20 Apr 2021 11:20:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C5BA613B2 for ; Tue, 20 Apr 2021 11:20:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231869AbhDTLVK (ORCPT ); Tue, 20 Apr 2021 07:21:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231837AbhDTLVJ (ORCPT ); Tue, 20 Apr 2021 07:21:09 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6384AC06138A; Tue, 20 Apr 2021 04:20:38 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id cu16so17659565pjb.4; Tue, 20 Apr 2021 04:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=tfZJcsESVJJ7LF8DyaFqXDwDLdv4yW2KMDeBAC866jo=; b=HHlhkFuIT3/E5oLlfNfJToXUKA4q4QJqlBFVsRIiZB+9wu5yf2mtd+cQ/IPhUC22ON odRSdjzuYwQjrh6m9ZSyUKdRr6Eg31izfhHUVkrwbvtr/r43FPoTmJB0oiCInUDskMaP WOLKw2nfh71WRLarYH4+M5u+mzOgD3wU32KSsmo2ftT6AQVuDK6UcYptgWeyAswgxwGz bAvGB0raoTbqwAyj21X87L0gpAzG5U5KM5eFU4OYho8Z2qsiFTdtaOEvJWTTa9mJnLCN JFlqgsZbfSDdhITrYTNrHTZHvZ7WRRr43z/l3E8yvuuxhL/tKNstgnNBVYR0vxlokEp2 duYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=tfZJcsESVJJ7LF8DyaFqXDwDLdv4yW2KMDeBAC866jo=; b=CT8WBZxind3Dor6hjjoDBcQWcw7cSyaFGizLENyOOeCur3OFFyvImkCNes3H9NwSCj VN8SKIw1jDCwDR6Pc04ieBnfeO5RR98Aow86/d5c8wliPvGA6ctyre/t95cQrnwVPJJn XCc4mEgPjabHYFSJnW5PHvMf9J3JxRCrq8OmAdgvX23YKJLNez14Mm2jDauBOMV4FtfY XjtTSYY5Cm/NDYjkHW9QdeCHeHDJ3BhajWnxJk5zMMSPl/TX9IAhrRIPQg3umZrCYqE/ y8uK3PNgaplxdlVpD6bpYlPG55C86KZaU+62gbrat8tlGR81o3oMDrsN1zC4myvOY+E/ RUxw== X-Gm-Message-State: AOAM533SfrfZGsv0oQES3R/OkVl9i7b5bc/5TEaSgXsEv+On+NGmQ9rd GRxHvbuXgUktF561CLErIOc= X-Google-Smtp-Source: ABdhPJwhtKio1/NXn2mOTJSCoi6eeI7xCDByM6/15sltzKq6VIfjBHwyKeRKrz4+6GR7/Y6wV5XxwA== X-Received: by 2002:a17:90a:6f45:: with SMTP id d63mr4459617pjk.39.1618917638072; Tue, 20 Apr 2021 04:20:38 -0700 (PDT) Received: from VM-0-3-centos.localdomain ([101.32.213.191]) by smtp.gmail.com with ESMTPSA id s40sm14187367pfw.100.2021.04.20.04.20.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Apr 2021 04:20:37 -0700 (PDT) From: brookxu To: paolo.valente@linaro.org, axboe@kernel.dk, tj@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] bfq: reset entity->prio_changed in bfq_init_entity() Date: Tue, 20 Apr 2021 19:20:24 +0800 Message-Id: <34c02f3525ed632ea1878591b41174aee50e953d.1618916839.git.brookxu@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chunguang Xu Since weight, ioprio, ioprio_class will be updated in bfq_init_entity(), st->wsum will be updated in __bfq_activate_entity(), so when it is first active, it seems that __bfq_entity_update_weight_prio() has nothing to do. By resetting entity->prio_change in bfq_init_entity(), we can avoid unnecessary logic calls. Signed-off-by: Chunguang Xu --- block/bfq-cgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index c8c68dc..79a5aaa 100644 --- a/block/bfq-cgroup.c +++ b/block/bfq-cgroup.c @@ -426,6 +426,7 @@ void bfq_init_entity(struct bfq_entity *entity, struct bfq_group *bfqg) entity->weight = entity->new_weight; entity->orig_weight = entity->new_weight; + entity->prio_changed = 0; if (bfqq) { bfqq->ioprio = bfqq->new_ioprio; bfqq->ioprio_class = bfqq->new_ioprio_class; From patchwork Tue Apr 20 11:20:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brookxu.cn" X-Patchwork-Id: 12213807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6571C433B4 for ; Tue, 20 Apr 2021 11:20:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADBD9613AE for ; Tue, 20 Apr 2021 11:20:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231805AbhDTLVT (ORCPT ); Tue, 20 Apr 2021 07:21:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231918AbhDTLVN (ORCPT ); Tue, 20 Apr 2021 07:21:13 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDA1AC06138A; Tue, 20 Apr 2021 04:20:39 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id 10so16439379pfl.1; Tue, 20 Apr 2021 04:20:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=qyBuZeZX6dtvZpGO9NcSkjgX81PiW8wDc10wk8ErfMI=; b=NU0gWB3bLQ/YvHQsoTXeQe3pmYJZZl1J/jfFrLtU2wvFbkpH3hXsng9vbM/vRpqXG3 OiUkRcwNMKrHCRqai8Sl1pD4hzAE9dOpESZHBiusyaT12PTasOqQPYpinnRENhqCX9nh 6bcXJVi0szFfSL3VLc2QGi4RWOTQJXCNP0ALeoYq2nTe23olNwdAVu7osIYlmbWRvH5h uWWqPhk1Y+XnjoOopFweN/nxn59T9yIm84UDOtuc7ubZjO6+15bCokaZvdxguOaxQA5W YJUkEHv4FsoqqO+WzwO4kF+zDfJrp/pmdjLvAfBGHPeZO4nAju/CHGMWjh/d04ne743X s42g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=qyBuZeZX6dtvZpGO9NcSkjgX81PiW8wDc10wk8ErfMI=; b=uFguUPFyXGQRz8PUoLdaimVkafybe/YvaG8enHnAqmsi3rA1ypKE6JdWE2qs9lfK0r +cc2NmdrbFzBvVDMUY49ElhfB+OL03y1+co7Bj6jk5iKZzO1sJ09RHdyzRfNceAPtTjC 43vK0ccBHmDodxlmSASb/Vi8oOSpSK7ouUHf1/73EG+K4htjvWpfWraF3rB5nHalhHNg vqlMriCypP7o6ueWC/9yqsfRfHaDbjdWrWzYPgLecuXTWr2Wc3JhZdxRRPS/NGwhoKaN Oog3MHQjwgGY8WB3sOOV+OuX7UUO4GGAF5ULsugliiUO6PzawICBoasWN7XYRMHp+Bzx mNVQ== X-Gm-Message-State: AOAM531F5k9PCQaeJpRtR1ocgKPmfiPxdaAsYXfncXL3F0qS7XUDQxCz 3wRtfOu1022gRNDnVgWC0cI= X-Google-Smtp-Source: ABdhPJwhOxy0VK8F9MrLulaJA9BdFiF57r0Uaq1SQynmOi1loZJ5nVr1scbbkEP5nCfAKKwNFD6Oig== X-Received: by 2002:a63:d552:: with SMTP id v18mr16318729pgi.313.1618917639488; Tue, 20 Apr 2021 04:20:39 -0700 (PDT) Received: from VM-0-3-centos.localdomain ([101.32.213.191]) by smtp.gmail.com with ESMTPSA id s40sm14187367pfw.100.2021.04.20.04.20.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Apr 2021 04:20:39 -0700 (PDT) From: brookxu To: paolo.valente@linaro.org, axboe@kernel.dk, tj@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/8] bfq: remove unnecessary BFQ_DEFAULT_GRP_IOPRIO Date: Tue, 20 Apr 2021 19:20:25 +0800 Message-Id: <86124148b8364995021f8c53737c68b04b524421.1618916839.git.brookxu@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chunguang Xu BFQ_DEFAULT_GRP_IOPRIO seems to be unused, maybe we can remove it. Signed-off-by: Chunguang Xu --- block/bfq-iosched.h | 1 - 1 file changed, 1 deletion(-) diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index da636a8..91c8654 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -22,7 +22,6 @@ #define BFQ_DEFAULT_QUEUE_IOPRIO 4 #define BFQ_WEIGHT_LEGACY_DFL 100 -#define BFQ_DEFAULT_GRP_IOPRIO 0 #define BFQ_DEFAULT_GRP_CLASS IOPRIO_CLASS_BE #define MAX_PID_STR_LENGTH 12