From 0265bbeee375428837b39a6a90ed5a1ac9c9c395 Mon Sep 17 00:00:00 2001 From: Nitesh Konkar Date: Thu, 23 Feb 2017 20:25:38 +0530 Subject: [PATCH] perf: add emulation_faults software perf event support This patch adds support and documentation for the emulation_faults perf event. Signed-off-by: Nitesh Konkar --- docs/formatdomain.html.in | 9 +++++++++ docs/schemas/domaincommon.rng | 1 + include/libvirt/libvirt-domain.h | 10 ++++++++++ src/libvirt-domain.c | 3 +++ src/qemu/qemu_driver.c | 1 + src/util/virperf.c | 5 ++++- src/util/virperf.h | 1 + tests/genericxml2xmlindata/generic-perf.xml | 1 + tools/virsh.pod | 3 +++ 9 files changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 680b98593f..68d664151d 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1955,6 +1955,7 @@ <event name='page_faults_min' enabled='no'/> <event name='page_faults_maj' enabled='no'/> <event name='alignment_faults' enabled='no'/> + <event name='emulation_faults' enabled='no'/> </perf> ... @@ -2090,6 +2091,14 @@ applications running on the platform perf.alignment_faults + + emulation_faults + the count of emulation faults, that is when + the kernel traps on unimplemented instrucions + and emulates them for user space, by + applications running on the platform + perf.emulation_faults +

Devices

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 1f0c729148..1860f9075b 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -441,6 +441,7 @@ page_faults_min page_faults_maj alignment_faults + emulation_faults diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 0c0fb182da..c490d712f2 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2270,6 +2270,16 @@ void virDomainStatsRecordListFree(virDomainStatsRecordPtr *stats); */ # define VIR_PERF_PARAM_ALIGNMENT_FAULTS "alignment_faults" +/** + * VIR_PERF_PARAM_EMULATION_FAULTS: + * + * Macro for typed parameter name that represents emulation_faults + * perf event which can be used to measure the count of emulation + * faults by applications running on the platform. It corresponds + * to the "perf.emulation_faults" field in the *Stats APIs. + */ +# define VIR_PERF_PARAM_EMULATION_FAULTS "emulation_faults" + int virDomainGetPerfEvents(virDomainPtr dom, virTypedParameterPtr *params, int *nparams, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 012795202f..d8c88e06c4 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11272,6 +11272,9 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * "perf.alignment_faults" - The count of alignment faults as unsigned * long long. It is produced by the * alignment_faults perf event + * "perf.emulation_faults" - The count of emulation faults as unsigned + * long long. It is produced by the + * emulation_faults perf event * * Note that entire stats groups or individual stat fields may be missing from * the output in case they are not supported by the given hypervisor, are not diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a6d8f141b5..639db74085 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9575,6 +9575,7 @@ qemuDomainSetPerfEvents(virDomainPtr dom, VIR_PERF_PARAM_PAGE_FAULTS_MIN, VIR_TYPED_PARAM_BOOLEAN, VIR_PERF_PARAM_PAGE_FAULTS_MAJ, VIR_TYPED_PARAM_BOOLEAN, VIR_PERF_PARAM_ALIGNMENT_FAULTS, VIR_TYPED_PARAM_BOOLEAN, + VIR_PERF_PARAM_EMULATION_FAULTS, VIR_TYPED_PARAM_BOOLEAN, NULL) < 0) return -1; diff --git a/src/util/virperf.c b/src/util/virperf.c index 3f015965c2..e39cebbe0f 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -47,7 +47,7 @@ VIR_ENUM_IMPL(virPerfEvent, VIR_PERF_EVENT_LAST, "cpu_clock", "task_clock", "page_faults", "context_switches", "cpu_migrations", "page_faults_min", "page_faults_maj", - "alignment_faults"); + "alignment_faults", "emulation_faults"); struct virPerfEvent { int type; @@ -140,6 +140,9 @@ static struct virPerfEventAttr attrs[] = { {.type = VIR_PERF_EVENT_ALIGNMENT_FAULTS, .attrType = PERF_TYPE_SOFTWARE, .attrConfig = PERF_COUNT_SW_ALIGNMENT_FAULTS}, + {.type = VIR_PERF_EVENT_EMULATION_FAULTS, + .attrType = PERF_TYPE_SOFTWARE, + .attrConfig = PERF_COUNT_SW_EMULATION_FAULTS}, }; typedef struct virPerfEventAttr *virPerfEventAttrPtr; diff --git a/src/util/virperf.h b/src/util/virperf.h index 4e464600ce..eee7a03d27 100644 --- a/src/util/virperf.h +++ b/src/util/virperf.h @@ -55,6 +55,7 @@ typedef enum { VIR_PERF_EVENT_PAGE_FAULTS_MIN, /* Count of minor page faults */ VIR_PERF_EVENT_PAGE_FAULTS_MAJ, /* Count of major page faults */ VIR_PERF_EVENT_ALIGNMENT_FAULTS, /* Count of alignment faults */ + VIR_PERF_EVENT_EMULATION_FAULTS, /* Count of emulation faults */ VIR_PERF_EVENT_LAST } virPerfEventType; diff --git a/tests/genericxml2xmlindata/generic-perf.xml b/tests/genericxml2xmlindata/generic-perf.xml index b48f96c38f..457aea0ef6 100644 --- a/tests/genericxml2xmlindata/generic-perf.xml +++ b/tests/genericxml2xmlindata/generic-perf.xml @@ -34,6 +34,7 @@ + diff --git a/tools/virsh.pod b/tools/virsh.pod index 0fe4188c99..ee79046113 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -972,6 +972,7 @@ I<--perf> returns the statistics of all enabled perf events: "perf.page_faults_min" - the count of minor page faults "perf.page_faults_maj" - the count of major page faults "perf.alignment_faults" - the count of alignment faults + "perf.emulation_faults" - the count of emulation faults See the B command for more details about each event. @@ -2357,6 +2358,8 @@ B by applications running on the platform. alignment_faults - Provides the count alignment faults by applications running on the platform. + emulation_faults - Provides the count emulation faults + by applications running on the platform. B: The statistics can be retrieved using the B command using the I<--perf> flag.