[PATCH RFC][makedumpfile 10/10] Introducing 2 eppic scripts to test the dwarf/btf eppic extension

Tao Liu ltao at redhat.com
Tue Jun 10 02:57:43 PDT 2025


This patch will introduce 2 eppic scripts. One is for filtering out amdgpu
mm pages, the other is for printing all tasks VMAs. dwarf & btf eppic
extension should produce the same result for every eppic script, mainly
for test use.

Signed-off-by: Tao Liu <ltao at redhat.com>
---
 eppic_scripts/filter_amdgpu_mm_pages.c | 36 ++++++++++++++++++++++++++
 eppic_scripts/print_all_vma.c          | 29 +++++++++++++++++++++
 2 files changed, 65 insertions(+)
 create mode 100644 eppic_scripts/filter_amdgpu_mm_pages.c
 create mode 100644 eppic_scripts/print_all_vma.c

diff --git a/eppic_scripts/filter_amdgpu_mm_pages.c b/eppic_scripts/filter_amdgpu_mm_pages.c
new file mode 100644
index 0000000..2936a54
--- /dev/null
+++ b/eppic_scripts/filter_amdgpu_mm_pages.c
@@ -0,0 +1,36 @@
+int main()
+{
+	struct task_struct *p;
+	unsigned long p_off;
+	int i, c;
+	struct vm_area_struct *vma;
+	struct ttm_buffer_object *tbo;
+	unsigned long pfn, num, mt;
+
+	p = (struct task_struct *)&init_task;
+	p_off = (unsigned long)&(p->tasks) - (unsigned long)p;
+
+	do {
+		if (!(p->mm)) {
+			p = (struct task_struct *)((unsigned long)(p->tasks.next) - p_off);
+			continue;
+		}
+		mt = (unsigned long)&(p->mm->mm_mt);
+
+		c = maple_count((char *)mt);
+		for (i = 0; i < c; i++) {
+			vma = (struct vm_area_struct *)maple_elem((char *)mt, i);
+			if (vma->vm_ops == &amdgpu_gem_vm_ops) {
+				tbo = (struct ttm_buffer_object *)(vma->vm_private_data);
+                                if (tbo->ttm) {                                  
+					num = (unsigned long)(tbo->ttm->num_pages);
+                                        pfn = ((unsigned long)(tbo->ttm->pages[0]) - *(unsigned long *)&vmemmap_base) / sizeof(struct page);
+					filter_pages(pfn, num);
+                                } 
+			}
+		}
+		p = (struct task_struct *)((unsigned long)(p->tasks.next) - p_off);
+	} while(p != &init_task);
+
+	return 1;
+}
diff --git a/eppic_scripts/print_all_vma.c b/eppic_scripts/print_all_vma.c
new file mode 100644
index 0000000..e8e49c2
--- /dev/null
+++ b/eppic_scripts/print_all_vma.c
@@ -0,0 +1,29 @@
+int main()
+{
+	struct task_struct *p;
+	unsigned long p_off;
+	int i, c;
+	struct vm_area_struct *vma;
+	unsigned long mt;
+
+	p = (struct task_struct *)&init_task;
+	p_off = (unsigned long)&(p->tasks) - (unsigned long)p;
+
+	do {
+		if (!(p->mm)) {
+			p = (struct task_struct *)((unsigned long)(p->tasks.next) - p_off);
+			continue;
+		}
+		printf("PID: %d\n", (int)(p->pid));
+		mt = (unsigned long)&(p->mm->mm_mt);
+
+		c = maple_count((char *)mt);
+		for (i = 0; i < c; i++) {
+			vma = (struct vm_area_struct *)maple_elem((char *)mt, i);
+			printf("%lx\n", vma);
+		}
+		p = (struct task_struct *)((unsigned long)(p->tasks.next) - p_off);
+	} while(p != &init_task);
+
+	return 1;
+}
-- 
2.47.0




More information about the kexec mailing list