public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chen Yu <yu.c.chen@intel.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>, Ingo Molnar <mingo@redhat.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	"Vincent Guittot" <vincent.guittot@linaro.org>,
	Will Deacon <will@kernel.org>, <linux-doc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	"Valentin Schneider" <valentin.schneider@arm.com>,
	Marco Elver <elver@google.com>,
	Frederic Weisbecker <frederic@kernel.org>,
	David Matlack <dmatlack@google.com>,
	Friedrich Weber <f.weber@proxmox.com>,
	Ankur Arora <ankur.a.arora@oracle.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2 2/2] sched/core: Drop spinlocks on contention iff kernel is preemptible
Date: Fri, 26 Apr 2024 11:41:25 +0800	[thread overview]
Message-ID: <ZisiZUWgERCZbc9w@chenyu5-mobl2> (raw)
In-Reply-To: <ZiqJOJEBshsQLl0M@google.com>

On 2024-04-25 at 09:47:52 -0700, Sean Christopherson wrote:
> On Thu, Apr 25, 2024, Chen Yu wrote:
> > Hi Sean,
> > 
> > On 2024-03-12 at 12:39:11 -0700, Sean Christopherson wrote:
> > > Use preempt_model_preemptible() to detect a preemptible kernel when
> > > deciding whether or not to reschedule in order to drop a contended
> > > spinlock or rwlock.  Because PREEMPT_DYNAMIC selects PREEMPTION, kernels
> > 
> > It took me a while to wonder why PREEMPT_DYNAMIC selects PREEMPTION
> > in Kconfig, then I assume that you mean the static config is CONFIG_PREEMPTION,
> > but the live preemption model is "none" or "voluntary", which makes the
> > static check of CONFIG_PREEMPTION in spin_needbreak() and rwlock_needbreak()
> > invalid?
> 
> Yep, exactly.
> 
> > > diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
> > > index 3fcd20de6ca8..63dd8cf3c3c2 100644
> > > --- a/include/linux/spinlock.h
> > > +++ b/include/linux/spinlock.h
> > > @@ -462,11 +462,10 @@ static __always_inline int spin_is_contended(spinlock_t *lock)
> > >   */
> > >  static inline int spin_needbreak(spinlock_t *lock)
> > >  {
> > > -#ifdef CONFIG_PREEMPTION
> > > +	if (!preempt_model_preemptible())
> > 
> > The old version checks against static CONFIG_PREEMPTION, now we check
> > the live CONFIG_PREEMPTION and static CONFIG_PREEMPT_RT, just wonder
> > if the rt check is needed here?
> 
> It's required, as CONFIG_PREEMPT_RT=y doesn't imply CONFIG_PREEMPT, and
> CONFIG_PREEMPT_RT=y is mutually exclusive with CONFIG_PREEMPT_DYNAMIC.  I.e. a
> CONFIG_PREEMPT_RT=y kernel will look yield:
> 
>   CONFIG_PREEMPT_RT=y
>   CONFIG_PREEMPT_DYNAMIC=n
>   CONFIG_PREEMPT=n
> 
> which in turn generates:
> 
>   static inline bool preempt_model_full(void)
>   {
> 	return IS_ENABLED(CONFIG_PREEMPT);
>   }
> 
> and so just checking preempt_model_full() would incorrectly return false for
> CONFIG_PREEMPT_RT=y.

You are right,  I missunderstood the definition of preempt_model_full(). For my
understanding of this patch:

Reviewed-by: Chen Yu <yu.c.chen@intel.com>

thanks,
Chenyu

  reply	other threads:[~2024-04-26  3:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 19:39 [PATCH v2 0/2] sched/core: Fix spinlocks vs. PREEMPT_DYNAMIC=y Sean Christopherson
2024-03-12 19:39 ` [PATCH v2 1/2] sched/core: Move preempt_model_*() helpers from sched.h to preempt.h Sean Christopherson
2024-04-25  6:19   ` Ankur Arora
2024-03-12 19:39 ` [PATCH v2 2/2] sched/core: Drop spinlocks on contention iff kernel is preemptible Sean Christopherson
2024-04-25  6:18   ` Ankur Arora
2024-04-25  7:41   ` Chen Yu
2024-04-25 16:47     ` Sean Christopherson
2024-04-26  3:41       ` Chen Yu [this message]
2024-04-24 20:08 ` [PATCH v2 0/2] sched/core: Fix spinlocks vs. PREEMPT_DYNAMIC=y Sean Christopherson

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=ZisiZUWgERCZbc9w@chenyu5-mobl2 \
    --to=yu.c.chen@intel.com \
    --cc=ankur.a.arora@oracle.com \
    --cc=corbet@lwn.net \
    --cc=dmatlack@google.com \
    --cc=elver@google.com \
    --cc=f.weber@proxmox.com \
    --cc=frederic@kernel.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=valentin.schneider@arm.com \
    --cc=vincent.guittot@linaro.org \
    --cc=will@kernel.org \
    /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