Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tao Liu <ltao@redhat.com>
To: yamazaki-msmt@nec.com, k-hagio-ab@nec.com, kexec@lists.infradead.org
Cc: aravinda@linux.vnet.ibm.com, devel@lists.crash-utility.osci.io,
	Tao Liu <ltao@redhat.com>
Subject: [PATCH RFC][makedumpfile 10/10] Introducing 2 eppic scripts to test the dwarf/btf eppic extension
Date: Tue, 10 Jun 2025 21:57:43 +1200	[thread overview]
Message-ID: <20250610095743.18073-11-ltao@redhat.com> (raw)
In-Reply-To: <20250610095743.18073-1-ltao@redhat.com>

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@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



  parent reply	other threads:[~2025-06-10 10:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-10  9:57 [PATCH RFC][makedumpfile 00/10] btf/kallsyms based eppic extension for mm page filtering Tao Liu
2025-06-10  9:57 ` [PATCH RFC][makedumpfile 01/10] dwarf_info: Support kernel address randomization Tao Liu
2025-09-08 11:11   ` YAMAZAKI MASAMITSU(山崎 真光)
2025-09-09  5:24     ` Tao Liu
2025-09-29  6:30   ` HAGIO KAZUHITO(萩尾 一仁)
2025-09-30  0:34     ` Tao Liu
2025-09-30  1:28       ` HAGIO KAZUHITO(萩尾 一仁)
2025-09-30  1:44         ` Tao Liu
2025-06-10  9:57 ` [PATCH RFC][makedumpfile 02/10] dwarf_info: Fix a infinite recursion bug for search_domain Tao Liu
2025-10-03  7:22   ` YAMAZAKI MASAMITSU(山崎 真光)
2025-10-05 23:25     ` Tao Liu
2025-10-17  4:21   ` HAGIO KAZUHITO(萩尾 一仁)
2025-10-20  3:52     ` Tao Liu
2025-06-10  9:57 ` [PATCH RFC][makedumpfile 03/10] Add page filtering function Tao Liu
2025-06-10  9:57 ` [PATCH RFC][makedumpfile 04/10] Add btf/kallsyms support for symbol type/address resolving Tao Liu
2025-06-10  9:57 ` [PATCH RFC][makedumpfile 05/10] Export necessary btf/kallsyms functions to eppic extension Tao Liu
2025-06-10  9:57 ` [PATCH RFC][makedumpfile 06/10] Port the maple tree data structures and functions Tao Liu
2025-06-10  9:57 ` [PATCH RFC][makedumpfile 07/10] Supporting main() as the entry of eppic script Tao Liu
2025-06-10  9:57 ` [PATCH RFC][makedumpfile 08/10] Enable page filtering for dwarf eppic Tao Liu
2025-06-10  9:57 ` [PATCH RFC][makedumpfile 09/10] Enable page filtering for btf/kallsyms eppic Tao Liu
2025-06-10  9:57 ` Tao Liu [this message]
2025-08-05  3:16 ` [PATCH RFC][makedumpfile 00/10] btf/kallsyms based eppic extension for mm page filtering Tao Liu
2025-08-07 11:42   ` YAMAZAKI MASAMITSU(山崎 真光)
2025-08-11  0:04     ` Tao Liu
2025-09-05 12:41       ` YAMAZAKI MASAMITSU(山崎 真光)
2025-09-09  1:56         ` Tao Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250610095743.18073-11-ltao@redhat.com \
    --to=ltao@redhat.com \
    --cc=aravinda@linux.vnet.ibm.com \
    --cc=devel@lists.crash-utility.osci.io \
    --cc=k-hagio-ab@nec.com \
    --cc=kexec@lists.infradead.org \
    --cc=yamazaki-msmt@nec.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox