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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Sep 29, 2024 at 10:04:00AM -0700, Alexei Starovoitov wrote:
> 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?

Do you mean that you want to not hold slab_mutex while BPF program is
running?  Maybe we can allocates an arary of pointers to the slab cahe
(with refcounts) at the beginning and iterate them instead.  And call
kmem_cache_destroy() for each entry at the end.  Is it ok to you?

Thanks,
Namhyung





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux