[PATCH] [fixlet] mm/filemap: add comment explaining design decision

From: Usama Arif

Date: Fri May 29 2026 - 08:31:05 EST


Signed-off-by: Usama Arif <usama.arif@xxxxxxxxx>
---
mm/filemap.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/mm/filemap.c b/mm/filemap.c
index bfb891d9da1f..0a3facf452b3 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3319,6 +3319,14 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)

/* Use the readahead code, even if readahead is disabled */
if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && (vm_flags & VM_HUGEPAGE)) {
+ /*
+ * Preserve PMD-sized readahead where it already fits in
+ * the page cache. Otherwise cap the new fallback path at
+ * 2MB: this is the common PMD-sized hugepage size, and it
+ * avoids memory pressure from very large forced readahead
+ * when mapping_max_folio_order() is high (for example,
+ * 128MB with 64K base pages on arm64).
+ */
if (HPAGE_PMD_ORDER <= MAX_PAGECACHE_ORDER) {
force_thp_readahead = true;
thp_order = HPAGE_PMD_ORDER;
--
2.53.0-Meta