From: Borislav Petkov <bp@alien8.de>
To: X86 ML <x86@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
LKML <linux-kernel@vger.kernel.org>,
Andy Lutomirski <luto@kernel.org>, Huang Rui <ray.huang@amd.com>,
spg_linux_kernel@amd.com
Subject: [RFC PATCH] x86/delay: Do not use cpu_tss in preemptible ctxt in delay_mwaitx()
Date: Wed, 9 Mar 2016 12:37:53 +0100 [thread overview]
Message-ID: <1457523473-3285-1-git-send-email-bp@alien8.de> (raw)
From: Borislav Petkov <bp@suse.de>
So Andy had a good idea about using a cacheline-aligned, seldomly used
per-cpu var as the MONITORX target but we can't use it in preemptible
context. The first simple idea I have is to disable preemption around us
dereffing it.
Better ideas?
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Huang Rui <ray.huang@amd.com>
Cc: spg_linux_kernel@amd.com
---
arch/x86/lib/delay.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c
index e912b2f6d36e..c1810afcd2ea 100644
--- a/arch/x86/lib/delay.c
+++ b/arch/x86/lib/delay.c
@@ -92,17 +92,22 @@ static void delay_tsc(unsigned long __loops)
static void delay_mwaitx(unsigned long __loops)
{
u64 start, end, delay, loops = __loops;
+ struct tss_struct *t;
+
+ /*
+ * Use cpu_tss as a cacheline-aligned, seldomly accessed per-cpu
+ * variable as the monitor target.
+ */
+ preempt_disable();
+ t = this_cpu_ptr(&cpu_tss);
+ preempt_enable();
start = rdtsc_ordered();
for (;;) {
delay = min_t(u64, MWAITX_MAX_LOOPS, loops);
- /*
- * Use cpu_tss as a cacheline-aligned, seldomly
- * accessed per-cpu variable as the monitor target.
- */
- __monitorx(this_cpu_ptr(&cpu_tss), 0, 0);
+ __monitorx(t, 0, 0);
/*
* AMD, like Intel, supports the EAX hint and EAX=0xf
--
2.3.5
next reply other threads:[~2016-03-09 11:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-09 11:37 Borislav Petkov [this message]
2016-03-09 17:56 ` Andy Lutomirski
2016-03-09 18:10 ` Borislav Petkov
2016-03-09 20:56 ` [PATCH] x86/delay: Avoid preemptible context checks " Borislav Petkov
2016-03-10 11:07 ` [tip:x86/urgent] " tip-bot for Borislav Petkov
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=1457523473-3285-1-git-send-email-bp@alien8.de \
--to=bp@alien8.de \
--cc=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=ray.huang@amd.com \
--cc=spg_linux_kernel@amd.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
Powered by JetHome