x86/VPMU: implement ipc and arch filter flags
PATCH v3 1/1 x86/VPMU: implement ipc and arch filter flags
This introduces a way to have a restricted VPMU, by specifying one of two predefined groups of PMCs to make available. For secure environments, this allows the VPMU to be used without needing to enable all PMCs.
---
Changes in v3:
* addressing review comments from Boris:
* ensure final flag is validated
* code tidy
Changes in v2:
* feature flags can now be combined (eg, "vpmu=ipc,bts")
* addressing review comments from Boris:
* restrict DS_AREA and PEBS_ENABLE access when filters are in use
* better variable types
* include MSR_IA32_CMT_EVTSEL_UE_MASK flag
--- docs/misc/xen-command-line.markdown | 14 +++++++++- xen/arch/x86/cpu/vpmu.c | 51 +++++++++++++++++++++++++++++-------- xen/arch/x86/cpu/vpmu_intel.c | 49 +++++++++++++++++++++++++++++++++++ xen/include/asm-x86/msr-index.h | 1 + xen/include/public/pmu.h | 14 ++++++++-- 5 files changed, 115 insertions(+), 14 deletions(-)
docs/misc/xen-command-line.markdown +13 -1
@@ -1452,7 +1452,7 @@ Use Virtual Processor ID support if available. This prevents the need for TLB flushes on VM entry and exit, increasing performance. ### vpmu -> `= ( bts )` +> `= ( <boolean> | { bts | ipc | arch [, ...] } )` > Default: `off`
@@ -1468,6 +1468,18 @@ wrong behaviour (see handle\_pmc\_quirk()). If 'vpmu=bts' is specified the virtualisation of the Branch Trace Store (BTS) feature is switched on on Intel processors supporting this feature. +vpmu=ipc enables performance monitoring, but restricts the counters to the +most minimum set possible: instructions, cycles, and reference cycles. These +can be used to calculate instructions per cycle (IPC). + +vpmu=arch enables performance monitoring, but restricts the counters to the +pre-defined architectural events only. These are exposed by cpuid, and listed +in Table 18-1 from the Intel 64 and IA-32 Architectures Software Developer's +Manual, Volume 3B, System Programming Guide, Part 2. + +If a boolean is not used, combinations of flags are allowed, comma separated. +For example, vpmu=arch,bts. + Note that if **watchdog** option is also specified vpmu will be turned off. *Warning:*
xen/arch/x86/cpu/vpmu.c +40 -11
80 lines not on this page · raw message
xen/arch/x86/cpu/vpmu_intel.c +49 -0
73 lines not on this page · raw message
xen/include/asm-x86/msr-index.h +1 -0
@@ -328,6 +328,7 @@/* Platform Shared Resource MSRs */ #define MSR_IA32_CMT_EVTSEL 0x00000c8d +#define MSR_IA32_CMT_EVTSEL_UE_MASK 0x0000ffff#define MSR_IA32_CMT_CTR 0x00000c8e#define MSR_IA32_PSR_ASSOC 0x00000c8f#define MSR_IA32_PSR_L3_QOS_CFG 0x00000c81
xen/include/public/pmu.h +12 -2
@@ -84,9 +84,19 @@ DEFINE_XEN_GUEST_HANDLE(xen_pmu_params_t);/* * PMU features: -* - XENPMU_FEATURE_INTEL_BTS: Intel BTS support (ignored on AMD) +* - XENPMU_FEATURE_INTEL_BTS: Intel BTS support (ignored on AMD) +* - XENPMU_FEATURE_IPC_ONLY: Restrict PMC to the most minimum set possible. +* Instructions, cycles, and ref cycles. Can be +* used to calculate instructions-per-cycle (IPC) +* (ignored on AMD). +* - XENPMU_FEATURE_ARCH_ONLY: Restrict PMCs to the Intel pre-defined +* architecteral events exposed by cpuid and +* listed in Table 18-1 of the developer's manual +* (ignored on AMD). */ -#define XENPMU_FEATURE_INTEL_BTS 1 +#define XENPMU_FEATURE_INTEL_BTS (1<<0) +#define XENPMU_FEATURE_IPC_ONLY (1<<1) +#define XENPMU_FEATURE_ARCH_ONLY (1<<2)/* * Shared PMU data between hypervisor and PV(H) domains.
Signature · 1 line
1.9.1
Quoted 17 lines · Brendan Gregg
This introduces a way to have a restricted VPMU, by specifying one of two predefined groups of PMCs to make available. For secure environments, this allows the VPMU to be used without needing to enable all PMCs.
Signed-off-by Brendan Gregg <[email protected]>---
Changes in v3:
* addressing review comments from Boris:
* ensure final flag is validated
* code tidyChanges in v2:
* feature flags can now be combined (eg, "vpmu=ipc,bts")
* addressing review comments from Boris:
* restrictDS_AREAandPEBS_ENABLEaccess when filters are in use
* better variable types
* includeMSR_IA32_CMT_EVTSEL_UE_MASKflag
Quoted 6 lines
--- docs/misc/xen-command-line.markdown | 14 +++++++++- xen/arch/x86/cpu/vpmu.c | 51 +++++++++++++++++++++++++++++-------- xen/arch/x86/cpu/vpmu_intel.c | 49 +++++++++++++++++++++++++++++++++++ xen/include/asm-x86/msr-index.h | 1 + xen/include/public/pmu.h | 14 ++++++++--