Skip to content

Commit 21a2ed5

Browse files
committed
perf parse-events: Set default GH modifier properly
JIRA: https://issues.redhat.com/browse/RHEL-78200 upstream ======== commit dcbe6e5 Author: Namhyung Kim <namhyung@kernel.org> Date: Fri Jun 6 15:54:31 2025 -0700 description =========== 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 <irogers@google.com> Link: https://lore.kernel.org/r/20250606225431.2109754-1-namhyung@kernel.org Fixes: 35c8d21 ("perf tools: Don't set attr.exclude_guest by default") Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
1 parent ae1b605 commit 21a2ed5

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
@@ -1825,13 +1825,11 @@ static int parse_events__modifier_list(struct parse_events_state *parse_state,
18251825
int eH = group ? evsel->core.attr.exclude_host : 0;
18261826
int eG = group ? evsel->core.attr.exclude_guest : 0;
18271827
int exclude = eu | ek | eh;
1828-
int exclude_GH = group ? evsel->exclude_GH : 0;
1828+
int exclude_GH = eG | eH;
18291829

18301830
if (mod.user) {
18311831
if (!exclude)
18321832
exclude = eu = ek = eh = 1;
1833-
if (!exclude_GH && !perf_guest && exclude_GH_default)
1834-
eG = 1;
18351833
eu = 0;
18361834
}
18371835
if (mod.kernel) {
@@ -1854,6 +1852,13 @@ static int parse_events__modifier_list(struct parse_events_state *parse_state,
18541852
exclude_GH = eG = eH = 1;
18551853
eH = 0;
18561854
}
1855+
if (!exclude_GH && exclude_GH_default) {
1856+
if (perf_host)
1857+
eG = 1;
1858+
else if (perf_guest)
1859+
eH = 1;
1860+
}
1861+
18571862
evsel->core.attr.exclude_user = eu;
18581863
evsel->core.attr.exclude_kernel = ek;
18591864
evsel->core.attr.exclude_hv = eh;

0 commit comments

Comments
 (0)