Re: [PATCH v3] locking/local_lock, mm: Replace localtry_ helpers with local_trylock_t type

From: Andrew Morton
Date: Thu Apr 03 2025 - 00:06:19 EST


On Wed, 2 Apr 2025 20:48:39 -0700 Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote:

> On Wed, Apr 2, 2025 at 8:12 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > On Wed, 2 Apr 2025 19:55:14 -0700 Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote:
> >
> > > Partially revert commit 0aaddfb06882 ("locking/local_lock: Introduce localtry_lock_t").
> > > Remove localtry_*() helpers, since localtry_lock() name might
> > > be misinterpreted as "try lock".
> > >
> >
> > So many macros grumble.
> >
> > +#define local_trylock_init(lock) __local_trylock_init(lock)
> > +#define local_trylock(lock) __local_trylock(lock)
> > +#define local_trylock_irqsave(lock, flags) \
> > +#define __local_trylock_init(lock) __local_lock_init(lock.llock)
> > +#define __local_lock_acquire(lock) \
> > +#define __local_trylock(lock) \
> > +#define __local_trylock_irqsave(lock, flags) \
> > +#define __local_lock_release(lock) \
> > +#define __local_unlock(lock) \
> > +#define __local_unlock_irq(lock) \
> > +#define __local_unlock_irqrestore(lock, flags) \
> > +#define __local_lock_nested_bh(lock) \
> > +#define __local_unlock_nested_bh(lock) \
> > +#define __local_trylock_init(l) __local_lock_init(l)
> > +#define __local_trylock(lock) \
> > +#define __local_trylock_irqsave(lock, flags) \
> >
> > I expect many of these could have been implemented as static inlines.
> >
> > Oh well, that's a separate project for someone sometime.
>
> They need to be macroses otherwise _Generic() trick won't work.

Ah.

> Thanks for applying v3.
>
> Do you want to take "mm/page_alloc: Avoid second trylock of zone->lock"
> fix as well ?

Added, thanks.