Blame SOURCES/0008-bt-arm64-add-support-for-bt-n-idle.patch

aefe19
From 0f162febebc4d11a165dd40cee00f3b0ba691a52 Mon Sep 17 00:00:00 2001
aefe19
From: Qi Zheng <zhengqi.arch@bytedance.com>
aefe19
Date: Tue, 24 May 2022 20:25:54 +0800
aefe19
Subject: [PATCH 08/18] bt: arm64: add support for 'bt -n idle'
aefe19
aefe19
The '-n idle' option of bt command can help us filter the
aefe19
stack of the idle process when debugging the dumpfiles
aefe19
captured by kdump.
aefe19
aefe19
This patch supports this feature on ARM64.
aefe19
aefe19
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
aefe19
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
aefe19
---
aefe19
 arm64.c  | 19 ++++++++++++++++---
aefe19
 help.c   |  2 +-
aefe19
 kernel.c |  3 ++-
aefe19
 3 files changed, 19 insertions(+), 5 deletions(-)
aefe19
aefe19
diff --git a/arm64.c b/arm64.c
aefe19
index 65f6cdf69fa6..0f615cf52bef 100644
aefe19
--- a/arm64.c
aefe19
+++ b/arm64.c
aefe19
@@ -3681,6 +3681,12 @@ arm64_get_dumpfile_stackframe(struct bt_info *bt, struct arm64_stackframe *frame
aefe19
 {
aefe19
 	struct machine_specific *ms = machdep->machspec;
aefe19
 	struct arm64_pt_regs *ptregs;
aefe19
+	bool skip = false;
aefe19
+
aefe19
+	if (bt->flags & BT_SKIP_IDLE) {
aefe19
+		skip = true;
aefe19
+		bt->flags &= ~BT_SKIP_IDLE;
aefe19
+	}
aefe19
 
aefe19
 	if (!ms->panic_task_regs ||
aefe19
 	    (!ms->panic_task_regs[bt->tc->processor].sp && 
aefe19
@@ -3713,8 +3719,11 @@ try_kernel:
aefe19
 	}
aefe19
 
aefe19
 	if (arm64_in_kdump_text(bt, frame) || 
aefe19
-	    arm64_in_kdump_text_on_irq_stack(bt))
aefe19
+	    arm64_in_kdump_text_on_irq_stack(bt)) {
aefe19
 		bt->flags |= BT_KDUMP_ADJUST;
aefe19
+		if (skip && is_idle_thread(bt->task))
aefe19
+			bt->flags |= BT_SKIP_IDLE;
aefe19
+	}
aefe19
 
aefe19
 	return TRUE;
aefe19
 }
aefe19
@@ -3738,10 +3747,14 @@ arm64_get_stack_frame(struct bt_info *bt, ulong *pcp, ulong *spp)
aefe19
 	int ret;
aefe19
 	struct arm64_stackframe stackframe = { 0 };
aefe19
 
aefe19
-	if (DUMPFILE() && is_task_active(bt->task))
aefe19
+	if (DUMPFILE() && is_task_active(bt->task)) {
aefe19
 		ret = arm64_get_dumpfile_stackframe(bt, &stackframe);
aefe19
-	else
aefe19
+	} else {
aefe19
+		if (bt->flags & BT_SKIP_IDLE)
aefe19
+			bt->flags &= ~BT_SKIP_IDLE;
aefe19
+
aefe19
 		ret = arm64_get_stackframe(bt, &stackframe);
aefe19
+	}
aefe19
 
aefe19
 	if (!ret)
aefe19
 		error(WARNING, 
aefe19
diff --git a/help.c b/help.c
aefe19
index e1bbc5abe029..99214c1590fa 100644
aefe19
--- a/help.c
aefe19
+++ b/help.c
aefe19
@@ -1915,7 +1915,7 @@ char *help_bt[] = {
aefe19
 "       -a  displays the stack traces of the active task on each CPU.",
aefe19
 "           (only applicable to crash dumps)",
aefe19
 "       -A  same as -a, but also displays vector registers (S390X only).",
aefe19
-"  -n idle  filter the stack of idle tasks (x86_64).",
aefe19
+"  -n idle  filter the stack of idle tasks (x86_64, arm64).",
aefe19
 "           (only applicable to crash dumps)",
aefe19
 "       -p  display the stack trace of the panic task only.",
aefe19
 "           (only applicable to crash dumps)",
aefe19
diff --git a/kernel.c b/kernel.c
aefe19
index 411e9da1e54f..a521ef30cdb0 100644
aefe19
--- a/kernel.c
aefe19
+++ b/kernel.c
aefe19
@@ -2673,7 +2673,8 @@ cmd_bt(void)
aefe19
 			break;
aefe19
 
aefe19
 		case 'n':
aefe19
-			if (machine_type("X86_64") && STREQ(optarg, "idle"))
aefe19
+			if ((machine_type("X86_64") || machine_type("ARM64")) &&
aefe19
+			    STREQ(optarg, "idle"))
aefe19
 				bt->flags |= BT_SKIP_IDLE;
aefe19
 			else
aefe19
 				option_not_supported(c);
aefe19
-- 
aefe19
2.30.2
aefe19