From: "tip-bot2 for Kyung Min Park" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Fenghua Yu <fenghua.yu@intel.com>,
Kyung Min Park <kyung.min.park@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Tony Luck <tony.luck@intel.com>, x86 <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [tip: x86/timers] x86/delay: Refactor delay_mwaitx() for TPAUSE support
Date: Thu, 07 May 2020 14:13:26 -0000 [thread overview]
Message-ID: <158886080690.8414.16414662834297433879.tip-bot2@tip-bot2> (raw)
In-Reply-To: <1587757076-30337-3-git-send-email-kyung.min.park@intel.com>
The following commit has been merged into the x86/timers branch of tip:
Commit-ID: 46f90c7aad62be1af76588108c730d826308a801
Gitweb: https://git.kernel.org/tip/46f90c7aad62be1af76588108c730d826308a801
Author: Kyung Min Park <kyung.min.park@intel.com>
AuthorDate: Fri, 24 Apr 2020 12:37:55 -07:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 07 May 2020 16:06:19 +02:00
x86/delay: Refactor delay_mwaitx() for TPAUSE support
Refactor code to make it easier to add a new model specific function to
delay for a number of cycles.
No functional change.
Co-developed-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Kyung Min Park <kyung.min.park@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Link: https://lkml.kernel.org/r/1587757076-30337-3-git-send-email-kyung.min.park@intel.com
---
arch/x86/lib/delay.c | 48 ++++++++++++++++++++++++++-----------------
1 file changed, 30 insertions(+), 18 deletions(-)
diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c
index 887d52d..fe91dc1 100644
--- a/arch/x86/lib/delay.c
+++ b/arch/x86/lib/delay.c
@@ -34,6 +34,7 @@ static void delay_loop(u64 __loops);
* during boot.
*/
static void (*delay_fn)(u64) __ro_after_init = delay_loop;
+static void (*delay_halt_fn)(u64 start, u64 cycles) __ro_after_init;
/* simple loop based delay: */
static void delay_loop(u64 __loops)
@@ -100,9 +101,33 @@ static void delay_tsc(u64 cycles)
* counts with TSC frequency. The input value is the number of TSC cycles
* to wait. MWAITX will also exit when the timer expires.
*/
-static void delay_mwaitx(u64 cycles)
+static void delay_halt_mwaitx(u64 unused, u64 cycles)
{
- u64 start, end, delay;
+ u64 delay;
+
+ delay = min_t(u64, MWAITX_MAX_WAIT_CYCLES, cycles);
+ /*
+ * Use cpu_tss_rw as a cacheline-aligned, seldomly accessed per-cpu
+ * variable as the monitor target.
+ */
+ __monitorx(raw_cpu_ptr(&cpu_tss_rw), 0, 0);
+
+ /*
+ * AMD, like Intel, supports the EAX hint and EAX=0xf means, do not
+ * enter any deep C-state and we use it here in delay() to minimize
+ * wakeup latency.
+ */
+ __mwaitx(MWAITX_DISABLE_CSTATES, delay, MWAITX_ECX_TIMER_ENABLE);
+}
+
+/*
+ * Call a vendor specific function to delay for a given amount of time. Because
+ * these functions may return earlier than requested, check for actual elapsed
+ * time and call again until done.
+ */
+static void delay_halt(u64 __cycles)
+{
+ u64 start, end, cycles = __cycles;
/*
* Timer value of 0 causes MWAITX to wait indefinitely, unless there
@@ -114,21 +139,7 @@ static void delay_mwaitx(u64 cycles)
start = rdtsc_ordered();
for (;;) {
- delay = min_t(u64, MWAITX_MAX_WAIT_CYCLES, cycles);
-
- /*
- * Use cpu_tss_rw as a cacheline-aligned, seldomly
- * accessed per-cpu variable as the monitor target.
- */
- __monitorx(raw_cpu_ptr(&cpu_tss_rw), 0, 0);
-
- /*
- * AMD, like Intel's MWAIT version, supports the EAX hint and
- * EAX=0xf0 means, do not enter any deep C-state and we use it
- * here in delay() to minimize wakeup latency.
- */
- __mwaitx(MWAITX_DISABLE_CSTATES, delay, MWAITX_ECX_TIMER_ENABLE);
-
+ delay_halt_fn(start, cycles);
end = rdtsc_ordered();
if (cycles <= end - start)
@@ -147,7 +158,8 @@ void __init use_tsc_delay(void)
void use_mwaitx_delay(void)
{
- delay_fn = delay_mwaitx;
+ delay_halt_fn = delay_halt_mwaitx;
+ delay_fn = delay_halt;
}
int read_current_timer(unsigned long *timer_val)
next prev parent reply other threads:[~2020-05-07 14:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 19:37 [PATCH v4 0/3] x86/delay: Introduce TPAUSE instruction Kyung Min Park
2020-04-24 19:37 ` [PATCH v4 1/3] x86/delay: Preparatory code cleanup Kyung Min Park
2020-05-07 14:13 ` [tip: x86/timers] " tip-bot2 for Thomas Gleixner
2020-04-24 19:37 ` [PATCH v4 2/3] x86/delay: Refactor delay_mwaitx() for TPAUSE support Kyung Min Park
2020-05-07 14:13 ` tip-bot2 for Kyung Min Park [this message]
2020-04-24 19:37 ` [PATCH v4 3/3] x86/delay: Introduce TPAUSE delay Kyung Min Park
2020-05-07 14:13 ` [tip: x86/timers] " tip-bot2 for Kyung Min Park
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=158886080690.8414.16414662834297433879.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=fenghua.yu@intel.com \
--cc=kyung.min.park@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--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®