Message ID | 20221123060401.20392-4-shikemeng@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2614398wrr; Tue, 22 Nov 2022 22:04:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Xy8uLX/kFgKXaW2a2lQo4hX7GFbFMqA1EEVRe0XNVC+HYr2YkhVMm2OM5rrUJrAoS8xDr X-Received: by 2002:a17:90a:3f8e:b0:212:d644:fc20 with SMTP id m14-20020a17090a3f8e00b00212d644fc20mr29932270pjc.3.1669183486564; Tue, 22 Nov 2022 22:04:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669183486; cv=none; d=google.com; s=arc-20160816; b=SJdMvQQhB8sb2INOYMgK4LLK8YHvQ6cCIpUenfGfRptE4nGCJ9GNf+1WhGDNr2mx4E 0Wm2BbyJEkOmN0G22y4j3MMupKR3fUqKTJAtDF7jGQIdSDkaagV6wgqrVxQmbMTV/tF0 lxXPxUJzRtVcmfo6PwBYw7wM1MDhLTsYPFxMx69AwAVthBoDP+NsM0HWo21+11nJWVY2 NQs3LKobGFxblHDJ2aS6MjG9pyjswMqzjx1eCYrMGGPefcz1fGYbmEHj4uV9DH+3mLaf Ar10UobJVsJ0Cfnewpm2SVtz0KCB5+R3zezEmG3zJMrAimGKTJfMswT6kvs3GgWRVn8s XT4g== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a170902dac700b00175449cf6f8si18046655plx.606.2022.11.22.22.04.33; Tue, 22 Nov 2022 22:04:46 -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 <rfc822;cjcooper78@gmail.com> + 99 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <shikemeng@huawei.com> To: <tj@kernel.org>, <josef@toxicpanda.com>, <axboe@kernel.dk> CC: <cgroups@vger.kernel.org>, <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <shikemeng@huawei.com> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750265743503138464?= X-GMAIL-MSGID: =?utf-8?q?1750265743503138464?= |
Series |
A few bugfix and cleanup patches for blk-throttle
|
|
Commit Message
Kemeng Shi
Nov. 23, 2022, 6:03 a.m. UTC
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 <shikemeng@huawei.com>
---
block/blk-throttle.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
Comments
On Wed, Nov 23, 2022 at 02:03:53PM +0800, Kemeng Shi wrote: > 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 <shikemeng@huawei.com> > --- > 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 */ It's probably more important to mention that putting this in without PENDING set can corrupt the tree in the future through double insertion. > + if (!(tg->flags & THROTL_TG_PENDING)) > + continue; > + Other than than the above comment, Acked-by: Tejun Heo <tj@kernel.org> Thanks.
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.