Skip to content

Commit 931ea24

Browse files
committed
kdb: fix per_cpu command to remove supress mask
Rusty pointed out that the per_cpu command uses up lots of space on the stack and the cpu supress mask is probably not needed. This patch removes the need for the supress mask as well as fixing up the following problems with the kdb per_cpu command: * The per_cpu command should allow an address as an argument * When you have more data than can be displayed on one screen allow the user to break out of the print loop. Reported-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
1 parent 4aad8f5 commit 931ea24

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

kernel/debug/kdb/kdb_main.c

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,20 +2603,17 @@ static int kdb_summary(int argc, const char **argv)
26032603
*/
26042604
static int kdb_per_cpu(int argc, const char **argv)
26052605
{
2606-
char buf[256], fmtstr[64];
2607-
kdb_symtab_t symtab;
2608-
cpumask_t suppress = CPU_MASK_NONE;
2609-
int cpu, diag;
2610-
unsigned long addr, val, bytesperword = 0, whichcpu = ~0UL;
2606+
char fmtstr[64];
2607+
int cpu, diag, nextarg = 1;
2608+
unsigned long addr, symaddr, val, bytesperword = 0, whichcpu = ~0UL;
26112609

26122610
if (argc < 1 || argc > 3)
26132611
return KDB_ARGCOUNT;
26142612

2615-
snprintf(buf, sizeof(buf), "per_cpu__%s", argv[1]);
2616-
if (!kdbgetsymval(buf, &symtab)) {
2617-
kdb_printf("%s is not a per_cpu variable\n", argv[1]);
2618-
return KDB_BADADDR;
2619-
}
2613+
diag = kdbgetaddrarg(argc, argv, &nextarg, &symaddr, NULL, NULL);
2614+
if (diag)
2615+
return diag;
2616+
26202617
if (argc >= 2) {
26212618
diag = kdbgetularg(argv[2], &bytesperword);
26222619
if (diag)
@@ -2649,46 +2646,25 @@ static int kdb_per_cpu(int argc, const char **argv)
26492646
#define KDB_PCU(cpu) 0
26502647
#endif
26512648
#endif
2652-
26532649
for_each_online_cpu(cpu) {
2650+
if (KDB_FLAG(CMD_INTERRUPT))
2651+
return 0;
2652+
26542653
if (whichcpu != ~0UL && whichcpu != cpu)
26552654
continue;
2656-
addr = symtab.sym_start + KDB_PCU(cpu);
2655+
addr = symaddr + KDB_PCU(cpu);
26572656
diag = kdb_getword(&val, addr, bytesperword);
26582657
if (diag) {
26592658
kdb_printf("%5d " kdb_bfd_vma_fmt0 " - unable to "
26602659
"read, diag=%d\n", cpu, addr, diag);
26612660
continue;
26622661
}
2663-
#ifdef CONFIG_SMP
2664-
if (!val) {
2665-
cpu_set(cpu, suppress);
2666-
continue;
2667-
}
2668-
#endif /* CONFIG_SMP */
26692662
kdb_printf("%5d ", cpu);
26702663
kdb_md_line(fmtstr, addr,
26712664
bytesperword == KDB_WORD_SIZE,
26722665
1, bytesperword, 1, 1, 0);
26732666
}
2674-
if (cpus_weight(suppress) == 0)
2675-
return 0;
2676-
kdb_printf("Zero suppressed cpu(s):");
2677-
for (cpu = first_cpu(suppress); cpu < num_possible_cpus();
2678-
cpu = next_cpu(cpu, suppress)) {
2679-
kdb_printf(" %d", cpu);
2680-
if (cpu == num_possible_cpus() - 1 ||
2681-
next_cpu(cpu, suppress) != cpu + 1)
2682-
continue;
2683-
while (cpu < num_possible_cpus() &&
2684-
next_cpu(cpu, suppress) == cpu + 1)
2685-
++cpu;
2686-
kdb_printf("-%d", cpu);
2687-
}
2688-
kdb_printf("\n");
2689-
26902667
#undef KDB_PCU
2691-
26922668
return 0;
26932669
}
26942670

0 commit comments

Comments
 (0)