Re: [PATCH bpf-next 2/2] selftests/bpf: Add a test for open coded kmem_cache iter
From: Namhyung Kim
Date: Thu Oct 24 2024 - 03:44:45 EST
On Mon, Oct 21, 2024 at 04:36:49PM -0700, Andrii Nakryiko wrote:
> On Thu, Oct 17, 2024 at 1:06 AM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> >
> > The new subtest is attached to sleepable fentry of syncfs() syscall.
> > It iterates the kmem_cache using bpf_for_each loop and count the number
> > of entries. Finally it checks it with the number of entries from the
> > regular iterator.
> >
> > $ ./vmtest.sh -- ./test_progs -t kmem_cache_iter
> > ...
> > #130/1 kmem_cache_iter/check_task_struct:OK
> > #130/2 kmem_cache_iter/check_slabinfo:OK
> > #130/3 kmem_cache_iter/open_coded_iter:OK
> > #130 kmem_cache_iter:OK
> > Summary: 1/3 PASSED, 0 SKIPPED, 0 FAILED
> >
> > Also simplify the code by using attach routine of the skeleton.
> >
> > Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
> > ---
> > .../testing/selftests/bpf/bpf_experimental.h | 6 ++++
> > .../bpf/prog_tests/kmem_cache_iter.c | 28 +++++++++++--------
> > .../selftests/bpf/progs/kmem_cache_iter.c | 24 ++++++++++++++++
> > 3 files changed, 46 insertions(+), 12 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h
> > index b0668f29f7b394eb..cd8ecd39c3f3c68d 100644
> > --- a/tools/testing/selftests/bpf/bpf_experimental.h
> > +++ b/tools/testing/selftests/bpf/bpf_experimental.h
> > @@ -582,4 +582,10 @@ extern int bpf_wq_set_callback_impl(struct bpf_wq *wq,
> > unsigned int flags__k, void *aux__ign) __ksym;
> > #define bpf_wq_set_callback(timer, cb, flags) \
> > bpf_wq_set_callback_impl(timer, cb, flags, NULL)
> > +
> > +struct bpf_iter_kmem_cache;
> > +extern int bpf_iter_kmem_cache_new(struct bpf_iter_kmem_cache *it) __weak __ksym;
> > +extern struct kmem_cache *bpf_iter_kmem_cache_next(struct bpf_iter_kmem_cache *it) __weak __ksym;
> > +extern void bpf_iter_kmem_cache_destroy(struct bpf_iter_kmem_cache *it) __weak __ksym;
> > +
>
> we should be getting this from vmlinux.h nowadays, so this is probably
> unnecessary
I got some build errors without this. I'll leave it for v2.
Thanks,
Namhyung