All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai3@huawei.com>
To: Tao Su <tao1.su@linux.intel.com>, <linux-block@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Cc: <tj@kernel.org>, <josef@toxicpanda.com>, <axboe@kernel.dk>,
	"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH] Remove blkg node after destroying blkg
Date: Tue, 25 Apr 2023 16:09:34 +0800	[thread overview]
Message-ID: <aa5de32c-c92b-d032-e9bb-83d2436ff72c@huawei.com> (raw)
In-Reply-To: <20230425075911.839539-1-tao1.su@linux.intel.com>

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 <xiangfeix.ma@intel.com>
> Tested-by: Xiangfei Ma <xiangfeix.ma@intel.com>
> Tested-by: Farrah Chen <farrah.chen@intel.com>
> Signed-off-by: Tao Su <tao1.su@linux.intel.com>
> ---
>   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);
>   
>   		/*
> 

  reply	other threads:[~2023-04-25  8:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-25  7:59 [PATCH] Remove blkg node after destroying blkg Tao Su
2023-04-25  8:09 ` Yu Kuai [this message]
2023-04-25  9:41   ` Tao Su
2023-04-25 11:09     ` Yu Kuai
2023-04-26  1:13       ` Yu Kuai
2023-04-26  2:20         ` Tao Su

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aa5de32c-c92b-d032-e9bb-83d2436ff72c@huawei.com \
    --to=yukuai3@huawei.com \
    --cc=axboe@kernel.dk \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tao1.su@linux.intel.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.