From: sashiko-bot@kernel.org
To: "Pratyush Yadav" <pratyush@kernel.org>,
"Pasha Tatashin" <pasha.tatashin@soleen.com>,
"Mike Rapoport" <rppt@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>
Cc: kexec@lists.infradead.org, linux-mm@kvack.org
Subject: Re: [PATCH v3] mm/memfd_luo: don't use memfd_pin_folios()
Date: Tue, 24 Nov 2026 13:01:49 +0000 [thread overview]
Message-ID: <sashiko-outbox-231187@kernel.org> (raw)
In-Reply-To: <20261123130115.4021199-1-pratyush@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm/memfd_luo: memfd_luo_get_folio() returns -EBUSY after last
migration
--
commit 41c3599dbcd67e367dde6fcd9824d0c532431810
Author: Pratyush Yadav (Google) <pratyush@kernel.org>
mm/memfd_luo: don't use memfd_pin_folios()
This commit replaces memfd_pin_folios() in memfd_luo with a direct page
cache walk using shmem_get_folio() and migrates folios that are not
longterm pinnable via memfd_luo_migrate_folio().
> diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c
> index 6b68220275ebe..c963bc3522e61 100644
> --- a/mm/memfd_luo.c
> +++ b/mm/memfd_luo.c
> @@ -77,26 +77,161 @@
[ ... ]
> +/* How many times to try migrating a folio that is not longterm pinnable. */
> +#define MEMFD_LUO_MIGRATE_RETRIES 3
[ ... ]
> +static int memfd_luo_get_folio(struct inode *inode, pgoff_t index,
> + struct folio **foliop)
> +{
> + struct folio *folio;
> + int err, retry;
> +
> + for (retry = 0; retry < MEMFD_LUO_MIGRATE_RETRIES; retry++) {
> + err = shmem_get_folio(inode, index, 0, &folio, SGP_CACHE);
> + if (err)
> + return err;
> +
> + if (likely(folio_is_longterm_pinnable(folio))) {
> + *foliop = folio;
> + return 0;
> + }
> +
> + folio_unlock(folio);
> + err = memfd_luo_migrate_folio(folio);
> + /* Someone else might have it isolated, retry a bit. */
> + if (err && err != -EBUSY)
> + return err;
> + }
> +
> + return -EBUSY;
> +}
[Severity: Medium]
Does memfd_luo_get_folio() return -EBUSY even when
memfd_luo_migrate_folio() succeeds on the final iteration?
Because memfd_luo_migrate_folio() drops the reference to the old folio,
memfd_luo_get_folio() relies on the next iteration of the loop to call
shmem_get_folio() and look up the migrated folio. If isolation fails with
-EBUSY on the first two attempts and migration succeeds on the third
(retry == MEMFD_LUO_MIGRATE_RETRIES - 1), the loop terminates before
re-fetching the migrated folio and fails preservation with -EBUSY.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123130115.4021199-1-pratyush@kernel.org?part=1
prev parent reply other threads:[~2026-11-24 13:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 13:01 [PATCH v3] mm/memfd_luo: don't use memfd_pin_folios() Pratyush Yadav
2026-11-23 19:54 ` Mike Rapoport
2026-11-24 13:01 ` sashiko-bot [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=sashiko-outbox-231187@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=kexec@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox