Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
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 v4] mm/memfd_luo: don't use memfd_pin_folios()
Date: Wed, 25 Nov 2026 18:40:57 +0000	[thread overview]
Message-ID: <sashiko-outbox-234004@kernel.org> (raw)
In-Reply-To: <20261124184042.1823277-1-pratyush@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm/memfd_luo: unbatched migration and LRU drain in
  memfd_luo_migrate_folio()
--

commit 36bee618bf022031606488c041334f6b85cc82a9
Author: Pratyush Yadav (Google) <pratyush@kernel.org>

mm/memfd_luo: don't use memfd_pin_folios()

This commit replaces memfd_pin_folios() with a direct page cache walk
using shmem_get_folio() and migrates folios out of movable or CMA
pageblocks individually via memfd_luo_migrate_folio().

> diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c
> index 6b68220275ebe..38584ecfa70be 100644
> --- a/mm/memfd_luo.c
> +++ b/mm/memfd_luo.c
> @@ -77,26 +77,168 @@

[ ... ]

> +static int memfd_luo_migrate_folio(struct folio *folio)
> +{
> +	struct migration_target_control mtc = {
> +		.nid = NUMA_NO_NODE,
> +		/* Not movable, so the target is neither in ZONE_MOVABLE nor CMA. */
> +		.gfp_mask = GFP_USER | __GFP_NOWARN,
> +		.reason = MR_LONGTERM_PIN,
> +	};
> +	LIST_HEAD(source);
> +	bool isolated;
> +
> +	/* Flush per-CPU LRU batches holding the folio so isolation works. */
> +	lru_cache_drain_for_folio(folio, 1, NULL);
> +	isolated = isolate_folio_to_list(folio, &source);
> +	/* Isolation holds its own reference. */
> +	folio_put(folio);
> +	if (!isolated)
> +		return -EBUSY;
> +
> +	if (migrate_pages(&source, alloc_migration_target, NULL,
> +			  (unsigned long)&mtc, MIGRATE_SYNC, MR_LONGTERM_PIN,
> +			  NULL)) {
> +		putback_movable_pages(&source);
> +		return -ENOMEM;
> +	}
> +
> +	return 0;
> +}

[Severity: Medium]
Does migrating one folio at a time here regress preservation latency when
folios in the memfd already reside in ZONE_MOVABLE or MIGRATE_CMA
pageblocks?

Previously, memfd_pin_folios() called check_and_migrate_movable_folios(),
which shared a single enum lru_cache_drained state across the scan so
lru_add_drain() and lru_add_drain_all() ran at most once, and passed all
movable folios to a single migrate_pages() call so migrate_pages_batch()
could batch TLB shootdowns across up to NR_MAX_BATCHED_MIGRATION (512)
unmapped pages.

Calling memfd_luo_migrate_folio() per folio passes NULL for the drained
state to lru_cache_drain_for_folio(), which can trigger repeated local and
all-CPU LRU cache drains, and invokes migrate_pages() on a single-folio
list, forcing a cross-CPU TLB shootdown IPI for every mapped folio that
needs migration.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184042.1823277-1-pratyush@kernel.org?part=1


      parent reply	other threads:[~2026-11-25 18:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 18:40 [PATCH v4] mm/memfd_luo: don't use memfd_pin_folios() Pratyush Yadav
2026-11-25 11:04 ` Mike Rapoport
2026-11-25 18:40 ` 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-234004@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