From: Muchun Song <muchun.song@linux.dev>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Muchun Song <muchun.song@linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
Chris Mason <mason@kernel.org>,
David Hildenbrand <david@kernel.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
linux-mm@kvack.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org, Dave Chinner <david@fromorbit.com>,
Kairui Song <kasong@tencent.com>, Qi Zheng <qi.zheng@linux.dev>
Subject: Re: [PATCH 1/2] mm: list_lru: fix XArray node leak at destroy
Date: Sun, 6 Dec 2026 10:57:48 +0800 [thread overview]
Message-ID: <C935ACCB-02D5-40EA-90EE-DAF71D667E99@linux.dev> (raw)
In-Reply-To: <20261204173929.2355221-1-hannes@cmpxchg.org>
> On Dec 5, 2026, at 01:39, Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> From: Chris Mason <mason@kernel.org>
>
> memcg_destroy_list_lru() tears down lru->xa by erasing its entries,
> and relies on the XArray to free each node once its last entry is
> gone. That is not how an XArray is torn down. A node can exist
> without entries, and nothing frees that one; it also keeps the count
> of its parent up, so the parent and everything above it stay
> allocated as well. The API has xa_destroy() for this: free the
> entries, then call it to free the nodes.
>
> Empty nodes come from a store that gave up partway. xas_create()
> builds the path to a new index one level at a time, and links each
> node into the tree before it allocates the next. If that allocation
> fails, the linked node stays. This is by design: once xas_nomem()
> has refilled the cache, the retry descends into the node and
> completes the path, and later stores reuse it too. But if the retry
> cannot allocate either, the store returns -ENOMEM and the node stays
> empty. __memcg_list_lru_alloc() gets there with GFP_NOWAIT when the
> page cache allocates a node under memory pressure.
>
> The leak is small, a few nodes per list_lru, and shows at umount.
>
> Fix it by calling xa_destroy() once the entries are freed.
>
> Fixes: bbca91cca9a9 ("mm: list_lru: replace linear array with xarray")
> Cc: Dave Chinner <david@fromorbit.com>
> Cc: Kairui Song <kasong@tencent.com>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: Muchun Song <muchun.song@linux.dev>
> Cc: Qi Zheng <qi.zheng@linux.dev>
> Cc: Roman Gushchin <roman.gushchin@linux.dev>
> Cc: Shakeel Butt <shakeel.butt@linux.dev>
> Signed-off-by: Chris Mason <mason@kernel.org>
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Muchun Song (ByteDance) <muchun.song@linux.dev>
Thanks.
prev parent reply other threads:[~2026-12-06 2:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 17:39 [PATCH 1/2] mm: list_lru: fix XArray node leak at destroy Johannes Weiner
2026-12-04 17:39 ` [PATCH 2/2] mm: list_lru: charge per-memcg lists and XArray nodes Johannes Weiner
2026-12-04 20:33 ` sashiko-bot
2026-12-06 2:57 ` Muchun Song [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=C935ACCB-02D5-40EA-90EE-DAF71D667E99@linux.dev \
--to=muchun.song@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=david@fromorbit.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mason@kernel.org \
--cc=mhocko@kernel.org \
--cc=qi.zheng@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.