From: Usama Arif <usama.arif@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: david@kernel.org, willy@infradead.org, ryan.roberts@arm.com,
linux-mm@kvack.org, r@hev.cc, jack@suse.cz,
Andrew Donnellan <andrew+kernel@donnellan.id.au>,
apopple@nvidia.com, baohua@kernel.org,
baolin.wang@linux.alibaba.com, brauner@kernel.org,
catalin.marinas@arm.com, dev.jain@arm.com, kees@kernel.org,
kevin.brodsky@arm.com, lance.yang@linux.dev,
"Liam R.Howlett" <liam@infradead.org>,
linux-arm-kernel@lists.infradead.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
ljs@kernel.org, mhocko@suse.com, npache@redhat.com,
pasha.tatashin@soleen.com, rmclure@linux.ibm.com,
rppt@kernel.org, surenb@google.com, vbabka@kernel.org,
Al Viro <viro@zeniv.linux.org.uk>,
wilts.infradead.org@hp2.hsd1.ca.comcast.net, ziy@nvidia.com,
hannes@cmpxchg.org, kas@kernel.org, shakeel.butt@linux.dev,
kernel-team@meta.com
Subject: Re: [PATCH v5 0/2] mm: improve large folio readahead for exec memory
Date: Mon, 25 May 2026 16:01:19 +0100 [thread overview]
Message-ID: <8edc8cd0-f65c-4456-9b3f-362e744c9a96@linux.dev> (raw)
In-Reply-To: <20260522122052.7b4ad7c482a0e4826296e392@linux-foundation.org>
On 22/05/2026 20:20, Andrew Morton wrote:
> On Fri, 22 May 2026 09:23:46 -0700 Usama Arif <usama.arif@linux.dev> wrote:
>
>> Two checks in do_sync_mmap_readahead() limit large-folio readahead:
>>
>> 1. The mmap_miss heuristic is meant to throttle wasteful speculative
>> readahead. It is currently also applied to the VM_EXEC readahead
>> path, which is targeted rather than speculative. Once mmap_miss exceeds
>> MMAP_LOTSAMISS, exec readahead - including the large-folio
>> order requested by exec_folio_order() - is disabled. On
>> configurations where the mmap_miss decrement paths are not
>> active (see patch 1) the counter only grows, so exec readahead
>> is permanently disabled after the first 100 faults.
>>
>> 2. The force_thp_readahead path is gated only on
>> HPAGE_PMD_ORDER <= MAX_PAGECACHE_ORDER and always drives the
>> readahead at HPAGE_PMD_ORDER. Configurations where
>> HPAGE_PMD_ORDER exceeds MAX_PAGECACHE_ORDER never reach this
>> path, even when the mapping itself supports usefully large
>> folios well below the cap.
>>
>> Both issues are most visible on arm64 with a 64K base page size,
>> where HPAGE_PMD_ORDER is 13 (512MB) -- above MAX_PAGECACHE_ORDER
>> (11) -- and where fault_around_pages collapses to 1 disabling
>> should_fault_around() (one of the two mmap_miss decrement sites).
>> However the fixes are architecture-agnostic: patch 1 reflects the
>> nature of VM_EXEC readahead regardless of base page size, and
>> patch 2 generalises the gate so any mapping advertising a usefully
>> large maximum folio order can benefit.
>>
>> I created a benchmark that mmaps a large executable file and calls
>> RET-stub functions at PAGE_SIZE offsets across it. "Cold" measures
>> fault + readahead cost. "Random" first faults in all pages with a
>> sequential sweep (not measured), then measures time for calling random
>> offsets, isolating iTLB miss cost for scattered execution.
>>
>> The benchmark results on Neoverse V2 (Grace), arm64 with 64K base pages,
>> 512MB executable file on ext4, averaged over 3 runs:
>>
>> Phase | Baseline | Patched | Improvement
>> -----------|--------------|--------------|------------------
>> Cold fault | 83.4 ms | 41.3 ms | 50% faster
>> Random | 76.0 ms | 58.3 ms | 23% faster
>
> Well that's nice.
>
> AI review might have found a few things:
> https://sashiko.dev/#/patchset/20260522162422.3856502-1-usama.arif@linux.dev
>
Thanks Andrew! So sashiko seems to have brought out some interesting problems,
some of which are pre-existing. For example, the decrement sites for mmap_miss
in do_async_mmap_readahead() and filemap_map_pages() dont skip for VM_SEQ_READ.
I have sent this as an independent patch in [1].
I will send the next version of this series on top of [1] in a few days
addressing the rest of the issues raised by sashiko.
[1] https://lore.kernel.org/all/20260525145751.2671248-1-usama.arif@linux.dev/
prev parent reply other threads:[~2026-05-25 15:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260522162422.3856502-1-usama.arif@linux.dev>
2026-05-22 19:20 ` [PATCH v5 0/2] mm: improve large folio readahead for exec memory Andrew Morton
2026-05-25 15:01 ` Usama Arif [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=8edc8cd0-f65c-4456-9b3f-362e744c9a96@linux.dev \
--to=usama.arif@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=andrew+kernel@donnellan.id.au \
--cc=apopple@nvidia.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=brauner@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=hannes@cmpxchg.org \
--cc=jack@suse.cz \
--cc=kas@kernel.org \
--cc=kees@kernel.org \
--cc=kernel-team@meta.com \
--cc=kevin.brodsky@arm.com \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=npache@redhat.com \
--cc=pasha.tatashin@soleen.com \
--cc=r@hev.cc \
--cc=rmclure@linux.ibm.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=wilts.infradead.org@hp2.hsd1.ca.comcast.net \
--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