From: Jinjiang Tu <tujinjiang@huawei.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: 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 15:33:00 +0800 [thread overview]
Message-ID: <7fa4b268-5c5b-4a69-ba47-40246ff933e0@huawei.com> (raw)
In-Reply-To: <ajID7ZpnBYOucAVz@casper.infradead.org>
在 2026/6/17 10:18, Matthew Wilcox 写道:
> On Wed, Jun 17, 2026 at 10:00:59AM +0800, Jinjiang Tu wrote:
>> 在 2026/6/16 23:29, Matthew Wilcox 写道:
>>> On Tue, Jun 16, 2026 at 10:54:13AM -0400, Rik van Riel wrote:
>>>> syzkaller reproduces it trivially with MADV_COLLAPSE on a sparse shmem
>>>> mapping (collapse aborts with SCAN_TRUNCATED because the range is empty),
>>>> and also via slab fault injection, which forces xas_create_range() down
>>>> the xas_nomem() path before the same abort. kmemleak then reports the
>>>> 576-byte struct xa_node objects allocated in xas_alloc()/xas_nomem().
>>> I think the ways to produce this problem are sufficiently rare/unlikely
>> 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()?
A user cannot exhaust memory by continuously creating xa_node structures. So
it is enough to free empty xa_nodes in clear_inode().
We shouldn't free empty xa_nodes in collapse_file() rollback path, because we
couldn't avoid a concurrent call of collapse_file(), which creates xa_nodes
for the same region and may use these nodes.
next prev parent reply other threads:[~2026-06-17 7:33 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 [this message]
2026-06-17 15:40 ` Rik van Riel
2026-06-17 18:05 ` Matthew Wilcox
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=7fa4b268-5c5b-4a69-ba47-40246ff933e0@huawei.com \
--to=tujinjiang@huawei.com \
--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@surriel.com \
--cc=ryan.roberts@arm.com \
--cc=willy@infradead.org \
--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®