Blame SOURCES/0025-Let-kmem-print-task-context-with-physical-address.patch

3ce5e9
From 74759e0e9736e86c7d2439bfe74ca5eb51b0a52b Mon Sep 17 00:00:00 2001
3ce5e9
From: Tao Liu <ltao@redhat.com>
3ce5e9
Date: Mon, 19 Sep 2022 17:49:23 +0800
3ce5e9
Subject: [PATCH 25/28] Let "kmem" print task context with physical address
3ce5e9
3ce5e9
Patch [1] enables "kmem" to print task context if the given virtual
3ce5e9
address is a vmalloced stack.
3ce5e9
3ce5e9
This patch lets "kmem" print task context also when the given address
3ce5e9
is a physical address.
3ce5e9
3ce5e9
Before:
3ce5e9
    crash> kmem 1883700e28
3ce5e9
       VMAP_AREA         VM_STRUCT                 ADDRESS RANGE                SIZE
3ce5e9
    ffff94eb9102c640  ffff94eb9102b140  ffffb7efce9b8000 - ffffb7efce9bd000    20480
3ce5e9
3ce5e9
	  PAGE         PHYSICAL      MAPPING       INDEX CNT FLAGS
3ce5e9
    ffffdd28220dc000 1883700000                0        0  1 50000000000000
3ce5e9
3ce5e9
After:
3ce5e9
    crash> kmem 1883700e28
3ce5e9
	PID: 847
3ce5e9
    COMMAND: "khungtaskd"
3ce5e9
       TASK: ffff94f8038f4000  [THREAD_INFO: ffff94f8038f4000]
3ce5e9
	CPU: 72
3ce5e9
      STATE: TASK_RUNNING (PANIC)
3ce5e9
3ce5e9
       VMAP_AREA         VM_STRUCT                 ADDRESS RANGE                SIZE
3ce5e9
    ffff94eb9102c640  ffff94eb9102b140  ffffb7efce9b8000 - ffffb7efce9bd000    20480
3ce5e9
3ce5e9
	  PAGE         PHYSICAL      MAPPING       INDEX CNT FLAGS
3ce5e9
    ffffdd28220dc000 1883700000                0        0  1 50000000000000
3ce5e9
3ce5e9
[1]: https://listman.redhat.com/archives/crash-utility/2022-September/010115.html
3ce5e9
3ce5e9
[ kh: squashed the 4/4 patch into 3/4 ]
3ce5e9
3ce5e9
Signed-off-by: Tao Liu <ltao@redhat.com>
3ce5e9
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
3ce5e9
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
3ce5e9
---
3ce5e9
 memory.c | 8 ++++++--
3ce5e9
 1 file changed, 6 insertions(+), 2 deletions(-)
3ce5e9
3ce5e9
diff --git a/memory.c b/memory.c
3ce5e9
index a60c3f9493f6..ff6b571361eb 100644
3ce5e9
--- a/memory.c
3ce5e9
+++ b/memory.c
3ce5e9
@@ -13506,6 +13506,10 @@ kmem_search(struct meminfo *mi)
3ce5e9
 		mi->flags &= ~GET_PHYS_TO_VMALLOC;
3ce5e9
 
3ce5e9
 		if (mi->retval) {
3ce5e9
+			if ((task = stkptr_to_task(mi->retval)) && (tc = task_to_context(task))) {
3ce5e9
+				show_context(tc);
3ce5e9
+				fprintf(fp, "\n");
3ce5e9
+			}
3ce5e9
 			if ((sp = value_search(mi->retval, &offset))) {
3ce5e9
                         	show_symbol(sp, offset, 
3ce5e9
 					SHOW_LINENUM | SHOW_RADIX());
3ce5e9
@@ -13562,11 +13566,11 @@ kmem_search(struct meminfo *mi)
3ce5e9
 	/*
3ce5e9
 	 *  Check whether it's a current task or stack address.
3ce5e9
 	 */
3ce5e9
-	if ((mi->memtype == KVADDR) && (task = vaddr_in_task_struct(vaddr)) &&
3ce5e9
+	if ((mi->memtype & (KVADDR|PHYSADDR)) && (task = vaddr_in_task_struct(vaddr)) &&
3ce5e9
 	    (tc = task_to_context(task))) {
3ce5e9
 		show_context(tc);
3ce5e9
 		fprintf(fp, "\n");
3ce5e9
-	} else if ((mi->memtype == KVADDR) && (task = stkptr_to_task(vaddr)) &&
3ce5e9
+	} else if ((mi->memtype & (KVADDR|PHYSADDR)) && (task = stkptr_to_task(vaddr)) &&
3ce5e9
 	    (tc = task_to_context(task))) {
3ce5e9
 		show_context(tc);
3ce5e9
 		fprintf(fp, "\n");
3ce5e9
-- 
3ce5e9
2.37.1
3ce5e9