From: Pedro Falcato <pfalcato@suse.de>
To: Chengfeng Lin <lin2530632123@gmail.com>
Cc: Dev Jain <dev.jain@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, "Liam R. Howlett" <liam@infradead.org>,
Lorenzo Stoakes <ljs@kernel.org>,
Vlastimil Babka <vbabka@kernel.org>,
Jann Horn <jannh@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: mm/mprotect: testing a zero-offset fast path
Date: Mon, 30 Nov 2026 18:48:21 +0000 [thread overview]
Message-ID: <aw3ErpDOoG3FBr-C@pedro-suse.tail5790ac.ts.net> (raw)
In-Reply-To: <CANGjgd=LeQwXaV0nH3wojMvZDQbBJV06jpGcd7BoYp9qzdEPew@mail.gmail.com>
On Mon, Nov 30, 2026 at 05:21:47PM +0800, Chengfeng Lin wrote:
> Hi Dev, Pedro and all,
>
> On bare-metal x86 (i7-12700KF), I tested mprotect() with the libMicro
> benchmark used by MMTests. Before timing, it writes to a private
> /dev/zero mapping to populate its pages. It then changes permissions
> between PROT_NONE and PROT_READ | PROT_WRITE in 128 KiB requests.
> In a direct-parent / cac1db8c3aad / direct-parent comparison, requests
> took 8.1-8.3% longer on the commit than on either parent run. I saw this
> both with and without reading each page before removing access.
>
> To isolate one cost, I kept batching enabled on v7.3 and skipped just the
> two pte_advance_pfn() calls in prot_commit_flush_ptes() when idx is zero.
> At offset zero the subrange starts at the first PTE, so neither the old
> nor the new PTE needs its page frame number adjusted. Nonzero offsets,
> protection commits and TLB flush decisions are unchanged.
>
> Means of nine uninstrumented runs per arm:
>
> stock before guard only stock return
> libMicro with read-touch,
> us per 128 KiB request 2.462113 2.377241 2.456938
> Separate 16-PTE fixture,
> ns per NONE + RW round trip 2669.41 2591.66 2676.70
>
> The first row averages libMicro's default usecs/call medians from all
> nine runs per arm. libMicro filters batches within each run. With -w,
> the pages are written before timing. With -t, reading each page before
> removing access is part of the timed work. The result is time per
> 128 KiB benchmark request, not syscall-only latency.
>
> Request time fell by 3.45% / 3.24% (about 80-85 ns) versus the before/return
> baselines. In separate observations, all 8,192 batch queries returned one
> page and all 16,384 PTE advances had offset zero.
This doesn't match my expectations. What architecture is this? pte_advance_pfn()
is a fairly simple function with (AIUI) a fairly simple, predictable branch.
What's the difference in codegen? Could it be some artifact of code alignment?
--
Pedro
prev parent reply other threads:[~2026-11-30 18:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 9:21 Chengfeng Lin
2026-11-30 15:41 ` lin2530632123
2026-11-30 16:08 ` Lorenzo Stoakes (ARM)
2026-11-30 16:44 ` Chengfeng Lin
2026-11-30 16:48 ` Lorenzo Stoakes (ARM)
2026-11-30 17:13 ` Chengfeng Lin
2026-11-30 18:48 ` Pedro Falcato [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=aw3ErpDOoG3FBr-C@pedro-suse.tail5790ac.ts.net \
--to=pfalcato@suse.de \
--cc=akpm@linux-foundation.org \
--cc=dev.jain@arm.com \
--cc=jannh@google.com \
--cc=liam@infradead.org \
--cc=lin2530632123@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=vbabka@kernel.org \
/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®