public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Miroslav Benes <mbenes@suse.cz>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>,
	mingo@kernel.com,  juri.lelli@redhat.com,
	vincent.guittot@linaro.org,  dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com,  mgorman@suse.de,
	vschneid@redhat.com, jpoimboe@kernel.org,  jikos@kernel.org,
	pmladek@suse.com, joe.lawrence@redhat.com,
	 linux-kernel@vger.kernel.org, live-patching@vger.kernel.org,
	 Thomas Gleixner <tglx@linutronix.de>,
	 Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: Re: [RFC][PATCH] sched,livepatch: Untangle cond_resched() and live-patching
Date: Wed, 26 Mar 2025 15:54:48 +0100 (CET)	[thread overview]
Message-ID: <alpine.LSU.2.21.2503261552360.4152@pobox.suse.cz> (raw)
In-Reply-To: <20250324134909.GA14718@noisy.programming.kicks-ass.net>

>  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

      parent reply	other threads:[~2025-03-26 14:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-24 13:49 [RFC][PATCH] sched,livepatch: Untangle cond_resched() and live-patching Peter Zijlstra
2025-03-26  9:49 ` Petr Mladek
2025-03-26 10:38   ` Peter Zijlstra
2025-03-26 14:37     ` Miroslav Benes
2025-03-26 14:42       ` Peter Zijlstra
2025-03-26 14:52         ` Miroslav Benes
2025-03-26 14:54 ` Miroslav Benes [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=alpine.LSU.2.21.2503261552360.4152@pobox.suse.cz \
    --to=mbenes@suse.cz \
    --cc=bigeasy@linutronix.de \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=jikos@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=jpoimboe@redhat.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.com \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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