mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Frederic Weisbecker" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Frederic Weisbecker <frederic@kernel.org>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/core] x86: Add a comment about the "magic" behind shadow sti before mwait
Date: Wed, 29 Nov 2023 14:55:55 -0000	[thread overview]
Message-ID: <170126975575.398.1797223222857571697.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20231115151325.6262-2-frederic@kernel.org>

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     7d09a052a3bdb62de9a86d43359d6c22eeaf105a
Gitweb:        https://git.kernel.org/tip/7d09a052a3bdb62de9a86d43359d6c22eeaf105a
Author:        Frederic Weisbecker <frederic@kernel.org>
AuthorDate:    Wed, 15 Nov 2023 10:13:22 -05:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 29 Nov 2023 15:44:01 +01:00

x86: Add a comment about the "magic" behind shadow sti before mwait

Add a note to make sure we never miss and break the requirements behind
it.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Link: https://lkml.kernel.org/r/20231115151325.6262-2-frederic@kernel.org
---
 arch/x86/include/asm/mwait.h |  9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h
index 778df05..341ee4f 100644
--- a/arch/x86/include/asm/mwait.h
+++ b/arch/x86/include/asm/mwait.h
@@ -87,6 +87,15 @@ static __always_inline void __mwaitx(unsigned long eax, unsigned long ebx,
 		     :: "a" (eax), "b" (ebx), "c" (ecx));
 }
 
+/*
+ * Re-enable interrupts right upon calling mwait in such a way that
+ * no interrupt can fire _before_ the execution of mwait, ie: no
+ * instruction must be placed between "sti" and "mwait".
+ *
+ * This is necessary because if an interrupt queues a timer before
+ * executing mwait, it would otherwise go unnoticed and the next tick
+ * would not be reprogrammed accordingly before mwait ever wakes up.
+ */
 static __always_inline void __sti_mwait(unsigned long eax, unsigned long ecx)
 {
 	mds_idle_clear_cpu_buffers();

  reply	other threads:[~2023-11-29 14:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-15 15:13 [PATCH 0/4] x86/cpuidle fixes and optimization Frederic Weisbecker
2023-11-15 15:13 ` [PATCH 1/4] x86: Add a comment about the "magic" behind shadow sti before mwait Frederic Weisbecker
2023-11-29 14:55   ` tip-bot2 for Frederic Weisbecker [this message]
2023-11-15 15:13 ` [PATCH 2/4] x86: Fix CPUIDLE_FLAG_IRQ_ENABLE leaking timer reprogram Frederic Weisbecker
2023-11-15 15:52   ` Peter Zijlstra
2023-11-15 15:57     ` Frederic Weisbecker
2023-11-29 14:55   ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2023-11-30 11:15     ` Peter Zijlstra
2023-12-12 13:46       ` Frederic Weisbecker
2023-11-15 15:13 ` [PATCH 3/4] x86: Remove __current_clr_polling() from mwait_idle() Frederic Weisbecker
2023-11-16 15:13   ` Peter Zijlstra
2023-11-16 18:48     ` Frederic Weisbecker
2023-11-15 15:13 ` [PATCH 4/4] x86: Remove the current_clr_polling() call upon mwait exit 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=170126975575.398.1797223222857571697.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=x86@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

all inboxes | Powered by JetHome®