Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/filemap: Extend __filemap_get_folio() to support NUMA memory policies

Extend __filemap_get_folio() to support NUMA memory policies by
renaming the implementation to __filemap_get_folio_mpol() and adding
a mempolicy parameter. The original function becomes a static inline
wrapper that passes NULL for the mempolicy.

This infrastructure will enable future support for NUMA-aware page cache
allocations in guest_memfd memory backend KVM guests.

Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Shivank Garg <shivankg@amd.com>
Tested-by: Ashish Kalra <ashish.kalra@amd.com>
Link: https://lore.kernel.org/r/20250827175247.83322-5-shivankg@amd.com
Signed-off-by: Sean Christopherson <seanjc@google.com>

authored by

Matthew Wilcox and committed by
Sean Christopherson
16a542e2 7f3779a3

+14 -7
+8 -2
include/linux/pagemap.h
··· 755 755 } 756 756 757 757 void *filemap_get_entry(struct address_space *mapping, pgoff_t index); 758 - struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, 759 - fgf_t fgp_flags, gfp_t gfp); 758 + struct folio *__filemap_get_folio_mpol(struct address_space *mapping, 759 + pgoff_t index, fgf_t fgf_flags, gfp_t gfp, struct mempolicy *policy); 760 760 struct page *pagecache_get_page(struct address_space *mapping, pgoff_t index, 761 761 fgf_t fgp_flags, gfp_t gfp); 762 + 763 + static inline struct folio *__filemap_get_folio(struct address_space *mapping, 764 + pgoff_t index, fgf_t fgf_flags, gfp_t gfp) 765 + { 766 + return __filemap_get_folio_mpol(mapping, index, fgf_flags, gfp, NULL); 767 + } 762 768 763 769 /** 764 770 * write_begin_get_folio - Get folio for write_begin with flags.
+6 -5
mm/filemap.c
··· 1928 1928 } 1929 1929 1930 1930 /** 1931 - * __filemap_get_folio - Find and get a reference to a folio. 1931 + * __filemap_get_folio_mpol - Find and get a reference to a folio. 1932 1932 * @mapping: The address_space to search. 1933 1933 * @index: The page index. 1934 1934 * @fgp_flags: %FGP flags modify how the folio is returned. 1935 1935 * @gfp: Memory allocation flags to use if %FGP_CREAT is specified. 1936 + * @policy: NUMA memory allocation policy to follow. 1936 1937 * 1937 1938 * Looks up the page cache entry at @mapping & @index. 1938 1939 * ··· 1944 1943 * 1945 1944 * Return: The found folio or an ERR_PTR() otherwise. 1946 1945 */ 1947 - struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, 1948 - fgf_t fgp_flags, gfp_t gfp) 1946 + struct folio *__filemap_get_folio_mpol(struct address_space *mapping, 1947 + pgoff_t index, fgf_t fgp_flags, gfp_t gfp, struct mempolicy *policy) 1949 1948 { 1950 1949 struct folio *folio; 1951 1950 ··· 2015 2014 err = -ENOMEM; 2016 2015 if (order > min_order) 2017 2016 alloc_gfp |= __GFP_NORETRY | __GFP_NOWARN; 2018 - folio = filemap_alloc_folio(alloc_gfp, order, NULL); 2017 + folio = filemap_alloc_folio(alloc_gfp, order, policy); 2019 2018 if (!folio) 2020 2019 continue; 2021 2020 ··· 2062 2061 folio_clear_dropbehind(folio); 2063 2062 return folio; 2064 2063 } 2065 - EXPORT_SYMBOL(__filemap_get_folio); 2064 + EXPORT_SYMBOL(__filemap_get_folio_mpol); 2066 2065 2067 2066 static inline struct folio *find_get_entry(struct xa_state *xas, pgoff_t max, 2068 2067 xa_mark_t mark)