Skip to content

Commit ece4cea

Browse files
Davidlohr BuesoDaniel Thompson
authored andcommitted
kdb: Use newer api for tasklist scanning
This kills using the do_each_thread/while_each_thread combo to iterate all threads and uses for_each_process_thread() instead, maintaining semantics. while_each_thread() is ultimately racy and deprecated; although in this particular case there is no concurrency so it doesn't matter. Still lets trivially get rid of two more users. Acked-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Link: https://lore.kernel.org/r/20200907203206.21293-1-dave@stgolabs.net Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
1 parent b18b099 commit ece4cea

4 files changed

Lines changed: 8 additions & 12 deletions

File tree

kernel/debug/gdbstub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ static void gdb_cmd_query(struct kgdb_state *ks)
725725
}
726726
}
727727

728-
do_each_thread(g, p) {
728+
for_each_process_thread(g, p) {
729729
if (i >= ks->thr_query && !finished) {
730730
int_to_threadref(thref, p->pid);
731731
ptr = pack_threadid(ptr, thref);
@@ -735,7 +735,7 @@ static void gdb_cmd_query(struct kgdb_state *ks)
735735
finished = 1;
736736
}
737737
i++;
738-
} while_each_thread(g, p);
738+
}
739739

740740
*(--ptr) = '\0';
741741
break;

kernel/debug/kdb/kdb_bt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,14 @@ kdb_bt(int argc, const char **argv)
149149
return 0;
150150
}
151151
/* Now the inactive tasks */
152-
kdb_do_each_thread(g, p) {
152+
for_each_process_thread(g, p) {
153153
if (KDB_FLAG(CMD_INTERRUPT))
154154
return 0;
155155
if (task_curr(p))
156156
continue;
157157
if (kdb_bt1(p, mask, btaprompt))
158158
return 0;
159-
} kdb_while_each_thread(g, p);
159+
}
160160
} else if (strcmp(argv[0], "btp") == 0) {
161161
struct task_struct *p;
162162
unsigned long pid;

kernel/debug/kdb/kdb_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,10 +2299,10 @@ void kdb_ps_suppressed(void)
22992299
if (kdb_task_state(p, mask_I))
23002300
++idle;
23012301
}
2302-
kdb_do_each_thread(g, p) {
2302+
for_each_process_thread(g, p) {
23032303
if (kdb_task_state(p, mask_M))
23042304
++daemon;
2305-
} kdb_while_each_thread(g, p);
2305+
}
23062306
if (idle || daemon) {
23072307
if (idle)
23082308
kdb_printf("%d idle process%s (state I)%s\n",
@@ -2370,12 +2370,12 @@ static int kdb_ps(int argc, const char **argv)
23702370
}
23712371
kdb_printf("\n");
23722372
/* Now the real tasks */
2373-
kdb_do_each_thread(g, p) {
2373+
for_each_process_thread(g, p) {
23742374
if (KDB_FLAG(CMD_INTERRUPT))
23752375
return 0;
23762376
if (kdb_task_state(p, mask))
23772377
kdb_ps1(p);
2378-
} kdb_while_each_thread(g, p);
2378+
}
23792379

23802380
return 0;
23812381
}

kernel/debug/kdb/kdb_private.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,6 @@ extern struct task_struct *kdb_curr_task(int);
230230

231231
#define kdb_task_has_cpu(p) (task_curr(p))
232232

233-
/* Simplify coexistence with NPTL */
234-
#define kdb_do_each_thread(g, p) do_each_thread(g, p)
235-
#define kdb_while_each_thread(g, p) while_each_thread(g, p)
236-
237233
#define GFP_KDB (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
238234

239235
extern void *debug_kmalloc(size_t size, gfp_t flags);

0 commit comments

Comments
 (0)