[PATCH 1/2] mm/filemap: place page-cache folios via an explicit mempolicy

From: Gregory Price

Date: Wed Jul 01 2026 - 18:22:20 EST


Page-cache allocations have no mempolicy of their own and implicitly
follow first-touch task mempolicy via the page allocator.

Codify this preference explicitly in filemap.c, rather than taking an
implicit behavior from the page allocator. No functional change; it
keeps pagecache placement stable across the following change.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Gregory Price <gourry@xxxxxxxxxx>
---
mm/filemap.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 5af62e6abca5..d419d09a58c1 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -25,6 +25,7 @@
#include <linux/syscalls.h>
#include <linux/mman.h>
#include <linux/pagemap.h>
+#include <linux/mempolicy.h>
#include <linux/file.h>
#include <linux/uio.h>
#include <linux/error-injection.h>
@@ -1010,7 +1011,9 @@ struct folio *filemap_alloc_folio_noprof(gfp_t gfp, unsigned int order,

return folio;
}
- return folio_alloc_noprof(gfp, order);
+ /* page cache defaults to first-accessor task mempolicy for placement */
+ return folio_alloc_mpol_noprof(gfp, order, get_task_policy(current),
+ NO_INTERLEAVE_INDEX, numa_node_id());
}
EXPORT_SYMBOL(filemap_alloc_folio_noprof);
#endif
--
2.53.0-Meta