Re: [PATCH v3 3/5] mm: convert compaction to zone lock wrappers

From: Dmitry Ilvokhin

Date: Fri Feb 27 2026 - 09:47:30 EST


On Thu, Feb 26, 2026 at 04:45:54PM -0800, SeongJae Park wrote:
> On Thu, 26 Feb 2026 18:26:20 +0000 Dmitry Ilvokhin <d@xxxxxxxxxxxx> wrote:
>
> > Compaction uses compact_lock_irqsave(), which currently operates
> > on a raw spinlock_t pointer so it can be used for both zone->lock
> > and lruvec->lru_lock. Since zone lock operations are now wrapped,
> > compact_lock_irqsave() can no longer directly operate on a
> > spinlock_t when the lock belongs to a zone.
> >
> > Split the helper into compact_zone_lock_irqsave() and
> > compact_lruvec_lock_irqsave(), duplicating the small amount of
> > shared logic. As there are only two call sites and both statically
> > know the lock type, this avoids introducing additional abstraction
> > or runtime dispatch in the compaction path.
> >
> > No functional change intended.
> >
> > Signed-off-by: Dmitry Ilvokhin <d@xxxxxxxxxxxx>
> > ---
> > mm/compaction.c | 33 ++++++++++++++++++++++++---------
> > 1 file changed, 24 insertions(+), 9 deletions(-)
> >
> > diff --git a/mm/compaction.c b/mm/compaction.c
> > index 47b26187a5df..9f7997e827bd 100644
> > --- a/mm/compaction.c
> > +++ b/mm/compaction.c
> > @@ -503,19 +503,36 @@ static bool test_and_set_skip(struct compact_control *cc, struct page *page)
> > *
> > * Always returns true which makes it easier to track lock state in callers.
> > */
> > -static bool compact_lock_irqsave(spinlock_t *lock, unsigned long *flags,
> > - struct compact_control *cc)
> > - __acquires(lock)
> > +static bool compact_zone_lock_irqsave(struct zone *zone,
> > + unsigned long *flags,
> > + struct compact_control *cc)
> > +__acquires(&zone->lock)
>
> Nit. Why don't you keep the indentation?
>
> My impression based on below output is that mm code prefer indenting
> __acquires().
>
> $ git grep __acquires mm
> mm/compaction.c:__acquires(&zone->_lock)
> mm/compaction.c:__acquires(&lruvec->lru_lock)
> mm/khugepaged.c: __acquires(&khugepaged_mm_lock)
> mm/userfaultfd.c: __acquires(ptl1)
> mm/userfaultfd.c: __acquires(ptl2)
>

Thanks for spotting it, will be fixed in v4.

>
> Thanks,
> SJ
>
> [...]