From: Lance Yang <lance.yang@linux.dev>
To: Sasha Levin <sashal@kernel.org>, stable@vger.kernel.org
Cc: syzbot+16bf7cd0ebeb1de93aa5@syzkaller.appspotmail.com,
Pedro Falcato <pfalcato@suse.de>,
"David Hildenbrand (Arm)" <david@kernel.org>,
Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>
Subject: Re: [PATCH 5.15.y v2] khugepaged: fix readahead lock inversion in collapse_file()
Date: Mon, 30 Nov 2026 20:33:25 +0800 [thread overview]
Message-ID: <8c67417f-0d76-46db-80c4-ad7a18617de3@linux.dev> (raw)
In-Reply-To: <2026-11-28-1-daily-reply-0027@kernel.org>
On 2026/11/30 02:59, Sasha Levin wrote:
>> We need to release those folio locks before starting readahead. On a page
>> cache miss, roll back first, populate the collapse range, and retry once.
>
> Both the 6.1 and the 5.15 backport retry with the same huge page
> ("goto retry") after collapse_file() has already inserted it into the
> page cache. These trees lack a2e17cc2efc7 ("mm/khugepaged: maintain
> page cache uptodate flag"), which keeps the new page out of the page
> cache until the collapse succeeds. So a racing lookup can hold a
> reference to the locked, not-uptodate page and wait on its lock; the
> rollback unlock_page() can hand it the lock, and the retry then
> re-locks the page with __SetPageLocked() and sets ->mapping again. Two
> tasks then hold PG_locked, or a waiter treats the not-uptodate THP as a
> normal page cache page. This is from reading the code, not reproduced.
Ouch ... I missed that some upstream fixes hadn't made it into
6.1.y or 5.15.y.
On 5.15, v2 also skipped an existing page_count() check on retry :(
> Could you respin: either free the huge page and allocate a fresh one
> before retrying, or do the readahead after the rollback and return
> SCAN_FAIL without a retry? (5.15 already stopped reusing the
Sure. In v3, we drop our reference to that huge page and retry
with a fresh one.
6.1.y:
https://lore.kernel.org/all/20261130123040.40795-1-lance.yang@linux.dev/
5.15.y:
https://lore.kernel.org/all/20261130123237.41399-1-lance.yang@linux.dev/
I've tested both backports. Thanks for catching this!
Cheers, Lance
> huge page when page_count > 1 in 033b5d775511 ("mm/khugepaged: fix
> filemap page_to_pgoff(page) != offset").)
>
next prev parent reply other threads:[~2026-11-30 12:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 1:24 FAILED: patch "[PATCH] khugepaged: fix readahead lock inversion in collapse_file()" failed to apply to 5.15-stable tree Sasha Levin
2026-11-11 13:24 ` [PATCH 5.15.y] khugepaged: fix readahead lock inversion in collapse_file() Lance Yang
2026-11-26 14:18 ` Greg KH
2026-11-27 8:16 ` [PATCH 5.15.y v2] " Lance Yang
2026-11-29 18:59 ` Sasha Levin
2026-11-30 12:33 ` Lance Yang [this message]
2026-11-30 12:32 ` [PATCH 5.15.y v3] " Lance Yang
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=8c67417f-0d76-46db-80c4-ad7a18617de3@linux.dev \
--to=lance.yang@linux.dev \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=pfalcato@suse.de \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+16bf7cd0ebeb1de93aa5@syzkaller.appspotmail.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 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.