Skip to content

Commit dcbe6e5

Browse files
committed
perf parse-events: Set default GH modifier properly
Commit 7b10098 ("perf evlist: Remove __evlist__add_default") changed to use "cycles:P" as a default event. But the problem is it cannot set other default modifiers correctly. perf kvm needs to set attr.exclude_host by default but it didn't work because of the logic in the parse_events__modifier_list(). Also the exclude_GH_default was applied only if ":u" modifier was specified - which is strange. Move it out after handling the ":GH" and check perf_host and perf_guest properly. Before: $ ./perf kvm record -vv true |& grep exclude (nothing) But specifying an event (without a modifier) works: $ ./perf kvm record -vv -e cycles true |& grep exclude exclude_host 1 After: It now works for the both cases: $ ./perf kvm record -vv true |& grep exclude exclude_host 1 $ ./perf kvm record -vv -e cycles true |& grep exclude exclude_host 1 Reviewed-by: Ian Rogers <[email protected]> Link: https://lore.kernel.org/r/[email protected] Fixes: 35c8d21 ("perf tools: Don't set attr.exclude_guest by default") Signed-off-by: Namhyung Kim <[email protected]>
1 parent 588d22b commit dcbe6e5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tools/perf/util/parse-events.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,13 +1830,11 @@ static int parse_events__modifier_list(struct parse_events_state *parse_state,
18301830
int eH = group ? evsel->core.attr.exclude_host : 0;
18311831
int eG = group ? evsel->core.attr.exclude_guest : 0;
18321832
int exclude = eu | ek | eh;
1833-
int exclude_GH = group ? evsel->exclude_GH : 0;
1833+
int exclude_GH = eG | eH;
18341834

18351835
if (mod.user) {
18361836
if (!exclude)
18371837
exclude = eu = ek = eh = 1;
1838-
if (!exclude_GH && !perf_guest && exclude_GH_default)
1839-
eG = 1;
18401838
eu = 0;
18411839
}
18421840
if (mod.kernel) {
@@ -1859,6 +1857,13 @@ static int parse_events__modifier_list(struct parse_events_state *parse_state,
18591857
exclude_GH = eG = eH = 1;
18601858
eH = 0;
18611859
}
1860+
if (!exclude_GH && exclude_GH_default) {
1861+
if (perf_host)
1862+
eG = 1;
1863+
else if (perf_guest)
1864+
eH = 1;
1865+
}
1866+
18621867
evsel->core.attr.exclude_user = eu;
18631868
evsel->core.attr.exclude_kernel = ek;
18641869
evsel->core.attr.exclude_hv = eh;

0 commit comments

Comments
 (0)