public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Huacai Chen <chenhuacai@kernel.org>,
	WANG Xuerui <kernel@xen0n.name>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Anna-Maria Behnsen <anna-maria@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: Loongson (and other $ARCHs?) idle VS timer enqueue
Date: Sat, 22 Apr 2023 16:48:40 +0200	[thread overview]
Message-ID: <ZEPzyGZciQF5TPLU@localhost.localdomain> (raw)
In-Reply-To: <20230422113811.GB1215777@hirez.programming.kicks-ass.net>

eeLe Sat, Apr 22, 2023 at 01:38:11PM +0200, Peter Zijlstra a écrit :
> On Sat, Apr 22, 2023 at 10:08:14AM +0200, Peter Zijlstra wrote:
> > On Fri, Apr 21, 2023 at 06:47:29PM +0200, Frederic Weisbecker wrote:
> > 
> > > > *HOWEVER*
> > > > 
> > > > intel_idle_irq() is affected -- except that we only (normally) use that
> > > > for very shallow idle states and it won't interact with NOHZ (because we
> > > > only disable the tick for deep idle states).
> > > 
> > > Well I don't know, that doesn't look comfortable... :)
> > > 
> > > Also why does it need to enable IRQs if ecx=1 ?
> > 
> > Supposedly this is some interrupt latency hack. See commit:
> > 
> >   c227233ad64c ("intel_idle: enable interrupts before C1 on Xeons")
> 
> Something like so perhaps...
> 
> diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h
> index 778df05f8539..07a4072c43de 100644
> --- a/arch/x86/include/asm/mwait.h
> +++ b/arch/x86/include/asm/mwait.h
> @@ -115,8 +115,14 @@ static __always_inline void mwait_idle_with_hints(unsigned long eax, unsigned lo
>  		}
>  
>  		__monitor((void *)&current_thread_info()->flags, 0, 0);
> -		if (!need_resched())
> -			__mwait(eax, ecx);
> +		if (!need_resched()) {
> +			if (ecx & 1) {
> +				__mwait(eax, ecx);
> +			} else {
> +				__sti_mwait(eax, ecx);
> +				raw_local_irq_disable();
> +			}
> +		}

Yep that looks good!

Thanks!

  reply	other threads:[~2023-04-22 14:48 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 12:36 Loongson (and other $ARCHs?) idle VS timer enqueue Frederic Weisbecker
2023-04-21 14:24 ` Peter Zijlstra
2023-04-21 16:47   ` Frederic Weisbecker
2023-04-22  8:08     ` Peter Zijlstra
2023-04-22 11:38       ` Peter Zijlstra
2023-04-22 14:48         ` Frederic Weisbecker [this message]
2023-04-21 15:24 ` Thomas Gleixner
2023-04-21 16:55   ` Frederic Weisbecker
2023-04-21 20:28     ` Thomas Gleixner
2023-04-22  8:17   ` Peter Zijlstra
2023-04-22  8:22     ` Peter Zijlstra
2023-04-22 14:21     ` Frederic Weisbecker
2023-04-22 15:04       ` Peter Zijlstra
2023-04-23 13:52         ` bibo, mao
2023-04-24  8:26           ` Frederic Weisbecker
2023-04-24 11:23             ` maobibo
2023-04-25 11:49           ` Peter Zijlstra
2023-04-25 13:25             ` maobibo
2023-04-25 13:28               ` WANG Xuerui
2023-04-26  0:46                 ` maobibo
2023-04-26  2:10                   ` WANG Xuerui
2023-04-26  2:23                     ` maobibo
2023-06-06 22:07             ` Frederic Weisbecker

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=ZEPzyGZciQF5TPLU@localhost.localdomain \
    --to=frederic@kernel.org \
    --cc=anna-maria@linutronix.de \
    --cc=chenhuacai@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tglx@linutronix.de \
    /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