From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andre Przywara Subject: [PATCH] RFC: Linux: disable APERF/MPERF feature in PV kernels Date: Tue, 22 May 2012 18:07:11 +0200 Message-ID: <4FBBB9AF.6020704@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050004060407060101060807" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , Jeremy Fitzhardinge Cc: xen-devel List-Id: xen-devel@lists.xenproject.org --------------050004060407060101060807 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit 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 --------------050004060407060101060807 Content-Type: text/x-patch; name="xenpv_aperfmperf.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xenpv_aperfmperf.patch" Content-Description: xenpv_aperfmperf.patch commit e802e47d85314b4541288e4a19d057e2ea885a28 Author: Andre Przywara Date: Tue May 22 15:13:07 2012 +0200 filter APERFMPERF feature in Xen to avoid kernel internal usage Signed-off-by: Andre Przywara 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; --------------050004060407060101060807 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --------------050004060407060101060807--