Skip to content

Commit e2eeef2

Browse files
namhyungacmel
authored andcommitted
perf tools: Ignore deleted cgroups
On large systems, cgroups can be created and deleted often. That means there's a race between perf tools and cgroups when it gets the cgroup name and opens the cgroup. I got a report that 'perf stat' with many cgroups failed quite often due to the missing cgroups on such a large machine. I think we can ignore such cgroups when expanding events and use id 0 if it fails to read the cgroup id. IIUC 0 is not a vaild cgroup id so it won't update event counts for the failed cgroups. Signed-off-by: Namhyung Kim <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 5ceb579 commit e2eeef2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

tools/perf/util/bpf_counter_cgroup.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ static int bperf_load_program(struct evlist *evlist)
136136
cgrp = evsel->cgrp;
137137

138138
if (read_cgroup_id(cgrp) < 0) {
139-
pr_err("Failed to get cgroup id\n");
140-
err = -1;
141-
goto out;
139+
pr_debug("Failed to get cgroup id for %s\n", cgrp->name);
140+
cgrp->id = 0;
142141
}
143142

144143
map_fd = bpf_map__fd(skel->maps.cgrp_idx);

tools/perf/util/cgroup.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,11 @@ int evlist__expand_cgroup(struct evlist *evlist, const char *str,
465465
name = cn->name + prefix_len;
466466
if (name[0] == '/' && name[1])
467467
name++;
468+
469+
/* the cgroup can go away in the meantime */
468470
cgrp = cgroup__new(name, open_cgroup);
469471
if (cgrp == NULL)
470-
goto out_err;
472+
continue;
471473

472474
leader = NULL;
473475
evlist__for_each_entry(orig_list, pos) {

0 commit comments

Comments
 (0)