All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zizhi Wo" <wozizhi@huaweicloud.com>
Cc: linux-raid@vger.kernel.org, yukuai@fygo.io
Subject: Re: [PATCH] md/raid10: fix missing wakeup in wait_barrier_nolock
Date: Mon, 10 Aug 2026 14:12:15 +0000	[thread overview]
Message-ID: <20260810141216.3AE7F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260810135521.3470422-1-wozizhi@huaweicloud.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Lockless read of `conf->array_freeze_pending` lacks `READ_ONCE()`, violating kernel concurrency guidelines and potentially triggering KCSAN warnings.
--

--- Patch [1]: [PATCH] md/raid10: fix missing wakeup in wait_barrier_nolock ---
commit 3470079c0f4271a77d161b3a70575176ea1d322b
Author: Zizhi Wo <wozizhi@huawei.com>

md/raid10: fix missing wakeup in wait_barrier_nolock

This commit fixes a hung task issue in RAID10 by ensuring that
wait_barrier_nolock() properly wakes up a pending freeze_array(). It adds a
wake-up condition for conf->array_freeze_pending when the pending counter is
decremented.

> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 0a3cfdd3f5df8..fad634a444f89 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
[ ... ]
> @@ -996,7 +996,8 @@ static bool wait_barrier_nolock(struct r10conf *conf)
>  	if (!read_seqretry(&conf->resync_lock, seq))
>  		return true;
>  
> -	if (atomic_dec_and_test(&conf->nr_pending))
> +	if (atomic_dec_and_test(&conf->nr_pending) ||
> +	    conf->array_freeze_pending)

[Severity: Low]
Does this lockless read of conf->array_freeze_pending need a READ_ONCE()
wrapper?

Since freeze_array() modifies this variable under the resync_lock seqlock,
reading it here locklessly might trigger KCSAN data race warnings or be
subject to compiler optimizations. 

While atomic_dec_and_test() provides a memory barrier, kernel concurrency
guidelines generally require READ_ONCE() for plain lockless reads of shared
variables to prevent compiler optimizations.

It looks like this pattern was copied from allow_barrier(), which also has a
lockless read without READ_ONCE():

drivers/md/raid10.c:allow_barrier() {
    ...
    if ((atomic_dec_and_test(&conf->nr_pending)) ||
        (conf->array_freeze_pending))
        wake_up_barrier(conf);
    ...
}

Should both of these locations be updated to use
READ_ONCE(conf->array_freeze_pending)?

>  		wake_up_barrier(conf);
>  
>  	return false;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260810135521.3470422-1-wozizhi@huaweicloud.com?part=1

      reply	other threads:[~2026-08-10 14:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 13:55 [PATCH] md/raid10: fix missing wakeup in wait_barrier_nolock Zizhi Wo
2026-08-10 14:12 ` sashiko-bot [this message]

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=20260810141216.3AE7F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wozizhi@huaweicloud.com \
    --cc=yukuai@fygo.io \
    /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.