From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: "Barry Song (Xiaomi)" <baohua@kernel.org>, akpm@linux-foundation.org
Cc: hannes@cmpxchg.org, mhocko@kernel.org, qi.zheng@linux.dev,
shakeel.butt@linux.dev, kasong@tencent.com,
axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com,
baoquan.he@linux.dev, mason@kernel.org, david@kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
ridong.chen@linux.dev, yuzhao@google.com, stable@vger.kernel.org
Subject: Re: [PATCH 2/3] mm/mglru: test PG_lru before taking a folio reference
Date: Tue, 1 Dec 2026 15:18:05 +0800 [thread overview]
Message-ID: <86852b44-03c1-4865-8ef0-a7c0d0b26113@linux.alibaba.com> (raw)
In-Reply-To: <20261129143759.96221-3-baohua@kernel.org>
On 11/29/26 10:37 PM, Barry Song (Xiaomi) wrote:
> From: Chris Mason <mason@kernel.org>
>
> With MGLRU, reclaim that races with compaction for a folio can deadlock
> on the lruvec->lru_lock that it already holds.
>
> isolate_folio() runs under the lru_lock. It takes a reference, and drops
> it again if another isolator has already cleared PG_lru. That
> folio_put() must not be the last one, since the free path takes the
> lru_lock if PG_lru is set. But compaction can release the lru_lock while
> the folio is still on the list with PG_lru clear. If the folio is
> truncated or unmapped meanwhile, the two isolators hold the only
> references:
>
> isolate_migratepages_block() evict_folios()
> ============================ ==============
> folio_get_nontail_page()
> folio_test_clear_lru()
> goto isolate_abort
> lruvec_unlock_irqrestore()
> lruvec_lock_irq()
> isolate_folio()
> folio_try_get()
> folio_test_clear_lru() fails
> folio_set_lru()
> folio_put()
> folio_put()
> __page_cache_release()
> folio_lruvec_lock_irqsave()
>
> The fix used here is to leave a folio alone if PG_lru is already clear,
> before a reference is taken, as isolate_lru_folios() does. An isolator
> that clears PG_lru after that test has to take the lru_lock before it
> drops its own reference.
>
> Fixes: ac35a4902374 ("mm: multi-gen LRU: minimal implementation")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chris Mason <mason@kernel.org>
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
> [Kairui: Improved the comment]
> Signed-off-by: Kairui Song <kasong@tencent.com>
> Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
> ---
LGTM.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
next prev parent reply other threads:[~2026-12-01 7:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 14:37 [PATCH 0/3] mm/mglru: fix a few reclaim issues Barry Song (Xiaomi)
2026-11-29 14:37 ` [PATCH 1/3] mm/mglru: count all generations as evictable Barry Song (Xiaomi)
2026-12-01 7:01 ` Baolin Wang
2026-11-29 14:37 ` [PATCH 2/3] mm/mglru: test PG_lru before taking a folio reference Barry Song (Xiaomi)
2026-12-01 7:18 ` Baolin Wang [this message]
2026-11-29 14:37 ` [PATCH 3/3] mm/mglru: report root reclaim to memory.pressure_level Barry Song (Xiaomi)
2026-11-30 3:53 ` [PATCH 0/3] mm/mglru: fix a few reclaim issues Kairui Song
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=86852b44-03c1-4865-8ef0-a7c0d0b26113@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baoquan.he@linux.dev \
--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=ridong.chen@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=stable@vger.kernel.org \
--cc=weixugc@google.com \
--cc=yuanchu@google.com \
--cc=yuzhao@google.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®