From: sashiko-bot@kernel.org
To: "Zhiteng Qiu" <qiuzhiteng@hygon.cn>,
"Andrew Morton" <akpm@linux-foundation.org>,
"David Hildenbrand" <david@kernel.org>
Cc: "Ying Huang" <ying.huang@linux.alibaba.com>,
"Zi Yan" <ziy@nvidia.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Joshua Hahn" <joshua.hahnjy@gmail.com>,
"Byungchul Park" <byungchul@sk.com>,
"Gregory Price" <gourry@gourry.net>,
"Alistair Popple" <apopple@nvidia.com>,
"Xin Hao" <xhao@linux.alibaba.com>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"Yuan Zhong" <zhongyuan@hygon.cn>,
"Shifei Ge" <geshifei@hygon.cn>,
"Jianyong Wu" <wujianyong@hygon.cn>,
"Shijie Huang" <huangsj@hygon.cn>,
"Yibin Liu" <liuyibin@hygon.cn>,
"Fengyu Wang" <wangfengyu@hygon.cn>,
linux-mm@kvack.org
Subject: Re: [PATCH v5] mm/migrate: don't batch the TLB flush when there is nothing to batch
Date: Fri, 04 Dec 2026 18:18:23 +0000 [thread overview]
Message-ID: <sashiko-outbox-250401@kernel.org> (raw)
In-Reply-To: <20261203181741.2318590-1-qiuzhiteng@hygon.cn>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm: migrate_pages_batch() guesses deferred TLB flush via
flush_deferred
--
commit 15115ab4349d82d585db7d6e31ded84d79bfe478
Author: Zhiteng Qiu <qiuzhiteng@hygon.cn>
mm/migrate: don't batch the TLB flush when there is nothing to batch
This commit lets migrate_pages_batch() omit TTU_BATCH_FLUSH during
asynchronous migration when no deferred flush is tracked, only a single
small folio remains, and the folio is not mapped shared.
Link: https://lore.kernel.org/r/20261122171706.9376E1F000C4@smtp.kernel.org
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 96b66a272379f..731d661108f19 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
[ ... ]
> @@ -2020,7 +2050,17 @@ static int migrate_pages_batch(struct list_head *from,
>
> cond_resched_tasks_rcu_qs();
>
> - rc = migrate_folio_unmap(folio, dst, mode, ret_folios);
> + ttu = folio_migrate_ttu_flags(folio, mode,
> + &new_folios, flush_deferred);
> + /*
> + * A folio that looks mapped here may leave a flush
> + * queued, which the rest of the batch can merge with.
> + */
> + if (ttu == TTU_BATCH_FLUSH && folio_mapped(folio))
> + flush_deferred = true;
> +
> + rc = migrate_folio_unmap(folio, dst, mode, ttu,
> + ret_folios);
[Severity: Medium]
Can folio_migrate_ttu_flags() check current->tlb_ubc.flush_required
directly instead of guessing with flush_deferred?
Because flush_deferred is set before migrate_folio_unmap() runs, an earlier
folio that bails out on folio_trylock() or writeback still latches it for
the rest of the batch. A trailing small private folio then still gets
TTU_BATCH_FLUSH and bumps mm->tlb_flush_batched with no queued flush.
Checking folio_mapped() unlocked can also miss a flush if a concurrent
minor fault maps a page-cache folio before migrate_folio_unmap() locks it.
try_to_migrate() then queues a flush while flush_deferred stays false, so a
trailing small private folio flushes immediately before try_to_unmap_flush().
A small try_to_unmap_flush_pending() helper in mm/internal.h reading
current->tlb_ubc.flush_required (returning false without
CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH) would give the exact state
across retry passes and avoid flush_deferred altogether.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203181741.2318590-1-qiuzhiteng@hygon.cn?part=1
prev parent reply other threads:[~2026-12-04 18:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 18:17 [PATCH v5] mm/migrate: don't batch the TLB flush when there is nothing to batch Zhiteng Qiu
2026-12-04 12:25 ` David Hildenbrand (Arm)
2026-12-04 18:18 ` 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-250401@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=byungchul@sk.com \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=geshifei@hygon.cn \
--cc=gourry@gourry.net \
--cc=huangsj@hygon.cn \
--cc=joshua.hahnjy@gmail.com \
--cc=linux-mm@kvack.org \
--cc=liuyibin@hygon.cn \
--cc=matthew.brost@intel.com \
--cc=qiuzhiteng@hygon.cn \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wangfengyu@hygon.cn \
--cc=wujianyong@hygon.cn \
--cc=xhao@linux.alibaba.com \
--cc=ying.huang@linux.alibaba.com \
--cc=zhongyuan@hygon.cn \
--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