From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7A3DFBF3 for ; Mon, 15 May 2023 17:03:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09DE4C433EF; Mon, 15 May 2023 17:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1684170211; bh=rbgR+y/r5Bn95AFcuQOb5aSCzNnLEgagLuLujUbnlqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jvSm575TR7nCZGRTHbTQMDPMZcry1yX6wQFW3H08sPT71poLqkgsMUj4yrjObjThM z4FZe0Eg1Jy3iWK1C++SOzWFXuCU9jqvqfnEsS3X/UUSRPmxPYDc3vCpGFdfxcNJ1K gsNIOl7WkH2MlFkgCrgSncUZmHFIPqeomVBj/04g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xiangfei Ma , Farrah Chen , Tao Su , Jens Axboe , Sasha Levin , Yu Kuai Subject: [PATCH 6.1 052/239] block: Skip destroyed blkg when restart in blkg_destroy_all() Date: Mon, 15 May 2023 18:25:15 +0200 Message-Id: <20230515161723.267970209@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515161721.545370111@linuxfoundation.org> References: <20230515161721.545370111@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Tao Su [ Upstream commit 8176080d59e6d4ff9fc97ae534063073b4f7a715 ] Kernel hang in blkg_destroy_all() when total blkg greater than BLKG_DESTROY_BATCH_SIZE, because of not removing destroyed blkg in blkg_list. So the size of blkg_list is same after destroying a batch of blkg, and the infinite 'restart' occurs. Since blkg should stay on the queue list until blkg_free_workfn(), skip destroyed blkg when restart a new round, which will 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 Fixes: f1c006f1c685 ("blk-cgroup: synchronize pd_free_fn() from blkg_free_workfn() and blkcg_deactivate_policy()") Suggested-and-reviewed-by: Yu Kuai Link: https://lore.kernel.org/r/20230428045149.1310073-1-tao1.su@linux.intel.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-cgroup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 7c91d9195da8d..60f366f98fa2b 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -468,6 +468,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); -- 2.39.2