Re: [PATCH bpf-next v1 5/5] bpf: add a selftest for cgroup hierarchical stats collection
From: Michal Koutný
Date: Tue Jun 07 2022 - 08:12:47 EST
On Mon, Jun 06, 2022 at 12:41:06PM -0700, Yosry Ahmed <yosryahmed@xxxxxxxxxx> wrote:
> I don't know if there is a standard way to handle this, but I think
> you should know the configs of your kernel when you are loading a bpf
> program?
Isn't this one of purposes of BTF? (I don't know, I'm genuinely asking.)
> If the CONFIG_CGROUPS=1 but CONFIG_MEMCG=0 I think everything will
> work normally except that task_memcg() will always return NULL so no
> stats will be collected, which makes sense.
I was not able to track down what is the include chain to
tools/testing/selftests/bpf/progs/cgroup_vmscan.c, i.e. how is the enum
value memory_cgrp_id defined.
(A custom kernel module build requires target kernel's header files, I
could understand that compiling a BPF program requires them likewise and
that's how this could work.
Although, it goes against my undestanding of the CO-RE principle.)
> There will be some overhead to running bpf programs that will always
> do nothing, but I would argue that it's the userspace's fault here for
> loading bpf programs on a non-compatible kernel.
Yeah, running an empty program is non-issue in my eyes, I was rather
considering whether the program uses proper offsets.
Michal