From: sashiko-bot@kernel.org
To: "Yunye Zhao" <yunye.zhao@linux.alibaba.com>
Cc: yukuai@fygo.io, linux-raid@vger.kernel.org
Subject: Re: [PATCH v2 2/3] md: add cond_resched() to md_do_sync()'s skip path
Date: Thu, 23 Jul 2026 14:05:13 +0000 [thread overview]
Message-ID: <20260723140514.F33C21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723135535.101995-3-yunye.zhao@linux.alibaba.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Unbounded waitqueue spam from md_new_event() during sync skip loops.
--
--- Patch [2]: [PATCH v2 2/3] md: add cond_resched() to md_do_sync()'s skip path ---
commit 6f3b7b59be28b3b7daedbe090461ee12870bd481
Author: Yunye Zhao <yunye.zhao@linux.alibaba.com>
md: add cond_resched() to md_do_sync()'s skip path
This patch adds a cond_resched() to the skip loop in md_do_sync(). It
addresses a soft lockup watchdog trigger during raid10 recovery on large,
mostly clean arrays by yielding the CPU when regions are skipped.
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index d1465bcd86c81..c2e8b203c4db2 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -9881,8 +9881,10 @@ void md_do_sync(struct md_thread *thread)
> */
> md_new_event();
>
> - if (last_check + window > io_sectors || j == max_sectors)
> + if (last_check + window > io_sectors || j == max_sectors) {
> + cond_resched();
> continue;
> + }
[Severity: High]
This isn't a bug introduced by this patch, but does this code cause unbounded
waitqueue spam from md_new_event() during sync skip loops?
When last_check starts at 0 and the personality skips regions, io_sectors
does not increment. Because last_check remains 0, the block just above this
diff checks:
if (last_check == 0)
/* this is the earliest that rebuild will be
* visible in /proc/mdstat
*/
md_new_event();
Since last_check == 0 evaluates to true on every iteration of the skip loop,
md_new_event() is called continuously.
For a large clean array with small skip chunks (like 128 sectors), this could
execute millions of times.
Could this lead to severe waitqueue spam and lock contention on
md_event_waiters, resulting in spurious wakeups for userspace processes
monitoring mdstat?
>
> last_check = io_sectors;
> repeat:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260723135535.101995-1-yunye.zhao@linux.alibaba.com?part=2
next prev parent reply other threads:[~2026-07-23 14:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 6:27 [PATCH] md: fix soft lockup during resync when sync is repeatedly skipped Yunye Zhao
2026-07-17 6:51 ` sashiko-bot
2026-07-19 10:45 ` yu kuai
2026-07-20 6:20 ` Yunye Zhao
2026-07-22 4:00 ` yu kuai
2026-07-23 13:55 ` [PATCH v2 0/3] md/raid10: fix recovery corruption and soft lockup on large arrays Yunye Zhao
2026-07-23 13:55 ` [PATCH v2 1/3] md/raid10: fix still_degraded being inverted in raid10_sync_request() Yunye Zhao
2026-07-23 13:55 ` [PATCH v2 2/3] md: add cond_resched() to md_do_sync()'s skip path Yunye Zhao
2026-07-23 14:05 ` sashiko-bot [this message]
2026-07-23 13:55 ` [PATCH v2 3/3] md/raid10: skip clean regions in bulk during recovery Yunye Zhao
2026-07-23 14:16 ` sashiko-bot
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=20260723140514.F33C21F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yukuai@fygo.io \
--cc=yunye.zhao@linux.alibaba.com \
/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