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

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