On Thu, Jun 18, 2020 at 08:23:33PM +0200, Uladzislau Rezki wrote:
> > +void vfree_bulk(size_t count, void **addrs)
> > +{
> > +   unsigned int i;
> > +
> > +   BUG_ON(in_nmi());
> > +   might_sleep_if(!in_interrupt());
> > +
> > +   for (i = 0; i < count; i++) {
> > +           void *addr = addrs[i];
> > +           kmemleak_free(addr);
> > +           if (addr)
> > +                   __vfree(addr);
> > +   }
> > +}
> > +EXPORT_SYMBOL(vfree_bulk);
> > +
> >
> Can we just do addrs[i] all over the loop?
> 
> Also, we can just call vfree() instead that has all checking we
> need: NMI, kmemleak, might_sleep.

Of course we _can_.  But would we want to?  This way, we only do these
checks once instead of once per pointer, which is rather the point
of batching.

I might actually go further and hoist the in_interrupt() check into
this function ... I suspect the RCU code always runs in_interrupt()
and so we always call vfree_deferred().

Reply via email to