From: Petr Mladek <pmladek@suse.com>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: "Ravindran, Binoy" <binoy@vt.edu>,
"Paul E. McKenney" <paulmck@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Joel Fernandes <joelagnelf@nvidia.com>,
Josh Triplett <josh@joshtriplett.org>,
Boqun Feng <boqun@kernel.org>,
Uladzislau Rezki <urezki@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang@linux.dev>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Miroslav Benes <mbenes@suse.cz>,
Joe Lawrence <joe.lawrence@redhat.com>,
Song Liu <song@kernel.org>, Ingo Molnar <mingo@kernel.org>,
Jiri Kosina <jikos@kernel.org>,
"sashiko-reviews@lists.linux.dev"
<sashiko-reviews@lists.linux.dev>,
"live-patching@vger.kernel.org" <live-patching@vger.kernel.org>,
"Shastri, Jaidev" <jaidevshastri@vt.edu>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"rcu@vger.kernel.org" <rcu@vger.kernel.org>
Subject: Re: [PATCH v3 2/3] livepatch: Include exiting tasks in the transition
Date: Fri, 27 Nov 2026 16:10:12 +0100 [thread overview]
Message-ID: <awmdVLfnwgrS9VfS@pathway.suse.cz> (raw)
In-Reply-To: <awmWExtIJGM805__@pathway.suse.cz>
On Fri 2026-11-27 15:39:15, Petr Mladek wrote:
> On Thu 2026-11-26 11:12:27, Yafang Shao wrote:
> > On Thu, Nov 26, 2026 at 8:58 AM Ravindran, Binoy <binoy@vt.edu> wrote:
> > >
> > >
> > > Thanks, this is right. A dying task reports its quiescent state in
> > > rcu_note_context_switch(), early in __schedule(), and then still runs
> > > traceable code, such as update_rq_clock() and pick_next_task(), until
> > > switch_to(). RCU does not promise to wait for code after that point, and
> > > with expedited grace periods the quiescent state is reported right
> > > there, so synchronize_rcu() can return too early.
> > > klp_synchronize_transition(), which v2 used, does not have this
> > > problem: schedule_on_each_cpu() completes only after the work item has
> > > run on every CPU, which on the dying task's CPU happens only after
> > > switch_to().
> > >
> > > v4 goes back to klp_synchronize_transition() for both waits and keeps
> > > klp_try_switch_exiting_tasks() from v3. I will send it after rerunning
> > > the tests.
> > >
> > > Yafang, this reverses your second suggestion; I hope the reason above
> > > makes sense. It also brings back the v2 transition times.
> >
> > Agreed. I missed the point that the quiescent state is reported early
> > in __schedule(), and that the code from there until switch_to() is not
> > covered by synchronize_rcu(). Thanks for pointing that out.
>
> Honestly, I think that synchronize_srcu() should work. Otherwise,
> the comment in rcu_tasks_postgp() would be wrong.
>
> IMHO, the trick is that there are two interlacing rcu_read() periods
> in do_exit() and synchronize_rcu(), see the comment in
> rcu_tasks_postscan() and the commit e4e1e8089c5fd9 ("rcu-tasks:
> Improve comments explaining tasks_rcu_exit_srcu purpose").
Wait! I might be wrong. I think that it does not work because
the 1st rcu_read section ends in exit_rcu() which is called
before exit_tasks_rcu_finish() where the task is removed
from rcu_tasks_exit_list.
By other words, the task is removed from the rcu_tasks_exit_list
in the later 2nd RCU period. So, if synchronize_rcu() is going
to wait for this 2nd period then it might end prematurely because
the quiescent state is reported by rcu_note_context_switch()
early in __schedule().
But I might miss something. I am not sure which period
synchronize_rcu() is waiting for.
Best Regards,
Petr
next prev parent reply other threads:[~2026-11-27 15:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 23:11 [PATCH v3 0/3] livepatch: Do not lose exiting tasks during a transition Binoy Ravindran via B4 Relay
2026-11-25 23:11 ` [PATCH v3 1/3] rcu-tasks: Add helpers to visit tasks on the exit lists Binoy Ravindran via B4 Relay
2026-11-25 23:11 ` [PATCH v3 2/3] livepatch: Include exiting tasks in the transition Binoy Ravindran via B4 Relay
2026-11-25 23:33 ` sashiko-bot
2026-11-26 0:58 ` Ravindran, Binoy
2026-11-26 3:12 ` Yafang Shao
2026-11-27 14:39 ` Petr Mladek
2026-11-27 15:10 ` Petr Mladek [this message]
2026-11-27 19:13 ` Ravindran, Binoy
2026-11-25 23:11 ` [PATCH v3 3/3] livepatch: Select TASKS_RCU Binoy Ravindran via B4 Relay
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=awmdVLfnwgrS9VfS@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=binoy@vt.edu \
--cc=boqun@kernel.org \
--cc=frederic@kernel.org \
--cc=jaidevshastri@vt.edu \
--cc=jiangshanlai@gmail.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=jpoimboe@kernel.org \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mbenes@suse.cz \
--cc=mingo@kernel.org \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=qiang.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=song@kernel.org \
--cc=urezki@gmail.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