From: Ze Zuo zuoze1@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IAFONL CVE: NA
--------------------------------
Skip cow page and ksm page for base page, like what change_pte_range did.
Signed-off-by: Ze Zuo zuoze1@huawei.com Signed-off-by: Nanyong Sun sunnanyong@huawei.com --- mm/mem_sampling.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/mm/mem_sampling.c b/mm/mem_sampling.c index e0470052ae9c..7d3a159c8f16 100644 --- a/mm/mem_sampling.c +++ b/mm/mem_sampling.c @@ -23,6 +23,7 @@ #include <linux/migrate.h> #include <linux/sched/numa_balancing.h> #include <trace/events/kmem.h> +#include "internal.h"
struct mem_sampling_ops_struct mem_sampling_ops;
@@ -257,7 +258,7 @@ static void do_numa_access(struct task_struct *p, u64 vaddr, u64 paddr) goto out_unlock;
page = pfn_to_online_page(PHYS_PFN(paddr)); - if (!page || is_zone_device_page(page)) + if (!page || is_zone_device_page(page) || PageKsm(page)) goto out_unlock;
if (unlikely(!PageLRU(page))) @@ -275,6 +276,10 @@ static void do_numa_access(struct task_struct *p, u64 vaddr, u64 paddr) if (page_mapcount(page) > 1 && (vma->vm_flags & VM_SHARED)) flags |= TNF_SHARED;
+ /* Also skip shared copy-on-write pages */ + if (is_cow_mapping(vma->vm_flags) && page_count(page) != 1) + goto out_unlock; + last_cpupid = page_cpupid_last(page); page_nid = page_to_nid(page);