xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RFC: Linux: disable APERF/MPERF feature in PV kernels
@ 2012-05-22 16:07 Andre Przywara
  2012-05-22 16:52 ` Jeremy Fitzhardinge
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Andre Przywara @ 2012-05-22 16:07 UTC (permalink / raw)
  To: Jan Beulich, Jeremy Fitzhardinge; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1032 bytes --]

Hi,

while testing some APERF/MPERF semantics I discovered that this feature 
is enabled in Xen Dom0, but is not reliable.
The Linux kernel's scheduler uses this feature if it sees the CPUID bit, 
leading to costly RDMSR traps (a few 100,000s during a kernel compile) 
and bogus values due to VCPU migration during the measurement.
The attached patch explicitly disables this CPU capability inside the 
Linux kernel, I couldn't measure any APERF/MPERF reads anymore with the 
patch applied.
I am not sure if the PVOPS code is the right place to fix this, we could 
as well do it in the HV's xen/arch/x86/traps.c:pv_cpuid().
Also when the Dom0 VCPUs are pinned, we could allow this, but I am not 
sure if it's worth to do so.

Awaiting your comments.

Regards,
Andre.

P.S. Of course this doesn't fix pure userland software like cpupower, 
but I would consider this in the user's responsibility to not use these 
tools in Dom0, but instead use xenpm.

-- 
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany

[-- Attachment #2: xenpv_aperfmperf.patch --]
[-- Type: text/x-patch, Size: 712 bytes --]

commit e802e47d85314b4541288e4a19d057e2ea885a28
Author: Andre Przywara <andre.przywara@amd.com>
Date:   Tue May 22 15:13:07 2012 +0200

    filter APERFMPERF feature in Xen to avoid kernel internal usage
    
    Signed-off-by: Andre Przywara <andre.przywara@amd.com>

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 95dccce..71252d5 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -240,6 +240,11 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
 		*dx = cpuid_leaf5_edx_val;
 		return;
 
+	case 6:
+		/* Disabling APERFMPERF for kernel usage */
+		maskecx = ~(1U << 0);
+		break;
+
 	case 0xb:
 		/* Suppress extended topology stuff */
 		maskebx = 0;

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

end of thread, other threads:[~2012-05-29 10:54 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-22 16:07 [PATCH] RFC: Linux: disable APERF/MPERF feature in PV kernels Andre Przywara
2012-05-22 16:52 ` Jeremy Fitzhardinge
2012-05-22 17:08   ` Malcolm Crossley
2012-05-23  8:10     ` Jan Beulich
2012-05-22 20:46   ` Andre Przywara
2012-05-22 17:18 ` Konrad Rzeszutek Wilk
2012-05-22 21:02   ` Andre Przywara
2012-05-22 21:00     ` Konrad Rzeszutek Wilk
2012-05-22 22:44       ` Andre Przywara
2012-05-23 13:26         ` Konrad Rzeszutek Wilk
2012-05-24 13:24           ` Andre Przywara
2012-05-29 10:54             ` Andre Przywara
2012-05-23  7:34 ` Jan Beulich
2012-05-23  9:14   ` Andre Przywara
2012-05-23  9:43     ` Jan Beulich
2012-05-23  9:52       ` Andre Przywara
2012-05-23 10:01         ` Jan Beulich
2012-05-23 11:11   ` Andrew Cooper
2012-05-23 12:18     ` Jan Beulich
2012-05-23 13:21       ` Andrew Cooper
2012-05-23 13:31         ` Andre Przywara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).