Linux block layer
 help / color / mirror / Atom feed
From: Tao Cui <cui.tao@linux.dev>
To: Guopeng Zhang <guopeng.zhang@linux.dev>,
	Tejun Heo <tj@kernel.org>, Josef Bacik <josef@toxicpanda.com>,
	Jens Axboe <axboe@kernel.dk>
Cc: cui.tao@linux.dev, Yu Kuai <yukuai@fygo.io>,
	cgroups@vger.kernel.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Guopeng Zhang <zhangguopeng@kylinos.cn>
Subject: Re: [PATCH] blk-cgroup: clear blkg->pd[] with WRITE_ONCE() in blkcg_deactivate_policy()
Date: Wed, 8 Jul 2026 13:10:47 +0800	[thread overview]
Message-ID: <841e91db-a51e-4df5-8cfc-e3762a2fecf1@linux.dev> (raw)
In-Reply-To: <20260707125814.1978139-1-guopeng.zhang@linux.dev>



在 2026/7/7 20:58, Guopeng Zhang 写道:
> From: Guopeng Zhang <zhangguopeng@kylinos.cn>
> 
> blkcg_activate_policy() installs blkg->pd[] entries with WRITE_ONCE()
> and also uses WRITE_ONCE() when clearing them on its error path.
> blkg_to_pd() is used by RCU readers and reads the same array with
> READ_ONCE().
> 
> blkcg_deactivate_policy() clears the entry with a plain store. Use
> WRITE_ONCE() there as well.
> 
> Fixes: 56cc24f59c14 ("blk-cgroup: don't nest queue_lock under rcu in blkcg_print_blkgs()")
> Signed-off-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
> ---
>  block/blk-cgroup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index d2a1f5903f24..a1dd69f99f5c 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -1691,7 +1691,7 @@ void blkcg_deactivate_policy(struct gendisk *disk,
>  			if (blkg->pd[pol->plid]->online && pol->pd_offline_fn)
>  				pol->pd_offline_fn(blkg->pd[pol->plid]);
>  			pol->pd_free_fn(blkg->pd[pol->plid]);
> -			blkg->pd[pol->plid] = NULL;
> +			WRITE_ONCE(blkg->pd[pol->plid], NULL);
>  		}
>  		spin_unlock(&blkcg->lock);
>  	}

Reviewed-by: Tao Cui <cuitao@kylinos.cn>


  reply	other threads:[~2026-07-08  5:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 12:58 [PATCH] blk-cgroup: clear blkg->pd[] with WRITE_ONCE() in blkcg_deactivate_policy() Guopeng Zhang
2026-07-08  5:10 ` Tao Cui [this message]
2026-07-08  5:29   ` Tao Cui
2026-07-08  5:59     ` Guopeng Zhang

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=841e91db-a51e-4df5-8cfc-e3762a2fecf1@linux.dev \
    --to=cui.tao@linux.dev \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=guopeng.zhang@linux.dev \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=yukuai@fygo.io \
    --cc=zhangguopeng@kylinos.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox