From: "Zqiang" <qiang.zhang@linux.dev>
To: "Sunho Park" <shpark061104@gmail.com>, rcu@vger.kernel.org
Cc: paulmck@kernel.org, linux-kernel@vger.kernel.org,
syzbot+d4faf7db59e11f6fd1ab@syzkaller.appspotmail.com
Subject: Re: [BUG] srcu: false-positive WARN in cleanup_srcu_struct() after 78a38cbf6f20
Date: Thu, 27 Aug 2026 11:35:09 +0000 [thread overview]
Message-ID: <698a4d8b6c559f9049ee6fa6b0bc99d45a3d7e44@linux.dev> (raw)
In-Reply-To: <e6350377085ddd85d6ef00d8e9a67bd50c762d3c@linux.dev>
>
> >
> > On 8/27/26 08:53, Zqiang wrote:
> >
> >
> > Based on your description below, the 5.srcu_barrier() did not intercept the callback of 4.call_srcu(),
> > this means that 4.call_srcu() and 5.srcu_barrier() concurrent calls, or calls after 5.srcu_barrier().
> > The combination of srcu_barrier() and cleanup_srcu_struct() typically occurs on the module exit path.
> > srcu_barrier() ensures that all previously inserted callbacks complete,so therefore, theoretically,
> > there shouldn't be any callbacks left to execute after we finish executing srcu_barrier().
> > and of course, there are also shouldn't be any ongoing or newly started SRCU grace period and the
> > WARN_ON() in cleanup_srcu_struct() is designed to detect it.
> > If when the cleanup_srcu_struct() detects an incomplete SRCU grace period or any srcu callbacks
> > that have not yet been executed, this is a risk that needs to be reported, even if the
> > cleanup_srcu_struct() can intercept it internally.
> > > Therefore, we should investigate this issue to ensure that 5.srcu_barrier() can intercept the step 4 callback.
> > Thanks
> > Zqiang
> >
> > Before 5. srcu_barrier() call, the 4. call_srcu() is finished and the callback was enqueued, and srcu_barrier() did intercept it by appending barrier cb after it. They can't be called concurrently because when call_srcu() is called inside kvm_io_bus_register_dev(), the kvm reference count is nonzero and kvm_destroy_vm() which calls srcu_barrier() could not be started.
> >
> Which tree is your test based on? (rcu tree or linux-next tree)
>
> The step 4 call_srcu() is finished and then the step5 call srcu_barrier(), it failed to intercept it?
> (theoretically, this shouldn't happen)
>
Sorry, here I missed.
>
>
> >
> > In my debugging, all five __free_bus() callbacks enqueued by kvm_io_bus_register_dev() were invoked before the barrier cb, and only then the barrier cb is called and srcu_barrier() returns. So all the real callbacks were executed and practically there were no callbacks left to execute when srcu_barrier() returns, but a stale n_cbs > 0 is left because srcu_invoke_callbacks()'s invoking loop has not finished.
> >
> > KVM logic correctly called srcu_barrier() and cleanup_srcu_struct() without calling call_srcu() in between. In my opinion, the root causes are as follows:
> >
> > 1) for timer_delete_sync(): the srcu_gp_end() which ended the last grace period (from 4. ) arms sdp->delay_work to expire at jiffies + 1 even though the invoke work (queued in 3. ) is already queued, and cleanup_srcu_struct() runs before that one-jiffy timer expires, so timer_delete_sync() cancels that pending timer and returns true.
The step5 srcu_barrier() has been intercept the srcu callback which by step4 call_srcu() insert,
so at here, the srcu_barrier should not be return, and the step4 srcu callback should not be run.
the cleanup_srcu_struct() also should not be called.
Thanks
Zqiang
> >
> > 2) for n_cbs: srcu_invoke_callbacks() calls rcu_segcblist_add_len(-len) only at the end of the work item, after the barrier callback has been invoked and srcu_barrier() has already returned, so cleanup_srcu_struct() observes a stale n_cbs > 0 while the cblist is physically empty.
> >
> because you say the 5.srcu_barrier() can not intercept setp4 call_srcu() enqueue callback func,
> that means that the step4 srcu callback shuold not be run, the cblist also not empty.
>
> Thanks
> Zqiang
>
> >
> > Thanks
> > Sunho Park
> >
>
next prev parent reply other threads:[~2026-08-27 11:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 10:56 [BUG] srcu: false-positive WARN in cleanup_srcu_struct() after 78a38cbf6f20 Sunho Park
2026-08-25 12:33 ` Zqiang
2026-08-25 16:50 ` Sunho Park
2026-08-26 13:13 ` Zqiang
2026-08-26 16:03 ` Sunho Park
2026-08-26 23:53 ` Zqiang
2026-08-27 9:11 ` Sunho Park
2026-08-27 11:13 ` Zqiang
2026-08-27 11:35 ` Zqiang [this message]
2026-08-27 12:30 ` Sunho Park
2026-08-27 12:40 ` Zqiang
2026-08-27 13:03 ` Sunho Park
2026-08-27 13:40 ` Zqiang
2026-08-27 13:41 ` Zqiang
2026-08-29 23:08 ` Paul E. McKenney
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=698a4d8b6c559f9049ee6fa6b0bc99d45a3d7e44@linux.dev \
--to=qiang.zhang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=shpark061104@gmail.com \
--cc=syzbot+d4faf7db59e11f6fd1ab@syzkaller.appspotmail.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 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.