perf stat: Get a perf cgroup more portably in BPF
Subsystems (2)
Namhyung Kim
maintainerPATCH 1/1 perf stat: Get a perf cgroup more portably in BPF
The perf_event_cgrp_id can be different on other configurations. To be more portable as CO-RE, it needs to get the cgroup subsys id using the bpf_core_enum_value() helper.
--- tools/perf/util/bpf_skel/bperf_cgroup.bpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/bpf_skel/bperf_cgroup.bpf.c +3 -1
@@ -57,8 +57,10 @@ static inline int get_cgroup_v1_idx(__u32 *cgrps, int size)__u32 *elem;int level;int cnt; +int perf_id; - cgrp =BPF_CORE_READ (p, cgroups, subsys[perf_event_cgrp_id], cgroup); + perf_id = bpf_core_enum_value(enum cgroup_subsys_id, perf_event_cgrp_id); + cgrp =BPF_CORE_READ (p, cgroups, subsys[perf_id], cgroup); level =BPF_CORE_READ (cgrp, level);for (cnt =0 ; i <MAX_LEVELS ; i++) {
Signature · 1 line
2.37.3.968.ga6b4b080e4-goog
Ian Rogers
reviewerQuoted 16 lines · Namhyung Kim
The
perf_event_cgrp_idcan be different on other configurations. To be more portable as CO-RE, it needs to get the cgroup subsys id using thebpf_core_enum_value()helper.Suggested-by Ian Rogers <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/bpf_skel/bperf_cgroup.bpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)tools/perf/util/bpf_skel/bperf_cgroup.bpf.c +0
-0
tools/perf/util/bpf_skel/bperf_cgroup.bpf.c static inline int get_cgroup_v1_idx(__u32 *cgrps, int size) · line 63
Quoted 8 lines
tools/perf/util/bpf_skel/bperf_cgroup.bpf.c +3
-1@@ -57,8 +57,10 @@ static inline int get_cgroup_v1_idx(__u32 *cgrps, int size)__u32 *elem;int level;int cnt; +int perf_id; - cgrp =BPF_CORE_READ (p, cgroups, subsys[perf_event_cgrp_id], cgroup); + perf_id = bpf_core_enum_value(enum cgroup_subsys_id, perf_event_cgrp_id); + cgrp =BPF_CORE_READ (p, cgroups, subsys[perf_id], cgroup);
LGTM, do we need the same fix in off cpu?
https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/tools/perf/util/bpf_skel/off_cpu.bpf.c?h=perf/core#n123
Thanks,
Ian
Quoted 6 lines
tools/perf/util/bpf_skel/bperf_cgroup.bpf.c +0
-1level =BPF_CORE_READ (cgrp, level);for (cnt =0 ; i <MAX_LEVELS ; i++) { --2.37.3.968.ga6b4b080e4-goog
Namhyung Kim
maintainerHi Ian,
Quoted 23 lines · Ian Rogers
Quoted 21 lines · Namhyung Kim
The
perf_event_cgrp_idcan be different on other configurations. To be more portable as CO-RE, it needs to get the cgroup subsys id using thebpf_core_enum_value()helper.Suggested-by Ian Rogers <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/bpf_skel/bperf_cgroup.bpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)tools/perf/util/bpf_skel/bperf_cgroup.bpf.c +1
-0@@ -57,8 +57,10 @@ static inline int get_cgroup_v1_idx(__u32 *cgrps, int size)__u32 *elem;int level;int cnt; +int perf_id;
Quoted 6 lines
tools/perf/util/bpf_skel/bperf_cgroup.bpf.c static inline int get_cgroup_v1_idx(__u32 *cgrps, int size) · line 63
Quoted 3 lines
tools/perf/util/bpf_skel/bperf_cgroup.bpf.c +2
-1- cgrp =BPF_CORE_READ (p, cgroups, subsys[perf_event_cgrp_id], cgroup); + perf_id = bpf_core_enum_value(enum cgroup_subsys_id, perf_event_cgrp_id); + cgrp =BPF_CORE_READ (p, cgroups, subsys[perf_id], cgroup);LGTM, do we need the same fix in off cpu?
https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/tools/perf/util/bpf_skel/off_cpu.bpf.c?h=perf/core#n123
Right, will send v2.
Thanks,
Namhyung