From: "Huang, Ying" <ying.huang@linux.alibaba.com>
To: Zhiteng Qiu <qiuzhiteng@hygon.cn>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>, 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>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm/migrate: don't batch the TLB flush when there is nothing to batch
Date: Sat, 07 Nov 2026 20:22:50 +0800 [thread overview]
Message-ID: <87ld74x23p.fsf@DESKTOP-5N7EMDA> (raw)
In-Reply-To: <20261107190737.1538200-1-qiuzhiteng@hygon.cn> (Zhiteng Qiu's message of "Sat, 7 Nov 2026 19:07:37 +0800")
Zhiteng Qiu <qiuzhiteng@hygon.cn> writes:
> Hi Ying,
>
>> Have you adjusted the NUMA scanning parameters?
>
> No. All NUMA balancing tunables are at their defaults
> (scan_delay_ms=1000, scan_period_min_ms=1000,
> scan_period_max_ms=60000, scan_size_mb=256).
>
> The scan is indeed slow: 58 passes of 256 MB in 55 s, 89 ms each,
> about 9% of wall time. But the hint faults are not spread evenly
> between passes: those 9% carry 33% of all migrations.
>
> The faults come from the scan, just not from the pass that happens
> to be running at that instant. Of the migrations that happen
> during a pass, 60% are for pages in the 256 MB chunk being scanned
> right now; nearly all the rest are for pages scanned one or two
> chunks earlier (lower addresses, within 512 MB). None are from
> addresses the scanner has not reached yet. So the scan makes the
> pages PROT_NONE and the workload touches them again within a second
> or two, while this or the next pass is running. The collision is
> not a coincidence between two independent events.
>
> Here is the sequence, one pass on the unpatched kernel:
>
> CPU A (task_numa_work) CPU B..N (workload threads)
> ---------------------- ---------------------------
> tlb_gather_mmu()
> tlb_flush_pending++
> change_pte_range(table 1)
> PTEs -> PROT_NONE
> access page in table 1
> do_numa_page()
> migrate_misplaced_folio()
> try_to_migrate_one()
> PROT_NONE, but pending set:
> pte_accessible() == true
> tlb_flush_batched++
> try_to_unmap_flush()
> full flush, IPI to ~380 CPUs
> change_pte_range(table 2)
> flush_tlb_batched_pending()
> pending != flushed:
> flush_tlb_mm(), IPI to ~380 CPUs
> PTEs -> PROT_NONE
> (same for pages in table 2)
> ... 128 PTE tables, ~0.7 ms each ...
> tlb_finish_mmu() pass took ~89 ms, not ~7 ms
> tlb_flush_pending--
This looks much more clear! Thanks!
> Each table flush makes the pass longer, and a longer pass lets more
> faults happen while tlb_flush_pending is set. With the patch the
> migration takes the direct path: it may still flush while the pass
> is running, but it does not bump tlb_flush_batched, so the scan does
> not pay per table and the pass stays at ~7 ms.
>
>> That appear too complex.
>
> Agreed. I'll keep the change in migrate_folio_unmap() and put the
> sequence above into the v2 changelog.
Sounds good to me.
---
Best Regards,
Huang, Ying
next prev parent reply other threads:[~2026-11-07 12:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 4:16 [PATCH] mm/migrate: don't batch the TLB flush when there is nothing to batch Zhiteng Qiu
2026-11-06 9:37 ` Huang, Ying
2026-11-06 10:09 ` Zhiteng Qiu
2026-11-06 17:50 ` Zhiteng Qiu
2026-11-07 6:54 ` Huang, Ying
2026-11-07 11:07 ` Zhiteng Qiu
2026-11-07 12:22 ` Huang, Ying [this message]
2026-11-07 12:26 ` Huang, Ying
2026-11-07 14:34 ` [PATCH v2] " Zhiteng Qiu
2026-11-08 12:52 ` Huang, Ying
2026-11-08 14:42 ` Zi Yan
2026-11-09 12:29 ` [PATCH v3] " Zhiteng Qiu
2026-11-09 13:07 ` David Hildenbrand (Arm)
2026-11-09 16:18 ` Zhiteng Qiu
2026-11-09 20:36 ` David Hildenbrand (Arm)
2026-11-10 1:41 ` Huang, Ying
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=87ld74x23p.fsf@DESKTOP-5N7EMDA \
--to=ying.huang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=byungchul@sk.com \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=joshua.hahnjy@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=matthew.brost@intel.com \
--cc=qiuzhiteng@hygon.cn \
--cc=xhao@linux.alibaba.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.