Re: [PATCH stable] mm/khugepaged: write all dirty file folios when collapsing

From: Gregg Leventhal

Date: Wed Jul 08 2026 - 10:17:48 EST


Hi there, just checking on the next steps here.

@Pedro Falcato Are you currently working on this patch (mentioned
above, re: holding invalidate lock), or are we perhaps stalled on
something?

Thanks!

On Fri, Jul 3, 2026 at 8:50 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
>
> On Thu, Jul 02, 2026 at 05:54:09PM +0100, Pedro Falcato wrote:
> > +++ b/mm/khugepaged.c
> > @@ -2094,32 +2094,43 @@ static enum scan_result collapse_file(struct mm_struct *mm, unsigned long addr,
> > goto xa_unlocked;
> > }
> >
> > - if (!is_shmem) {
> > +xa_locked:
> > + xas_unlock_irq(&xas);
> > +xa_unlocked:
>
> Hmm. Before this patch, we increment nr_thps while holding the i_pages
> lock. Now we aren't holding it, but we are holding the invalidate lock.
> Can you put something in the commit message that notes this change and
> argues that it's totally fine actually?
>
> You were good enough to not point out that my suggestion of calling
> write_and_wait in the existing !is_shmem condition would result in
> sleeping with a spinlock held. Silly me ;-)
>