mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Douglas Anderson <dianders@chromium.org>
To: Paul Burton <paul.burton@mips.com>,
	Jason Wessel <jason.wessel@windriver.com>,
	Daniel Thompson <daniel.thompson@linaro.org>
Cc: qiaochong@loongson.cn, kgdb-bugreport@lists.sourceforge.net,
	ralf@linux-mips.org, Douglas Anderson <dianders@chromium.org>,
	Christophe Leroy <christophe.leroy@c-s.fr>,
	Will Deacon <will@kernel.org>,
	Chuhong Yuan <hslester96@gmail.com>,
	linux-kernel@vger.kernel.org,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	Prarit Bhargava <prarit@redhat.com>,
	Nicholas Mc Guire <hofrat@osadl.org>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH 4/5] kdb: Gid rid of implicit setting of the current task / regs
Date: Sat,  9 Nov 2019 11:16:43 -0800	[thread overview]
Message-ID: <20191109111624.4.Ibc3d982bbeb9e46872d43973ba808cd4c79537c7@changeid> (raw)
In-Reply-To: <20191109191644.191766-1-dianders@chromium.org>

Some (but not all?) of the kdb backtrace paths would cause the
kdb_current_task and kdb_current_regs to remain changed.  As discussed
in a review of a previous patch [1], this doesn't seem intuitive, so
let's fix that.

...but, it turns out that there's actually no longer any reason to set
the current task / current regs while backtracing anymore anyway.  As
of commit 2277b492582d ("kdb: Fix stack crawling on 'running' CPUs
that aren't the master") if we're backtracing on a task running on a
CPU we ask that CPU to do the backtrace itself.  Linux can do that
without anything fancy.  If we're doing backtrace on a sleeping task
we can also do that fine without updating globals.  So this patch
mostly just turns into deleting a bunch of code.

[1] https://lore.kernel.org/r/20191010150735.dhrj3pbjgmjrdpwr@holly.lan

Signed-off-by: Douglas Anderson <dianders@chromium.org>
---

 kernel/debug/kdb/kdb_bt.c      | 8 +-------
 kernel/debug/kdb/kdb_main.c    | 2 +-
 kernel/debug/kdb/kdb_private.h | 1 -
 3 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/kernel/debug/kdb/kdb_bt.c b/kernel/debug/kdb/kdb_bt.c
index 4af48ac53625..3de0cc780c16 100644
--- a/kernel/debug/kdb/kdb_bt.c
+++ b/kernel/debug/kdb/kdb_bt.c
@@ -119,7 +119,6 @@ kdb_bt_cpu(unsigned long cpu)
 		return;
 	}
 
-	kdb_set_current_task(kdb_tsk);
 	kdb_bt1(kdb_tsk, ~0UL, false);
 }
 
@@ -166,10 +165,8 @@ kdb_bt(int argc, const char **argv)
 		if (diag)
 			return diag;
 		p = find_task_by_pid_ns(pid, &init_pid_ns);
-		if (p) {
-			kdb_set_current_task(p);
+		if (p)
 			return kdb_bt1(p, ~0UL, false);
-		}
 		kdb_printf("No process with pid == %ld found\n", pid);
 		return 0;
 	} else if (strcmp(argv[0], "btt") == 0) {
@@ -178,11 +175,9 @@ kdb_bt(int argc, const char **argv)
 		diag = kdbgetularg((char *)argv[1], &addr);
 		if (diag)
 			return diag;
-		kdb_set_current_task((struct task_struct *)addr);
 		return kdb_bt1((struct task_struct *)addr, ~0UL, false);
 	} else if (strcmp(argv[0], "btc") == 0) {
 		unsigned long cpu = ~0;
-		struct task_struct *save_current_task = kdb_current_task;
 		if (argc > 1)
 			return KDB_ARGCOUNT;
 		if (argc == 1) {
@@ -204,7 +199,6 @@ kdb_bt(int argc, const char **argv)
 				kdb_bt_cpu(cpu);
 				touch_nmi_watchdog();
 			}
-			kdb_set_current_task(save_current_task);
 		}
 		return 0;
 	} else {
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 4d44b3746836..ba12e9f4661e 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -1138,7 +1138,7 @@ static void kdb_dumpregs(struct pt_regs *regs)
 	console_loglevel = old_lvl;
 }
 
-void kdb_set_current_task(struct task_struct *p)
+static void kdb_set_current_task(struct task_struct *p)
 {
 	kdb_current_task = p;
 
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h
index e829b22f3946..2e296e4a234c 100644
--- a/kernel/debug/kdb/kdb_private.h
+++ b/kernel/debug/kdb/kdb_private.h
@@ -240,7 +240,6 @@ extern void *debug_kmalloc(size_t size, gfp_t flags);
 extern void debug_kfree(void *);
 extern void debug_kusage(void);
 
-extern void kdb_set_current_task(struct task_struct *);
 extern struct task_struct *kdb_current_task;
 extern struct pt_regs *kdb_current_regs;
 
-- 
2.24.0.432.g9d3f5f5b63-goog


  parent reply	other threads:[~2019-11-09 19:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-09 19:16 [PATCH 0/5] kdb: Don't implicitly change tasks; plus misc fixups Douglas Anderson
2019-11-09 19:16 ` [PATCH 1/5] MIPS: kdb: Remove old workaround for backtracing on other CPUs Douglas Anderson
2019-11-14 10:51   ` Daniel Thompson
2019-11-14 16:10     ` Doug Anderson
2019-11-15  0:30     ` Paul Burton
2019-11-09 19:16 ` [PATCH 2/5] kdb: kdb_current_regs should be private Douglas Anderson
2019-11-09 19:16 ` [PATCH 3/5] kdb: kdb_current_task shouldn't be exported Douglas Anderson
2019-11-09 19:16 ` Douglas Anderson [this message]
2019-11-09 19:16 ` [PATCH 5/5] kdb: Get rid of confusing diag msg from "rd" if current task has no regs Douglas Anderson
2020-01-28 16:59 ` [PATCH 0/5] kdb: Don't implicitly change tasks; plus misc fixups Doug Anderson
2020-01-29  1:42   ` Andrew Morton
2020-01-29 15:23     ` Daniel Thompson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191109111624.4.Ibc3d982bbeb9e46872d43973ba808cd4c79537c7@changeid \
    --to=dianders@chromium.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=dan.carpenter@oracle.com \
    --cc=daniel.thompson@linaro.org \
    --cc=gustavo@embeddedor.com \
    --cc=hofrat@osadl.org \
    --cc=hslester96@gmail.com \
    --cc=jason.wessel@windriver.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.burton@mips.com \
    --cc=prarit@redhat.com \
    --cc=qiaochong@loongson.cn \
    --cc=ralf@linux-mips.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®