Commit 931ea24819f2bd40cca2dc214558bfcc3c91549e
1 parent
4aad8f51d0
Exists in
master
and in
39 other branches
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>
Showing 1 changed file with 11 additions and 35 deletions Side-by-side Diff
kernel/debug/kdb/kdb_main.c
... | ... | @@ -2603,20 +2603,17 @@ |
2603 | 2603 | */ |
2604 | 2604 | static int kdb_per_cpu(int argc, const char **argv) |
2605 | 2605 | { |
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; | |
2611 | 2609 | |
2612 | 2610 | if (argc < 1 || argc > 3) |
2613 | 2611 | return KDB_ARGCOUNT; |
2614 | 2612 | |
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 | + | |
2620 | 2617 | if (argc >= 2) { |
2621 | 2618 | diag = kdbgetularg(argv[2], &bytesperword); |
2622 | 2619 | if (diag) |
2623 | 2620 | |
2624 | 2621 | |
2625 | 2622 | |
2626 | 2623 | |
2627 | 2624 | |
... | ... | @@ -2649,46 +2646,25 @@ |
2649 | 2646 | #define KDB_PCU(cpu) 0 |
2650 | 2647 | #endif |
2651 | 2648 | #endif |
2652 | - | |
2653 | 2649 | for_each_online_cpu(cpu) { |
2650 | + if (KDB_FLAG(CMD_INTERRUPT)) | |
2651 | + return 0; | |
2652 | + | |
2654 | 2653 | if (whichcpu != ~0UL && whichcpu != cpu) |
2655 | 2654 | continue; |
2656 | - addr = symtab.sym_start + KDB_PCU(cpu); | |
2655 | + addr = symaddr + KDB_PCU(cpu); | |
2657 | 2656 | diag = kdb_getword(&val, addr, bytesperword); |
2658 | 2657 | if (diag) { |
2659 | 2658 | kdb_printf("%5d " kdb_bfd_vma_fmt0 " - unable to " |
2660 | 2659 | "read, diag=%d\n", cpu, addr, diag); |
2661 | 2660 | continue; |
2662 | 2661 | } |
2663 | -#ifdef CONFIG_SMP | |
2664 | - if (!val) { | |
2665 | - cpu_set(cpu, suppress); | |
2666 | - continue; | |
2667 | - } | |
2668 | -#endif /* CONFIG_SMP */ | |
2669 | 2662 | kdb_printf("%5d ", cpu); |
2670 | 2663 | kdb_md_line(fmtstr, addr, |
2671 | 2664 | bytesperword == KDB_WORD_SIZE, |
2672 | 2665 | 1, bytesperword, 1, 1, 0); |
2673 | 2666 | } |
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 | - | |
2690 | 2667 | #undef KDB_PCU |
2691 | - | |
2692 | 2668 | return 0; |
2693 | 2669 | } |
2694 | 2670 |