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: huge_memory: use folio_can_map_prot_numa() for pmd folio

The folio_can_map_prot_numa() checks whether the folio can map prot numa,
which skips unsuitable folio, i.e. zone device, shared folios (KSM, CoW),
non-movable dma pinned, dirty file folio and folios that already have the
expected node affinity. Although the ksm only applies to small folios, an
extra test was added for large folios, but the other policies should be
applied to pmd folio, which helps to avoid unnecessary pmd change and
folio migration attempts.

Link: https://lkml.kernel.org/r/20251023113737.3572790-5-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kefeng Wang and committed by
Andrew Morton
f66e2727 ca43034c

+3 -14
+3 -14
mm/huge_memory.c
··· 2396 2396 #endif 2397 2397 2398 2398 if (prot_numa) { 2399 - struct folio *folio; 2400 - bool toptier; 2399 + 2401 2400 /* 2402 2401 * Avoid trapping faults against the zero page. The read-only 2403 2402 * data is likely to be read-cached on the local CPU and ··· 2408 2409 if (pmd_protnone(*pmd)) 2409 2410 goto unlock; 2410 2411 2411 - folio = pmd_folio(*pmd); 2412 - toptier = node_is_toptier(folio_nid(folio)); 2413 - /* 2414 - * Skip scanning top tier node if normal numa 2415 - * balancing is disabled 2416 - */ 2417 - if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_NORMAL) && 2418 - toptier) 2412 + if (!folio_can_map_prot_numa(pmd_folio(*pmd), vma, 2413 + vma_is_single_threaded_private(vma))) 2419 2414 goto unlock; 2420 - 2421 - if (folio_use_access_time(folio)) 2422 - folio_xchg_access_time(folio, 2423 - jiffies_to_msecs(jiffies)); 2424 2415 } 2425 2416 /* 2426 2417 * In case prot_numa, we are under mmap_read_lock(mm). It's critical