mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Rik van Riel <riel@meta.com>
Cc: Jinjiang Tu <tujinjiang@huawei.com>,
	Rik van Riel <riel@surriel.com>,
	ziy@nvidia.com, linux-kernel@vger.kernel.org,
	kernel-team@meta.com, Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>, Hugh Dickins <hughd@kernel.org>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	"Liam R. Howlett" <liam@infradead.org>,
	Nico Pache <npache@redhat.com>,
	Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
	Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
	linux-mm@kvack.org
Subject: Re: [PATCH] mm: khugepaged: free xarray nodes left behind by failed collapse_file()
Date: Wed, 17 Jun 2026 19:05:50 +0100	[thread overview]
Message-ID: <ajLh_pdGl5xea5dM@casper.infradead.org> (raw)
In-Reply-To: <CAPkx9x3BV3vMh8d8P36wCEOYRshRobT1G0Q9v4h1OABj1ffS=A@mail.gmail.com>

On Wed, Jun 17, 2026 at 11:40:28AM -0400, Rik van Riel wrote:
> On Tue, Jun 16, 2026 at 10:18 PM Matthew Wilcox <willy@infradead.org> wrote:
> >
> > On Wed, Jun 17, 2026 at 10:00:59AM +0800, Jinjiang Tu wrote:
> 
> > > I can reproduce it easily with following steps. [1]
> > > 1) create file /tmp/test_madvise_collapse and ftruncate to 4MB size, and
> > > then mmap the file
> > > 2) memset for the first 2MB
> > > 3) madvise(MADV_COLLAPSE) for the second 2MB
> > > 4) unlink the file
> >
> > Yes, but is there a problem?  That is, do we need to clear this up
> > before we get to clear_inode()?
> 
> If there is no harm in leaving this xarray node hang around until
> clear_inode() time, I agree we do not need this patch.
> 
> Are there no issues with large folios getting inserted into the
> xarray at a later time, after zapping little ones, and leaving
> the empty xarray node dangling?

That's not an issue.  The code which handles this is in
__filemap_add_folio().  You can see that we handle value (ie shadow)
entries here:

                xas_for_each_conflict(&xas, entry) {
                        old = entry;
                        if (!xa_is_value(entry)) {
                                xas_set_err(&xas, -EEXIST);
                                goto unlock;
                        }

(this loop will iterate 0 times if there are only empty nodes in the
"conflict" area)

Then we just do xas_store() which will overwrite the nodes.  That calls
xas_free_nodes() on any nodes which are overwritten.

      reply	other threads:[~2026-06-17 18:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 14:54 Rik van Riel
2026-06-16 15:09 ` Zi Yan
2026-06-16 15:29 ` Matthew Wilcox
2026-06-17  2:00   ` Jinjiang Tu
2026-06-17  2:18     ` Matthew Wilcox
2026-06-17  7:33       ` Jinjiang Tu
2026-06-17 15:40       ` Rik van Riel
2026-06-17 18:05         ` Matthew Wilcox [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ajLh_pdGl5xea5dM@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=hughd@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=npache@redhat.com \
    --cc=riel@meta.com \
    --cc=riel@surriel.com \
    --cc=ryan.roberts@arm.com \
    --cc=tujinjiang@huawei.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®