perf tools: Add support for guest/host-only profiling
To restrict a counter to either host or guest mode this patch introduces two new event modifiers: G and H. With G the counter is configured in guest-only mode and with H in host-only mode. Cc: Gleb Natapov <gleb@redhat.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Joerg Roedel <joro@8bytes.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Link: http://lkml.kernel.org/n/tip-or5aj3rghy9ngyg882z6kln9@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
1aed267173
commit
99320cc824
|
@ -21,6 +21,8 @@ EVENT MODIFIERS
|
||||||
Events can optionally have a modifer by appending a colon and one or
|
Events can optionally have a modifer by appending a colon and one or
|
||||||
more modifiers. Modifiers allow the user to restrict when events are
|
more modifiers. Modifiers allow the user to restrict when events are
|
||||||
counted with 'u' for user-space, 'k' for kernel, 'h' for hypervisor.
|
counted with 'u' for user-space, 'k' for kernel, 'h' for hypervisor.
|
||||||
|
Additional modifiers are 'G' for guest counting (in KVM guests) and 'H'
|
||||||
|
for host counting (not in KVM guests).
|
||||||
|
|
||||||
The 'p' modifier can be used for specifying how precise the instruction
|
The 'p' modifier can be used for specifying how precise the instruction
|
||||||
address should be. The 'p' modifier is currently only implemented for
|
address should be. The 'p' modifier is currently only implemented for
|
||||||
|
|
|
@ -735,8 +735,8 @@ static int
|
||||||
parse_event_modifier(const char **strp, struct perf_event_attr *attr)
|
parse_event_modifier(const char **strp, struct perf_event_attr *attr)
|
||||||
{
|
{
|
||||||
const char *str = *strp;
|
const char *str = *strp;
|
||||||
int exclude = 0;
|
int exclude = 0, exclude_GH = 0;
|
||||||
int eu = 0, ek = 0, eh = 0, precise = 0;
|
int eu = 0, ek = 0, eh = 0, eH = 0, eG = 0, precise = 0;
|
||||||
|
|
||||||
if (!*str)
|
if (!*str)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -760,6 +760,14 @@ parse_event_modifier(const char **strp, struct perf_event_attr *attr)
|
||||||
if (!exclude)
|
if (!exclude)
|
||||||
exclude = eu = ek = eh = 1;
|
exclude = eu = ek = eh = 1;
|
||||||
eh = 0;
|
eh = 0;
|
||||||
|
} else if (*str == 'G') {
|
||||||
|
if (!exclude_GH)
|
||||||
|
exclude_GH = eG = eH = 1;
|
||||||
|
eG = 0;
|
||||||
|
} else if (*str == 'H') {
|
||||||
|
if (!exclude_GH)
|
||||||
|
exclude_GH = eG = eH = 1;
|
||||||
|
eH = 0;
|
||||||
} else if (*str == 'p') {
|
} else if (*str == 'p') {
|
||||||
precise++;
|
precise++;
|
||||||
} else
|
} else
|
||||||
|
@ -776,6 +784,8 @@ parse_event_modifier(const char **strp, struct perf_event_attr *attr)
|
||||||
attr->exclude_kernel = ek;
|
attr->exclude_kernel = ek;
|
||||||
attr->exclude_hv = eh;
|
attr->exclude_hv = eh;
|
||||||
attr->precise_ip = precise;
|
attr->precise_ip = precise;
|
||||||
|
attr->exclude_host = eH;
|
||||||
|
attr->exclude_guest = eG;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue