From: Eduard Zingerman <eddyz87@gmail.com>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Ziyang Men <ziyang.meme@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
bpf@vger.kernel.org, Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Shuah Khan <shuah@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
kernel-team@meta.com, linux-mm@kvack.org,
cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/3] selftests/bpf: compare BPF and memory.stat memcg stat readers
Date: Tue, 07 Jul 2026 02:21:59 -0700 [thread overview]
Message-ID: <eccfd9a8dd1af1668e142b9b866194333647b0d5.camel@gmail.com> (raw)
In-Reply-To: <akxW5dzvR9e2CfGq@linux.dev>
On Mon, 2026-07-06 at 18:50 -0700, Shakeel Butt wrote:
> On Mon, Jul 06, 2026 at 05:17:50PM -0700, Eduard Zingerman wrote:
> > On Fri, 2026-07-03 at 21:56 -0700, Ziyang Men wrote:
> >
> > [...]
> >
> > Hi Ziyang,
> >
> > I'm a bit hesitant adding 2.5K lines of code to the BPF selftests,
> > as this code would need to be (a) maintained, (b) run at each CI invocation.
> > Hence, the tests added need to be relevant for the BPF sub-system.
> >
> > Regarding the benchmarking part, as you state yourself:
> >
> > > In my testing (a 60-CPU VM) the BPF path is roughly an order of magnitude
> > > faster than the per-cgroup memory.stat parse for a whole-tree scan, mainly
> > > because it avoids the per-cgroup open/read and string parsing.
> >
> > With this, I think the benchmarking code can be dropped altogether.
> >
> > Next, the three memcg_stat_{reader,churn,churn_percpu}.c files share a
> > lot of utility code almost verbatim (e.g. tree definition/construction).
> > Such duplication should be avoided.
> >
> > Finally, from the BPF point of view the test exercises the following functionality:
> > - kfuncs:
> > - bpf_mem_cgroup_page_state
> > - bpf_mem_cgroup_vm_events
> > - bpf_put_mem_cgroup
> > - bpf_get_mem_cgroup
> > - main iterator logic.
> >
> > All kfuncs but bpf_get_mem_cgroup() are thin wrappers around mm/memcontrol.c code,
> > all kfuncs including the bpf_get_mem_cgroup() are already exercised in the selftests.
> > The iterator logic itself is covered by 8 sub-tests in the prog_tests/cgroup_iter.c.
> > Hence two questions:
> > - What do these new tests add in terms of tests coverage?
> > - Why do BPF selftests need to exercise the churn and churn_percpu scenarios?
> >
> > Shakeel, could you please comment as well?
>
> Hi Eduard,
>
> Thanks a lot for taking a look. The main motivation I had behind requesting
> Ziyang to send this series (beside making him learn the tooling and process of
> sending patches to lkml) was to have a reference implementation and performance
> comparison for BPF based cgroup/memcg stats collection.
>
> However you have correctly pointed out that selftests might not be the right
> place for such kind of code as selftests are more focused on functional tests
> and run by a lot of CIs while this is a performance benchmarking code.
>
> I am wondering if there is a place for this benchmarking code in kernel under
> tools folder but archiving it on lkml might be good enough and should be easily
> searchable. Anyways thanks again for your time.
Hi Shakeel,
We do have bpf benchmarks in the kernel tree, the entry point is
tools/testing/selftests/bpf/bench.c. These are supposed to be
performance measurements and are executed manually from time to time
(quite rarely, as far as I understand), not by CI.
However, if I understand Ziyang's assessment correctly, this code is
not really a performance test, but kind of a load test.
Thanks,
Eduard
prev parent reply other threads:[~2026-07-07 9:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-04 4:56 [PATCH 0/3] selftests/bpf: compare BPF and memory.stat memcg stat readers Ziyang Men
2026-07-04 4:56 ` [PATCH 1/3] selftests/bpf: add memcg_stat_reader BPF-vs-memory.stat benchmark Ziyang Men
2026-07-04 5:06 ` sashiko-bot
2026-07-04 4:56 ` [PATCH 2/3] selftests/bpf: add memcg_stat_churn BPF-vs-memory.stat benchmark under churn Ziyang Men
2026-07-04 4:56 ` [PATCH 3/3] selftests/bpf: add memcg_stat_churn_percpu BPF-vs-memory.stat benchmark under cross-CPU churn Ziyang Men
2026-07-04 5:04 ` sashiko-bot
2026-07-04 5:58 ` bot+bpf-ci
2026-07-07 0:17 ` [PATCH 0/3] selftests/bpf: compare BPF and memory.stat memcg stat readers Eduard Zingerman
2026-07-07 1:50 ` Shakeel Butt
2026-07-07 9:21 ` Eduard Zingerman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eccfd9a8dd1af1668e142b9b866194333647b0d5.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=emil@etsalapatis.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
--cc=ziyang.meme@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox