Re: [PATCH 7/7] mm/page_alloc: Replace local_lock with normal spinlock

From: Mel Gorman
Date: Tue Jun 21 2022 - 05:27:37 EST


On Fri, Jun 17, 2022 at 09:57:06AM +0200, Vlastimil Babka wrote:
> On 6/16/22 23:07, Yu Zhao wrote:
> > On Thu, Jun 16, 2022 at 11:02 AM Vlastimil Babka <vbabka@xxxxxxx> wrote:
> >>
> >>
> >> > @@ -3794,19 +3805,29 @@ static struct page *rmqueue_pcplist(struct zone *preferred_zone,
> >> > struct list_head *list;
> >> > struct page *page;
> >> > unsigned long flags;
> >> > + unsigned long __maybe_unused UP_flags;
> >> >
> >> > - local_lock_irqsave(&pagesets.lock, flags);
> >> > + /*
> >> > + * spin_trylock_irqsave is not necessary right now as it'll only be
> >> > + * true when contending with a remote drain. It's in place as a
> >> > + * preparation step before converting pcp locking to spin_trylock
> >> > + * to protect against IRQ reentry.
> >> > + */
> >> > + pcp_trylock_prepare(UP_flags);
> >> > + pcp = pcp_spin_trylock_irqsave(zone->per_cpu_pageset, flags);
> >> > + if (!pcp)
> >>
> >> Besides the missing unpin Andrew fixed, I think also this is missing
> >> pcp_trylock_finish(UP_flags); ?
> >
> > spin_trylock only fails when trylock_finish is a NOP.
>
> True, so it's not an active bug, but I would still add it, so it's not
> confusing and depending on non-obvious details that might later change and
> break the code.

Yes. Even though it may work, it's still wrong.

--
Mel Gorman
SUSE Labs