public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/kernel/cpu/amd.c: use indirect call
@ 2017-07-11 11:44 Mikulas Patocka
  2017-07-12 13:09 ` [tip:x86/urgent] x86/cpu: Use indirect call to measure performance in init_amd_k6() tip-bot for Mikulas Patocka
  2017-07-16  9:14 ` tip-bot for Mikulas Patocka
  0 siblings, 2 replies; 5+ messages in thread
From: Mikulas Patocka @ 2017-07-11 11:44 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin; +Cc: x86, linux-kernel

This old piece of code is supposed to measure the performance of indirect
calls to determine if the processor is buggy or not, however the compiler
optimizer turns it into a direct call.

Use the macro OPTIMIZER_HIDE_VAR to thwart the optimization, so that real 
indirect call is generated.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 arch/x86/kernel/cpu/amd.c |    1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6/arch/x86/kernel/cpu/amd.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/amd.c
+++ linux-2.6/arch/x86/kernel/cpu/amd.c
@@ -134,6 +134,7 @@ static void init_amd_k6(struct cpuinfo_x
 
 		n = K6_BUG_LOOP;
 		f_vide = vide;
+		OPTIMIZER_HIDE_VAR(f_vide);
 		d = rdtsc();
 		while (n--)
 			f_vide();

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:x86/urgent] x86/cpu: Use indirect call to measure performance in init_amd_k6()
  2017-07-11 11:44 [PATCH] x86/kernel/cpu/amd.c: use indirect call Mikulas Patocka
@ 2017-07-12 13:09 ` tip-bot for Mikulas Patocka
  2017-07-12 13:48   ` Borislav Petkov
  2017-07-16  9:14 ` tip-bot for Mikulas Patocka
  1 sibling, 1 reply; 5+ messages in thread
From: tip-bot for Mikulas Patocka @ 2017-07-12 13:09 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: brgerst, dvlasenk, peterz, mpatocka, hpa, tglx, linux-kernel,
	luto, jpoimboe, torvalds, mingo, bp

Commit-ID:  429ed86b5c99b388543f6f7f6983b1230326f2bb
Gitweb:     http://git.kernel.org/tip/429ed86b5c99b388543f6f7f6983b1230326f2bb
Author:     Mikulas Patocka <mpatocka@redhat.com>
AuthorDate: Tue, 11 Jul 2017 07:44:05 -0400
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 12 Jul 2017 10:42:32 +0200

x86/cpu: Use indirect call to measure performance in init_amd_k6()

This old piece of code is supposed to measure the performance of indirect
calls to determine if the processor is buggy or not, however the compiler
optimizer turns it into a direct call.

Use the OPTIMIZER_HIDE_VAR() macro to thwart the optimization, so that a real
indirect call is generated.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1707110737530.8746@file01.intranet.prod.int.rdu2.redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/amd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index bb5abe8..3b9e220 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -134,6 +134,7 @@ static void init_amd_k6(struct cpuinfo_x86 *c)
 
 		n = K6_BUG_LOOP;
 		f_vide = vide;
+		OPTIMIZER_HIDE_VAR(f_vide);
 		d = rdtsc();
 		while (n--)
 			f_vide();

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [tip:x86/urgent] x86/cpu: Use indirect call to measure performance in init_amd_k6()
  2017-07-12 13:09 ` [tip:x86/urgent] x86/cpu: Use indirect call to measure performance in init_amd_k6() tip-bot for Mikulas Patocka
@ 2017-07-12 13:48   ` Borislav Petkov
  2017-07-13  2:20     ` Mikulas Patocka
  0 siblings, 1 reply; 5+ messages in thread
From: Borislav Petkov @ 2017-07-12 13:48 UTC (permalink / raw)
  To: Mikulas Patocka
  Cc: linux-tip-commits, brgerst, dvlasenk, peterz, mpatocka, hpa, tglx,
	linux-kernel, luto, jpoimboe, torvalds, mingo

On Wed, Jul 12, 2017 at 06:09:57AM -0700, tip-bot for Mikulas Patocka wrote:
> Commit-ID:  429ed86b5c99b388543f6f7f6983b1230326f2bb
> Gitweb:     http://git.kernel.org/tip/429ed86b5c99b388543f6f7f6983b1230326f2bb
> Author:     Mikulas Patocka <mpatocka@redhat.com>
> AuthorDate: Tue, 11 Jul 2017 07:44:05 -0400
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Wed, 12 Jul 2017 10:42:32 +0200
> 
> x86/cpu: Use indirect call to measure performance in init_amd_k6()
> 
> This old piece of code is supposed to measure the performance of indirect
> calls to determine if the processor is buggy or not, however the compiler
> optimizer turns it into a direct call.

