Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6901711rwb; Tue, 22 Nov 2022 22:11:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf62iyC7MvGXM+/L4+8tN0DRY9ivkBK34WJYtObKPBQ8rY5m6GbWBTx+91DrCv9q9B8fbVU6 X-Received: by 2002:a17:907:b606:b0:7af:ecf4:61c0 with SMTP id vl6-20020a170907b60600b007afecf461c0mr7646170ejc.178.1669183905442; Tue, 22 Nov 2022 22:11:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669183905; cv=none; d=google.com; s=arc-20160816; b=u5p/om+R5g1K3zXh/s/qjh8KIUFQOoJJe2xvMrfQTsdYtKNsGkzRyO71nkuQfTB+0E ui8hcMDKXknyybe6r6bzzMlRakD2nkpCn6s4xVGlVrQOPF+Okswk9IHiByhu3W4g89bM jyCHdUiHGPOjzmrlFgRs0InAmZzgCE2xXDrGPJFG8SDkXiOA4g4k9yQacdm0U3WfVM5X 9+I9oPCbfy9W5IYwFZZEUNVkHIwUTALJyDKp4iRALNij5n5HpdkbzBI91ohTvO3DT6wQ 0SgWVh4haVRWlCIQIR/KXNMRjhlpNfdm4HbQWdGqY1RVNIiaoU48V/ykxrTBCuWLsiGh TneA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=b+YlWhnNICoyt+4tL/pWEaMrlJo7McJUuiO5Tr9YiSI=; b=J0EkgIwG1J7LtAZ5my75RiNNC9Xrp6LBEzh6qBdeQqiQ0IrdK05q3V48epjkA/x8Yj iqo1SEaDyFn+D94CAMmBE+3JbvI6f4Vv8dQgT4rbix1Iuxs6mWxxJjA6bXBGOd3xJQjR AHWV+OJzFm/BSrPH0DZ4A6qPqtA1GXLDg4cqa7Z2j6g+MnHkdSwuUkLTnFTaBHwws3Sp LF3fxGWnLGy7wkw3WypbaPBDdeOSEa36+yfjllvARus8sA7v1GsNOCdSznxA55sTGk7v hepXPCkNGWKSUpLT9nfICJkICIaUn86/jvXskPBRa03XmOKKDQBRu8CMWrGicEB9ieqN GF+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g35-20020a056402322300b0045ccd2c9944si13319559eda.233.2022.11.22.22.11.22; Tue, 22 Nov 2022 22:11:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235831AbiKWGES (ORCPT + 90 others); Wed, 23 Nov 2022 01:04:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbiKWGEK (ORCPT ); Wed, 23 Nov 2022 01:04:10 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34396F2C08; Tue, 22 Nov 2022 22:04:08 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NH9Tt2rc6zJnrH; Wed, 23 Nov 2022 14:00:50 +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; Wed, 23 Nov 2022 14:04:05 +0800 From: Kemeng Shi To: , , CC: , , , Subject: [PATCH 03/11] blk-throttle: ignore cgroup without io queued in blk_throtl_cancel_bios Date: Wed, 23 Nov 2022 14:03:53 +0800 Message-ID: <20221123060401.20392-4-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221123060401.20392-1-shikemeng@huawei.com> References: <20221123060401.20392-1-shikemeng@huawei.com> MIME-Version: 1.0 Content-Type: text/plain 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ignore cgroup without io queued in blk_throtl_cancel_bios for two reasons: 1. Save cpu cycle for trying to dispatch cgroup which is no io queued. 2. Avoid non-consistent state that cgroup is inserted to service queue without THROTL_TG_PENDING set as tg_update_disptime will unconditional re-insert cgroup to service queue. If we are on the default hierarchy, IO dispatched from child in tg_dispatch_one_bio will trigger inserting cgroup to service queue without erase first and ruin the tree. Signed-off-by: Kemeng Shi --- block/blk-throttle.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index b33bcf53b36e..acfac916ed99 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -1728,7 +1728,12 @@ void blk_throtl_cancel_bios(struct gendisk *disk) * Set the flag to make sure throtl_pending_timer_fn() won't * stop until all throttled bios are dispatched. */ - blkg_to_tg(blkg)->flags |= THROTL_TG_CANCELING; + tg->flags |= THROTL_TG_CANCELING; + + /* No need to dispatch cgroup without io queued */ + if (!(tg->flags & THROTL_TG_PENDING)) + continue; + /* * Update disptime after setting the above flag to make sure * throtl_select_dispatch() won't exit without dispatching. -- 2.30.0