Skip to content

Commit 9441d5f

Browse files
diandersDaniel Thompson
authored andcommitted
kdb: Gid rid of implicit setting of the current task / regs
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 2277b49 ("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/[email protected] Signed-off-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/20191109111624.4.Ibc3d982bbeb9e46872d43973ba808cd4c79537c7@changeid Signed-off-by: Daniel Thompson <[email protected]>
1 parent a8649fb commit 9441d5f

File tree

3 files changed

+2
-9
lines changed

3 files changed

+2
-9
lines changed

kernel/debug/kdb/kdb_bt.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ kdb_bt_cpu(unsigned long cpu)
119119
return;
120120
}
121121

122-
kdb_set_current_task(kdb_tsk);
123122
kdb_bt1(kdb_tsk, ~0UL, false);
124123
}
125124

@@ -166,10 +165,8 @@ kdb_bt(int argc, const char **argv)
166165
if (diag)
167166
return diag;
168167
p = find_task_by_pid_ns(pid, &init_pid_ns);
169-
if (p) {
170-
kdb_set_current_task(p);
168+
if (p)
171169
return kdb_bt1(p, ~0UL, false);
172-
}
173170
kdb_printf("No process with pid == %ld found\n", pid);
174171
return 0;
175172
} else if (strcmp(argv[0], "btt") == 0) {
@@ -178,11 +175,9 @@ kdb_bt(int argc, const char **argv)
178175
diag = kdbgetularg((char *)argv[1], &addr);
179176
if (diag)
180177
return diag;
181-
kdb_set_current_task((struct task_struct *)addr);
182178
return kdb_bt1((struct task_struct *)addr, ~0UL, false);
183179
} else if (strcmp(argv[0], "btc") == 0) {
184180
unsigned long cpu = ~0;
185-
struct task_struct *save_current_task = kdb_current_task;
186181
if (argc > 1)
187182
return KDB_ARGCOUNT;
188183
if (argc == 1) {
@@ -204,7 +199,6 @@ kdb_bt(int argc, const char **argv)
204199
kdb_bt_cpu(cpu);
205200
touch_nmi_watchdog();
206201
}
207-
kdb_set_current_task(save_current_task);
208202
}
209203
return 0;
210204
} else {

kernel/debug/kdb/kdb_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ static void kdb_dumpregs(struct pt_regs *regs)
11381138
console_loglevel = old_lvl;
11391139
}
11401140

1141-
void kdb_set_current_task(struct task_struct *p)
1141+
static void kdb_set_current_task(struct task_struct *p)
11421142
{
11431143
kdb_current_task = p;
11441144

kernel/debug/kdb/kdb_private.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ extern void *debug_kmalloc(size_t size, gfp_t flags);
240240
extern void debug_kfree(void *);
241241
extern void debug_kusage(void);
242242

243-
extern void kdb_set_current_task(struct task_struct *);
244243
extern struct task_struct *kdb_current_task;
245244
extern struct pt_regs *kdb_current_regs;
246245

0 commit comments

Comments
 (0)