Are you booting on a real K6 or qemu?

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [tip:x86/urgent] x86/cpu: Use indirect call to measure performance in init_amd_k6()
  2017-07-12 13:48   ` Borislav Petkov
@ 2017-07-13  2:20     ` Mikulas Patocka
  0 siblings, 0 replies; 5+ messages in thread
From: Mikulas Patocka @ 2017-07-13  2:20 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: linux-tip-commits, brgerst, dvlasenk, peterz, hpa, tglx,
	linux-kernel, luto, jpoimboe, torvalds, mingo



On Wed, 12 Jul 2017, Borislav Petkov wrote:

> On Wed, Jul 12, 2017 at 06:09:57AM -0700, tip-bot for Mikulas Patocka wrote:
> > Commit-ID:  429ed86b5c99b388543f6f7f6983b1230326f2bb
> > Gitweb:     http://git.kernel.org/tip/429ed86b5c99b388543f6f7f6983b1230326f2bb
> > Author:     Mikulas Patocka <mpatocka@redhat.com>
> > AuthorDate: Tue, 11 Jul 2017 07:44:05 -0400
> > Committer:  Ingo Molnar <mingo@kernel.org>
> > CommitDate: Wed, 12 Jul 2017 10:42:32 +0200
> > 
> > x86/cpu: Use indirect call to measure performance in init_amd_k6()
> > 
> > This old piece of code is supposed to measure the performance of indirect
> > calls to determine if the processor is buggy or not, however the compiler
> > optimizer turns it into a direct call.
> 
> Are you booting on a real K6 or qemu?

I tested it on K6-3 and it doesn't trigger the warning, the loop with the 
indirect call takes 9 million cycles (it took 4 million cycles with the 
direct call).

I don't have the old K6 revision with the bug.

Mikulas

> -- 
> Regards/Gruss,
>     Boris.
> 
> ECO tip #101: Trim your mails when you reply.
> --

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:x86/urgent] x86/cpu: Use indirect call to measure performance in init_amd_k6()
  2017-07-11 11:44 [PATCH] x86/kernel/cpu/amd.c: use indirect call Mikulas Patocka
  2017-07-12 13:09 ` [tip:x86/urgent] x86/cpu: Use indirect call to measure performance in init_amd_k6() tip-bot for Mikulas Patocka
@ 2017-07-16  9:14 ` tip-bot for Mikulas Patocka
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Mikulas Patocka @ 2017-07-16  9:14 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jpoimboe, tglx, brgerst, linux-kernel, luto, mingo, hpa, peterz,
	bp, mpatocka, torvalds, dvlasenk

Commit-ID:  5f8a16156aa1b2d0223eaee9dacdfb9bc096f610
Gitweb:     http://git.kernel.org/tip/5f8a16156aa1b2d0223eaee9dacdfb9bc096f610
Author:     Mikulas Patocka <mpatocka@redhat.com>
AuthorDate: Tue, 11 Jul 2017 07:44:05 -0400
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 16 Jul 2017 11:05:04 +0200

x86/cpu: Use indirect call to measure performance in init_amd_k6()

This old piece of code is supposed to measure the performance of indirect
calls to determine if the processor is buggy or not, however the compiler
optimizer turns it into a direct call.

Use the OPTIMIZER_HIDE_VAR() macro to thwart the optimization, so that a real
indirect call is generated.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1707110737530.8746@file01.intranet.prod.int.rdu2.redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/amd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index bb5abe8..3b9e220 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -134,6 +134,7 @@ static void init_amd_k6(struct cpuinfo_x86 *c)
 
 		n = K6_BUG_LOOP;
 		f_vide = vide;
+		OPTIMIZER_HIDE_VAR(f_vide);
 		d = rdtsc();
 		while (n--)
 			f_vide();

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-07-16  9:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-11 11:44 [PATCH] x86/kernel/cpu/amd.c: use indirect call Mikulas Patocka
2017-07-12 13:09 ` [tip:x86/urgent] x86/cpu: Use indirect call to measure performance in init_amd_k6() tip-bot for Mikulas Patocka
2017-07-12 13:48   ` Borislav Petkov
2017-07-13  2:20     ` Mikulas Patocka
2017-07-16  9:14 ` tip-bot for Mikulas Patocka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox