From: sashiko-bot@kernel.org
To: "Pedro Falcato" <pfalcato@suse.de>,
"Andrew Morton" <akpm@linux-foundation.org>,
"David Hildenbrand" <david@kernel.org>, "Zi Yan" <ziy@nvidia.com>
Cc: "Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <liam@infradead.org>,
"Nico Pache" <nico.pache@linux.dev>,
"Ryan Roberts" <ryan.roberts@arm.com>,
"Dev Jain" <dev.jain@arm.com>, "Barry Song" <baohua@kernel.org>,
"Lance Yang" <lance.yang@linux.dev>,
"Usama Arif" <usama.arif@linux.dev>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Kiryl Shutsemau" <kas@kernel.org>,
linux-mm@kvack.org
Subject: Re: [PATCH v2 1/8] mm/khugepaged: separate out windy folio logic from collapse_file
Date: Thu, 12 Nov 2026 17:51:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-211629@kernel.org> (raw)
In-Reply-To: <20261111175121.1328383-2-pfalcato@suse.de>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Critical] mm/khugepaged: unreleased xa_lock in
prepare_collapse_file_folio()
- [Low] mm/khugepaged: unused file and end fields in struct
collapse_file_state
--
commit 4417d51ddf77d1023dd61cf9f5007c13774865df
Author: Pedro Falcato <pfalcato@suse.de>
mm/khugepaged: separate out windy folio logic from collapse_file
This commit factors the per-folio preparation and locking logic out of
collapse_file() into a new prepare_collapse_file_folio() helper and
introduces struct collapse_file_state to pass state.
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 24eb8281ea3cd..0fe19acf470b7 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2211,6 +2211,105 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff)
> i_mmap_unlock_read(mapping);
> }
>
> +struct collapse_file_state {
> + /* Inputs */
> + struct address_space *mapping;
> + struct file *file;
> + struct xa_state *xas;
> + /* folio is in-out; preparing might modify it */
> + struct folio *folio;
> + /* collapse end index */
> + const pgoff_t end;
> + const bool is_shmem : 1;
> + bool do_readahead : 1;
> + bool readahead_done : 1;
> +};
[Severity: Low]
This isn't a bug, but the file and end fields in struct collapse_file_state
are initialized in collapse_file() and never read anywhere.
[ ... ]
> +static enum scan_result
> +prepare_collapse_file_folio(pgoff_t index, struct collapse_file_state *state)
> +{
> + struct address_space *mapping = state->mapping;
> + enum scan_result result = SCAN_SUCCEED;
> + const bool is_shmem = state->is_shmem;
> + struct folio *folio = state->folio;
> +
> + if (is_shmem) {
[ ... ]
> + } else { /* !is_shmem */
> + if (!folio || xa_is_value(folio)) {
> + state->do_readahead = !state->readahead_done;
> + result = SCAN_FAIL;
> + goto xa_unlocked;
[ ... ]
> +xa_locked:
> + xas_unlock_irq(state->xas);
> +xa_unlocked:
> + state->folio = folio;
> + return result;
> +}
[Severity: Critical]
Does jumping to xa_unlocked instead of xa_locked here return with
state->xas still locked and IRQs disabled when a non-shmem file range has a
missing or shadow page-cache entry?
In collapse_file(), the !SCAN_SUCCEED path also jumps directly to
xa_unlocked and proceeds to rollback:, where it sleeps while atomic and
deadlocks trying to re-acquire mapping->i_pages.xa_lock during readahead
(or returns with xa_lock held and IRQs disabled if readahead already ran).
This regression is later resolved in the series by commit "mm/khugepaged:
factor out page cache folio reading", but breaks bisection here.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111175121.1328383-1-pfalcato@suse.de?part=1
next prev parent reply other threads:[~2026-11-12 17:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 17:51 [PATCH v2 0/8] mm/khugepaged: collapse_file() cleanups Pedro Falcato
2026-11-11 17:51 ` [PATCH v2 1/8] mm/khugepaged: separate out windy folio logic from collapse_file Pedro Falcato
2026-11-12 17:51 ` sashiko-bot [this message]
2026-11-11 17:51 ` [PATCH v2 2/8] mm/khugepaged: sanitize the folio passed to file folio collapse logic Pedro Falcato
2026-11-11 17:51 ` [PATCH v2 3/8] mm/khugepaged: factor out page cache folio reading Pedro Falcato
2026-11-11 17:51 ` [PATCH v2 4/8] mm/khugepaged: factor out and simplify dirty/writeback handling Pedro Falcato
2026-11-11 17:51 ` [PATCH v2 5/8] mm/khugepaged: simplify prepare folio locking and exit paths Pedro Falcato
2026-11-11 17:51 ` [PATCH v2 6/8] mm/khugepaged: hoist isolation into collapse_isolate_folio() Pedro Falcato
2026-11-11 17:51 ` [PATCH v2 7/8] mm/khugepaged: hoist more code " Pedro Falcato
2026-11-12 17:51 ` sashiko-bot
2026-11-11 17:51 ` [PATCH v2 8/8] mm/khugepaged: flesh out try_to_unmap_flush() comment Pedro Falcato
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=sashiko-outbox-211629@kernel.org \
--to=sashiko-bot@kernel.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=kas@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=nico.pache@linux.dev \
--cc=pfalcato@suse.de \
--cc=ryan.roberts@arm.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=usama.arif@linux.dev \
--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