[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LSU.2.21.2503261552360.4152@pobox.suse.cz>
Date: Wed, 26 Mar 2025 15:54:48 +0100 (CET)
From: Miroslav Benes <mbenes@...e.cz>
To: Peter Zijlstra <peterz@...radead.org>
cc: Josh Poimboeuf <jpoimboe@...hat.com>, mingo@...nel.com,
juri.lelli@...hat.com, vincent.guittot@...aro.org,
dietmar.eggemann@....com, rostedt@...dmis.org, bsegall@...gle.com,
mgorman@...e.de, vschneid@...hat.com, jpoimboe@...nel.org,
jikos@...nel.org, pmladek@...e.com, joe.lawrence@...hat.com,
linux-kernel@...r.kernel.org, live-patching@...r.kernel.org,
Thomas Gleixner <tglx@...utronix.de>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Subject: Re: [RFC][PATCH] sched,livepatch: Untangle cond_resched() and
live-patching
> void __klp_sched_try_switch(void)
> {
> - if (likely(!klp_patch_pending(current)))
> - return;
> -
> /*
> * This function is called from cond_resched() which is called in many
> * places throughout the kernel. Using the klp_mutex here might
> @@ -377,14 +365,14 @@ void __klp_sched_try_switch(void)
> * klp_try_switch_task(). Thanks to task_call_func() they won't be
> * able to switch this task while it's running.
> */
> - preempt_disable();
> + lockdep_assert_preemption_disabled();
>
> /*
> * Make sure current didn't get patched between the above check and
> * preempt_disable().
> */
> if (unlikely(!klp_patch_pending(current)))
> - goto out;
> + return;
It does not look correct. We just make sure that
klp_patch_pending(current) did not change here. It would be highly
unlikely. However, we should keep the likely way out (the first removed
condition above). So let's also s/unlikely/likely/ here.
And the comments in the function should be updated as well.
Miroslav
Powered by blists - more mailing lists