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

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