diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 680b98593feefc69a23f37f0247d74daeb27bb45..68d664151dc3b5fdbb8b7ef02d47d5c2c2a46fd3 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 1f0c72914879465c6eb2a765eb11c21991bed6a9..1860f9075b725f3e53e7ce6d88f082640843d058 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 0c0fb182da7c598cddf9574196116b3f8a878ef6..c490d712f22ebeb41b9fba4e090ed8e213502334 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 012795202f5cb9a0df3d5c16424a87659c38167f..d8c88e06c476268098b46232473470dcc8aee7ae 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 a6d8f141b5e35532ee87765dd9ccd7a13142a43c..639db74085024f2a7f36d8c8994340ccd0ee8067 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 3f015965c2a2ad793e075f5b0d55c444a849cd72..e39cebbe0f175b3feb8f7b5ee23aa3f91e2dec95 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 4e464600ce3a5786af605220c498d5e1aeb0bd67..eee7a03d27771473fa81065d7e1f71177aa316b9 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 b48f96c38f44b832445d981d4e59e7a02a108153..457aea0ef67ceaa0bb309adc212289e8d3e4e51e 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 0fe4188c998f8154e9a8759a8608085933cdecdb..ee790461136206c729f22daa26bf64afe94c39a8 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.