Re: [RFC/PATCH bpf-next 1/3] bpf: Add kmem_cache iterator

From: Alexei Starovoitov
Date: Sun Sep 29 2024 - 13:04:27 EST


On Fri, Sep 27, 2024 at 11:41 AM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> +static void *kmem_cache_iter_seq_start(struct seq_file *seq, loff_t *pos)
> +{
> + loff_t cnt = 0;
> + struct kmem_cache *s = NULL;
> +
> + mutex_lock(&slab_mutex);

It would be better to find a way to iterate slabs without holding
the mutex for the duration of the loop.
Maybe use refcnt to hold the kmem_cache while bpf prog is looking at it?