xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Andre Przywara <andre.przywara@amd.com>
Cc: jeremy@goop.org, xen-devel@lists.xensource.com,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org.#.v3.0+
Subject: Re: [PATCH] xen: filter APERFMPERF feature for kernel usage
Date: Thu, 31 May 2012 12:17:32 -0400	[thread overview]
Message-ID: <20120531161732.GA14197@phenom.dumpdata.com> (raw)
In-Reply-To: <1338289651-15843-1-git-send-email-andre.przywara@amd.com>

On Tue, May 29, 2012 at 01:07:31PM +0200, Andre Przywara wrote:
> Xen PV kernels allow access to the APERF/MPERF registers to read the
> effective frequency. Access to the MSRs is however redirected to the
> currently scheduled physical CPU, making consecutive read and
> compares unreliable. In addition each rdmsr traps into the hypervisor.
> So to avoid bogus readouts and expensive traps, disable the kernel
> internal feature flag for APERF/MPERF if running under Xen.
> This will
> a) remove the aperfmperf flag from /proc/cpuinfo
> b) not mislead the power scheduler (arch/x86/kernel/cpu/sched.c) to
>    use the feature to improve scheduling (by default disabled)
> c) not mislead the cpufreq driver to use the MSRs
> 
> This does not cover userland programs which access the MSRs via the
> device file interface, but this will be addressed separately.
> 
> Signed-off-by: Andre Przywara <andre.przywara@amd.com>
> Cc: stable@vger.kernel.org # v3.0+

applied.
> ---
>  arch/x86/xen/enlighten.c |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> index 95dccce..dfbe1af 100644
> --- a/arch/x86/xen/enlighten.c
> +++ b/arch/x86/xen/enlighten.c
> @@ -207,6 +207,9 @@ static void __init xen_banner(void)
>  	       xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : "");
>  }
>  
> +#define CPUID_THERM_POWER_LEAF 6
> +#define APERFMPERF_PRESENT 0
> +
>  static __read_mostly unsigned int cpuid_leaf1_edx_mask = ~0;
>  static __read_mostly unsigned int cpuid_leaf1_ecx_mask = ~0;
>  
> @@ -240,6 +243,11 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
>  		*dx = cpuid_leaf5_edx_val;
>  		return;
>  
> +	case CPUID_THERM_POWER_LEAF:
> +		/* Disabling APERFMPERF for kernel usage */
> +		maskecx = ~(1 << APERFMPERF_PRESENT);
> +		break;
> +
>  	case 0xb:
>  		/* Suppress extended topology stuff */
>  		maskebx = 0;
> -- 
> 1.7.4.4
> 

      reply	other threads:[~2012-05-31 16:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-29 11:07 [PATCH] xen: filter APERFMPERF feature for kernel usage Andre Przywara
2012-05-31 16:17 ` Konrad Rzeszutek Wilk [this message]

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=20120531161732.GA14197@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=andre.przywara@amd.com \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org.#.v3.0+ \
    --cc=xen-devel@lists.xensource.com \
    /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;
as well as URLs for NNTP newsgroup(s).