Date: Mon, 5 Sep 2022 15:09:22 +0800
From: Tao Liu <ltao@redhat.com>
To: crash-utility@redhat.com
Subject: [Crash-utility] [PATCH v3 3/3] Let kmem print task context
when physical address is vmalloced stack
Message-ID: <20220905070922.14426-4-ltao@redhat.com>
Content-Type: text/plain; charset="US-ASCII"; x-default=true
Patch [1] enables kmem to print task context if the given virtual
address is a vmalloced stack.
This patch handles the same issue except the given address is
physical address.
Before:
crash> kmem 1883700e28
VMAP_AREA VM_STRUCT ADDRESS RANGE SIZE
ffff94eb9102c640 ffff94eb9102b140 ffffb7efce9b8000 - ffffb7efce9bd000 20480
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
ffffdd28220dc000 1883700000 0 0 1 50000000000000
After:
crash> kmem 1883700e28
PID: 847
COMMAND: "khungtaskd"
TASK: ffff94f8038f4000 [THREAD_INFO: ffff94f8038f4000]
CPU: 72
STATE: TASK_RUNNING (PANIC)
VMAP_AREA VM_STRUCT ADDRESS RANGE SIZE
ffff94eb9102c640 ffff94eb9102b140 ffffb7efce9b8000 - ffffb7efce9bd000 20480
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
ffffdd28220dc000 1883700000 0 0 1 50000000000000
[1]: https://listman.redhat.com/archives/crash-utility/2022-August/010074.html
I did the test and got different results with yours as below. Did I miss anything else?
crash> kmem ffff94e088110000CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME
ffff94e080c22a00 12040 3126 3129 3129 16k task_struct
SLAB MEMORY NODE TOTAL ALLOCATED FREE
ffffdd27c4204400 ffff94e088110000 0 1 1 0
FREE / [ALLOCATED]
[ffff94e088110000]
PID: 0
COMMAND: "swapper/2"
TASK: ffff94e088110000 (1 of 96) [THREAD_INFO: ffff94e088110000]
CPU: 2
STATE: TASK_RUNNING (ACTIVE)
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
ffffdd27c4204400 108110000 ffff94e080c22a00 0 1 10000000008100 slab,head
crash> kmem 108110000CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME
ffff94e080c22a00 12040 3126 3129 3129 16k task_struct
SLAB MEMORY NODE TOTAL ALLOCATED FREE
ffffdd27c4204400 ffff94e088110000 0 1 1 0
FREE / [ALLOCATED]
[ffff94e088110000]
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
ffffdd27c4204400 108110000 ffff94e080c22a00 0 1 10000000008100 slab,head
crash>
Thanks
Lianbo
Signed-off-by: Tao Liu <ltao@redhat.com>
---
memory.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/memory.c b/memory.c
index 1b6f9ba..eac8262 100644
--- a/memory.c
+++ b/memory.c
@@ -13506,6 +13506,10 @@ kmem_search(struct meminfo *mi)
mi->flags &= ~GET_PHYS_TO_VMALLOC;
if (mi->retval) {
+ if ((task = stkptr_to_task(mi->retval)) && (tc = task_to_context(task))) {
+ show_context(tc);
+ fprintf(fp, "\n");
+ }
if ((sp = value_search(mi->retval, &offset))) {
show_symbol(sp, offset,
SHOW_LINENUM | SHOW_RADIX());
--
2.33.1