Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6646899rwr; Tue, 25 Apr 2023 01:19:26 -0700 (PDT) X-Google-Smtp-Source: AKy350Ye25oSosKIcOM2O//9hBDYZL0thdsePyMDCXRuJJ+bdBe7ccZBl1oR/q0XoOmS0sLR6iUw X-Received: by 2002:a17:902:e3d3:b0:19e:6760:305b with SMTP id r19-20020a170902e3d300b0019e6760305bmr14230795ple.47.1682410766049; Tue, 25 Apr 2023 01:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682410766; cv=none; d=google.com; s=arc-20160816; b=Fp481XO3MkIbOxM1Fjq98UEVSvkfTNPAyEi3UK4WIcVPelgvKxc0jjsUi6fMzklAnq BTGq20wuttHpjBVuXe39KvSturfN+2YUsWBY2tqqZ/zGBfvZW8bTXmDG4pkMxYKyynZI nIkI2b7yq/WO9xvRqguucj0hb1aWcvCh/tukrKK34UXfDbKe7y2ECoLhLB42V+i1ZIly 6v3JIXpw08m0lGfH7J7MGAlaIg8mx9acYJBuihC+Uqus4eqrb2uIi0nQUAOelTmO6sOD hvdJiY/3ntooRPAGl3wBomYzX8BVPMXkkRXJyjgiMNU5JqWgrqiqfNx7LQmPvEwwjymN jh+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=+ZygSBdlrjHCpJCivreUPB+mq4BImAGv8ynnpyYUSBI=; b=v8ViKTGLEnKj6efvs6kXCHUIEugsK74Gj8mWISjGXt3ZCGGR8gTYQzBygiT5Vi1fCk +l648FfoXX9hD0fMC4Yzf030J/M/mSkKHTXPDP/UNxo4Ci3a0oW3V6DzkW6xdSmLtQfY eZOs7pDj8W/H/SpjHaIyU9jBtLlJoV6Yvz4mxjZ/c9btUO8973Ij6SZQgYvhwzOKz+Wv 4H4yFGYJMYF1KIWbA0hw2zlZh1lcvnfvLSR+coX23HLec+Jp1GnQXxFhADx/emMuC87S 8p7azH3jlnBm4KXYqLDZ108MuyTm1VbASlR/buJS3UvKk4jZpaijoP8zKGB1QSkTlvK+ P0ig== 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 d9-20020a170903230900b001a63a2de59asi14262408plh.494.2023.04.25.01.19.13; Tue, 25 Apr 2023 01:19:26 -0700 (PDT) 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 S233491AbjDYIJo (ORCPT + 99 others); Tue, 25 Apr 2023 04:09:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233416AbjDYIJm (ORCPT ); Tue, 25 Apr 2023 04:09:42 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 203FEA2; Tue, 25 Apr 2023 01:09:39 -0700 (PDT) Received: from kwepemm600009.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Q5F0w0f5GzSsln; Tue, 25 Apr 2023 16:05:20 +0800 (CST) Received: from [10.174.176.73] (10.174.176.73) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 25 Apr 2023 16:09:35 +0800 Subject: Re: [PATCH] Remove blkg node after destroying blkg To: Tao Su , , CC: , , , "yukuai (C)" References: <20230425075911.839539-1-tao1.su@linux.intel.com> From: Yu Kuai Message-ID: Date: Tue, 25 Apr 2023 16:09:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20230425075911.839539-1-tao1.su@linux.intel.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.73] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi, ?? 2023/04/25 15:59, Tao Su ะด??: > Kernel hang when poweroff or reboot, due to infinite restart in function > blkg_destroy_all. It will goto restart label when a batch of blkgs are > destroyed, but not remove blkg node in blkg_list. So the blkg_list is > same in every 'restart' and result in kernel hang. > > By adding list_del to remove blkg node after destroying, can solve this > kernel hang issue and satisfy the previous will to 'restart'. > > Reported-by: Xiangfei Ma > Tested-by: Xiangfei Ma > Tested-by: Farrah Chen > Signed-off-by: Tao Su > --- > block/blk-cgroup.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c > index bd50b55bdb61..960eb538a704 100644 > --- a/block/blk-cgroup.c > +++ b/block/blk-cgroup.c > @@ -530,6 +530,7 @@ static void blkg_destroy_all(struct gendisk *disk) > > spin_lock(&blkcg->lock); > blkg_destroy(blkg); > + list_del(&blkg->q_node); blkg should stay on the queue list until blkg_free_workfn(), otherwise parent blkg can be freed before child, which will cause some known issue. I think this hung happens when total blkg is greater than BLKG_DESTROY_BATCH_SIZE, right? Can you try if following patch fix your problem? index 1c1ebeb51003..0ecb4cce8af2 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -527,6 +527,9 @@ static void blkg_destroy_all(struct gendisk *disk) list_for_each_entry_safe(blkg, n, &q->blkg_list, q_node) { struct blkcg *blkcg = blkg->blkcg; + if (hlist_unhashed(&blkg->blkcg_node)) + continue; + spin_lock(&blkcg->lock); blkg_destroy(blkg); spin_unlock(&blkcg->lock); > spin_unlock(&blkcg->lock); > > /* >