hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I9GZAQ CVE: NA
--------------------------------
This patch adds trace events for the sampling and migration of pages, . Using the events, it will be known what page has been sampled and are being migrated.
Signed-off-by: Ze Zuo zuoze1@huawei.com Signed-off-by: Tong Tiangen tongtiangen@huawei.com Signed-off-by: Shuang Yan yanshuang7@huawei.com --- include/trace/events/kmem.h | 53 +++++++++++++++++++++++++++++++++++++ mm/memory.c | 1 + mm/mempolicy.c | 4 +++ 3 files changed, 58 insertions(+)
diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h index f65b1f6db22d..307fa0c3380f 100644 --- a/include/trace/events/kmem.h +++ b/include/trace/events/kmem.h @@ -363,6 +363,59 @@ TRACE_EVENT(rss_stat, __entry->member, __entry->size) ); + +#ifdef CONFIG_NUMABALANCING_MEM_SAMPLING +TRACE_EVENT(mm_numa_migrating, + + TP_PROTO(u64 laddr, int page_nid, int target_nid, + int migrate_success), + + TP_ARGS(laddr, page_nid, target_nid, migrate_success), + + TP_STRUCT__entry( + __field(u64, laddr) + __field(int, page_nid) + __field(int, target_nid) + __field(int, migrate_success) + ), + + TP_fast_assign( + __entry->laddr = laddr; + __entry->page_nid = page_nid; + __entry->target_nid = target_nid; + __entry->migrate_success = !!(migrate_success); + ), + + TP_printk("laddr=%llu page_nid=%d target_nid=%d migrate_success=%d", + __entry->laddr, __entry->page_nid, + __entry->target_nid, __entry->migrate_success) +); + +TRACE_EVENT(mm_mem_sampling_access_record, + + TP_PROTO(u64 laddr, u64 paddr, int cpuid, int pid), + + TP_ARGS(laddr, paddr, cpuid, pid), + + TP_STRUCT__entry( + __field(u64, laddr) + __field(u64, paddr) + __field(int, cpuid) + __field(int, pid) + ), + + TP_fast_assign( + __entry->laddr = laddr; + __entry->paddr = paddr; + __entry->cpuid = cpuid; + __entry->pid = pid; + ), + + TP_printk("laddr=%llu paddr=%llu cpuid=%d pid=%d", + __entry->laddr, __entry->paddr, + __entry->cpuid, __entry->pid) +); +#endif /* CONFIG_NUMABALANCING_MEM_SAMPLING */ #endif /* _TRACE_KMEM_H */
/* This part must be outside protection */ diff --git a/mm/memory.c b/mm/memory.c index 9fd66e4193f5..eb7cb36abf45 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4557,6 +4557,7 @@ void do_numa_access(struct task_struct *p, u64 laddr, u64 paddr) }
out: + trace_mm_numa_migrating(laddr, page_nid, target_nid, flags&TNF_MIGRATED); if (page_nid != NUMA_NO_NODE) task_numa_fault(last_cpupid, page_nid, 1, flags);
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 25e991e6bb60..d81996ef0be0 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -108,6 +108,8 @@ #include <linux/task_work.h> #include <linux/mem_sampling.h>
+#include <trace/events/kmem.h> + #include <asm/tlbflush.h> #include <linux/uaccess.h>
@@ -785,6 +787,8 @@ void numa_balancing_mem_sampling_cb(struct mem_sampling_record *record) if (p->pid != record->context_id) return;
+ trace_mm_mem_sampling_access_record(laddr, paddr, smp_processor_id(), + current->pid); numa_create_taskwork(laddr, paddr, smp_processor_id()); }