From: Ze Zuo zuoze1@huawei.com
skip cow page, and ksm page for base page.
Signed-off-by: Ze Zuo zuoze1@huawei.com --- mm/mem_sampling.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/mm/mem_sampling.c b/mm/mem_sampling.c index 23f3eb28c5e6..bbf6e6ed9229 100644 --- a/mm/mem_sampling.c +++ b/mm/mem_sampling.c @@ -24,6 +24,8 @@ #include <linux/sched/numa_balancing.h> #include <trace/events/kmem.h>
+#include "internal.h" + struct mem_sampling_ops_struct mem_sampling_ops;
static int mem_sampling; @@ -224,7 +226,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))) @@ -263,6 +265,11 @@ 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);