mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Chengfeng Lin <chengfenglin@stu.xmu.edu.cn>,
	Pedro Falcato <pfalcato@suse.de>
Cc: "David Hildenbrand (Arm)" <david@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Vlastimil Babka <vbabka@kernel.org>, Jann Horn <jannh@google.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Barry Song <baohua@kernel.org>, Dev Jain <dev.jain@arm.com>,
	Ryan Roberts <ryan.roberts@arm.com>, Zi Yan <ziy@nvidia.com>
Subject: Re: [RFC] mm/mincore: present-PTE scan cost after pte_batch_hint() batching
Date: Wed, 10 Jun 2026 16:45:05 +0800	[thread overview]
Message-ID: <529db4e0-6635-4e3d-8ce5-f215ad9220cf@linux.alibaba.com> (raw)
In-Reply-To: <307c2254.17b12.19eb0678f22.Coremail.chengfenglin@stu.xmu.edu.cn>



On 6/10/26 3:20 PM, Chengfeng Lin wrote:
> Hi Pedro, David,
> 
> Thanks. I tried two newer GCC builds as well, using the same base config and
> the same mm/mincore.o build target.
> 
> The GCC 14.2 sizes were:
> 
>    v6.15 original:              0x1e8
>    v6.16 original:              0x229
>    v6.16 batch<=1 fastpath:     0x1d9
>    v6.16 with batching removed: 0x1d9
> 
> I also tried GCC 15.2 from the Ubuntu 25.10 (Questing) packages, extracted
> locally rather than installed system-wide:
> 
>    v6.15 original:              0x1e0
>    v6.16 original:              0x221
>    v6.16 batch<=1 fastpath:     0x1d1
>    v6.16 with batching removed: 0x1d1
> 
> So GCC 14.2 and GCC 15.2 match the GCC 13.3 direction: v6.16 original still
> does not collapse to the old x86 base-page shape, while the batch<=1 fastpath
> and the nobatch variant produce byte-identical `mincore_pte_range()` objdump
> output. Clang 18.1.3 behaves differently: all four checked variants produce
> byte-identical `mincore_pte_range()` objdump output there.
> 
> I also looked at the generated-code difference. It does not look like an
> obvious extra inlining decision. With GCC 13.3, GCC 14.2 and GCC 15.2, the
> original, fastpath, and nobatch builds all have the same external
> call/relocation targets:
> 
>    __pte_offset_map_lock
>    __pmd_trans_huge_lock
>    memset
>    __cond_resched
>    filemap_get_incore_folio
>    __folio_put
>    swapper_spaces
> 
> For GCC 15.2, I also saved focused optimization-dump snippets for
> mincore_pte_range(). They show the same direction before final assembly: the
> original build has more GCC intermediate code than the fastpath/nobatch builds
> (321 optimized-dump lines and 993 RTL-expand lines, compared with 299 and
> 921).
> 
> The visible difference is the PTE-loop layout. GCC keeps the v6.16 original
> `step`-based batching shape in the generated code, so the present-PTE hot path
> has an extra split/jump through a common advance block. The nobatch and
> batch<=1 fastpath builds produce a more compact, identical
> `mincore_pte_range()` objdump.
> 
> After Pedro's suggestion, I also tried forcing the default helper to
> `__always_inline`:
> 
>    static __always_inline unsigned int pte_batch_hint(pte_t *ptep, pte_t pte)
> 
> That did not change the result in this setup. For GCC 13.3, GCC 14.2 and
> GCC 15.2, the always-inline variant has the same size and normalized
> `mincore_pte_range()` objdump as v6.16 original, not the batch<=1 fastpath /
> nobatch shape.
> 
> I put the updated GCC14/GCC15 nm/objdump files, focused dump snippets, and a
> short side-by-side block note here:
> 
>    https://github.com/lcf0399/linux-mm-regression-evidence-2026-05/tree/444d66373b7be32f7a06b52b3d9ced7c2c53264f/mincore-present-pte-scan/codegen
> 
> One caveat: I have not rerun the timing part on bare metal. The timing signal
> I reported is still from the QEMU direct-boot lab, so I do not want to
> overstate that part. The codegen comparison above is static `mm/mincore.o`
> evidence and is not QEMU-dependent.
> 
> So the narrower result is that newer GCC did not make the codegen difference
> disappear in this check.
> 
> If there is another specific compiler/codegen detail that would be useful to
> check, I can look at that.

I quickly tested using your test cases (haven't reviewed your test code 
yet) on my x86 Xeon machine, and I didn't observe any obvious regression 
(tested 3 times, taking the average), and the data shows some noisy 
fluctuations:

test cases: ./mincore_present_pte_scan no_thp_pte_scan_64m 1
metric: mincore_ns_per_1k_pages, lower is better

base            revert 4df65651f7075
2675            2670

I still suspect it's an issue with your QEMU test environment. I'd 
suggest retesting on bare metals.

  reply	other threads:[~2026-06-10  8:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09  7:26 Chengfeng Lin
2026-06-09  9:01 ` David Hildenbrand (Arm)
2026-06-09  9:55   ` Barry Song
2026-06-09 14:12   ` Chengfeng Lin
2026-06-09 14:27     ` David Hildenbrand (Arm)
2026-06-09 21:12       ` Pedro Falcato
2026-06-10  7:20         ` Chengfeng Lin
2026-06-10  8:45           ` Baolin Wang [this message]
2026-06-10  9:20             ` Chengfeng Lin

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=529db4e0-6635-4e3d-8ce5-f215ad9220cf@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=chengfenglin@stu.xmu.edu.cn \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=jannh@google.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=pfalcato@suse.de \
    --cc=ryan.roberts@arm.com \
    --cc=vbabka@kernel.org \
    --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

all inboxes | Powered by JetHome®