Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp151139rwr; Tue, 25 Apr 2023 19:24:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4bgMkAbbCdUJP8qnywbU7D9pUjnGK8UnIjMyIV9yJ/Yju9Yp54xIfUODs9j4YycaVG0nbd X-Received: by 2002:a05:6a00:2e26:b0:641:3f9:5a09 with SMTP id fc38-20020a056a002e2600b0064103f95a09mr863072pfb.4.1682475846099; Tue, 25 Apr 2023 19:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682475846; cv=none; d=google.com; s=arc-20160816; b=wbkYCnO7bFUwR8VSN2p+ctah90eQEfBxWQXAtfJuIqIvQJYLqX76sg2q09wGOsocLd mwDOSut7WBRpw9Yj+e6EhL+/lMM8bauutou9UkppA9eo57rx55S1mQ+Q3mormwHGFivh qFgQ2U/bGR8O2hea0KqyoKiynxQAGLMJjatYNlTzIObc1vOg2MA/Bh18df+warXJz0VI HcTzSuNlx1k8X5rrZrPtQJBgSeEwzvEakDcICcwbcZlVEfvh2kjV7Cq34EsXLbsELCqI 2SQ3zhPMaX5k3g04mHbddU6tC2xF9b0vCRtp1iJhPATsKqaaZPu0Zd8ucyRN4XDAcySN YjMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eBrHkhpsSjTvuNwXmi/r/rlAjxob+9SEBm2HiSe8Ero=; b=ludSkqjEojv8W4JYCIrGCe/2iVzl12rcdJBUj4p6MmTqSEAM1MzXbYNa6KE4tH2opu g0NUeIYEKV+u47zV4ICMOb2ePS6JGS7bcVmmbATctoA083W+JUGUxmJSAE6rBSbOmDOm h2h4ZrLkiM2N4ZNeyNbx66yaJ8/gEVHC7KNCAi0EgnWXkJT+cleDRfmBJ6sSfeTG6pv2 B8/u1bEkO4+a1ucwKdEetlYhavYRu5rxFCNvc5C9PMLoVd27LxOJR1572ls+yGkF7B/g c2vUkXGYK0MVN93S1h/OxmznMR1yrSLD4rpgjUrfWfggF3RV3912Miyqtz3Fq3MLmebf yVlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dQn0yCXm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u71-20020a62794a000000b0063601bd1cc9si15109780pfc.321.2023.04.25.19.23.52; Tue, 25 Apr 2023 19:24:06 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=dQn0yCXm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239018AbjDZCWF (ORCPT + 99 others); Tue, 25 Apr 2023 22:22:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238460AbjDZCWD (ORCPT ); Tue, 25 Apr 2023 22:22:03 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AE158688; Tue, 25 Apr 2023 19:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682475722; x=1714011722; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=aZSnevCV0ZRoHK+SA5IxOde8adJ7cTFjbdtLQdZjCrA=; b=dQn0yCXm9RqN6DYVe8IuUVa2iDTPXDkYChbDjtacrLCnnKRZgHX66w3o q8jf+yVzww9SAp9LWIfWy2ZLjcvhB8LQor7aJKljR3rGuKdaZq7YmQ8UT gSQKqBk5x5jKwrdLqDVqNZjTw3DBxBVJsYpYfwUwaA2t4G29KAom28dr9 YivFtZ3zslKSBxgb6Jls0FplVlyCs3MKzj9t7d6OlwPmKBLAUOfN8LxeV pwnNQN6daCCuW696+t3plxalkJUFJV3pyTbHj/3zq+LENlJw+a+5hLb9w LqdidmdP3DBU4P/GWNr1/CfJDzDr9q1gq8nhpgcyN8AOgAkmXKVQv2WSB A==; X-IronPort-AV: E=McAfee;i="6600,9927,10691"; a="345718608" X-IronPort-AV: E=Sophos;i="5.99,227,1677571200"; d="scan'208";a="345718608" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2023 19:22:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10691"; a="763111662" X-IronPort-AV: E=Sophos;i="5.99,227,1677571200"; d="scan'208";a="763111662" Received: from linux.bj.intel.com ([10.238.156.127]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2023 19:21:59 -0700 Date: Wed, 26 Apr 2023 10:20:34 +0800 From: Tao Su To: Yu Kuai Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, tj@kernel.org, josef@toxicpanda.com, axboe@kernel.dk, "yukuai (C)" Subject: Re: [PATCH] Remove blkg node after destroying blkg Message-ID: References: <20230425075911.839539-1-tao1.su@linux.intel.com> <6d486f85-87ed-fa35-00cb-4c37fef17536@huaweicloud.com> <9f5eeba2-fbc9-3b56-c7ed-d8ecc1c888b3@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9f5eeba2-fbc9-3b56-c7ed-d8ecc1c888b3@huaweicloud.com> X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Wed, Apr 26, 2023 at 09:13:08AM +0800, Yu Kuai wrote: > Hi, > > 在 2023/04/25 19:09, Yu Kuai 写道: > > Hi, > > > > 在 2023/04/25 17:41, Tao Su 写道: > > > On Tue, Apr 25, 2023 at 04:09:34PM +0800, Yu Kuai wrote: > > > > 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. > > > > > > Yes, directly removing blkg node is not appropriate, which I noticed some > > > comments in blkg_destroy(), thanks for pointing out this issue. > > > > > > > > > > > I think this hung happens when total blkg is greater than > > > > BLKG_DESTROY_BATCH_SIZE, right? > > > > > > Yes, you are right. > > > > > > > > > > > Can you try if following patch fix your problem? > > > > > > This patch can also fix my problem, and indeed is a more secure way. > > > > Thanks for the test, for a better solution, I think 'blkcg_mutex' can > > be used to protect 'blkg->q_node' list instead of 'queue_lock', so that > > the 'restart' can be removed because softlockup can be avoided. > > > > I looked into this, and I found that this is not a easy thing to do. > > Anyway, feel free to submit a new patch based on my orignial suggestion. Thanks for your contribution and careful review, I will submit the new patch if no other comments. Thanks, Tao > > Thanks, > Kuai >