On 2022/06/29 4:19, Hari Bathini wrote: > Add '-e' option to 'mach' command to list top address of all emergency > stacks of all present CPUs. > > Signed-off-by: Hari Bathini <hbathini@xxxxxxxxxxxxx> > --- > help.c | 31 +++++++++++++++++++++++++++++++ > ppc64.c | 43 ++++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 73 insertions(+), 1 deletion(-) > > diff --git a/help.c b/help.c > index 99214c1..7f0389c 100644 > --- a/help.c > +++ b/help.c > @@ -2487,6 +2487,7 @@ char *help_mach[] = { > " -x override default output format with hexadecimal format.", > " -d override default output format with decimal format.", > " -o Display the OPAL console log (ppc64 only).", > +" -e List top address of all emergency stacks of each CPU (ppc64 only).", > "\nEXAMPLES", > " %s> mach", > " MACHINE TYPE: i686", > @@ -2524,6 +2525,36 @@ char *help_mach[] = { > " [ 65.219607955,5] FDT: Parsing fdt @0xff00000", > " [ 494.026291523,7] BT: seq 0x25 netfn 0x0a cmd 0x48: Message sent to host", > " [ 494.027636927,7] BT: seq 0x25 netfn 0x0a cmd 0x48: IPMI MSG done", > +" ", > +" List top address of emergency stacks of each CPU:\n", > +" %s> mach -e", > +" EMERGENCY STACK: ", > +" CPU 0: c00000001eb28000", > +" CPU 1: c00000001eb1c000", > +" CPU 2: c00000001eb10000", > +" CPU 3: c00000001eb04000", > +" CPU 4: c00000001eaf8000", > +" CPU 5: c00000001eaec000", > +" CPU 6: c00000001eae0000", > +" CPU 7: c00000001ead4000", > +" NMI EMERGENCY STACK: ", > +" CPU 0: c00000001eb24000", > +" CPU 1: c00000001eb18000", > +" CPU 2: c00000001eb0c000", > +" CPU 3: c00000001eb00000", > +" CPU 4: c00000001eaf4000", > +" CPU 5: c00000001eae8000", > +" CPU 6: c00000001eadc000", > +" CPU 7: c00000001ead0000", > +" MC EMERGENCY STACK: ", > +" CPU 0: c00000001eb20000", > +" CPU 1: c00000001eb14000", > +" CPU 2: c00000001eb08000", > +" CPU 3: c00000001eafc000", > +" CPU 4: c00000001eaf0000", > +" CPU 5: c00000001eae4000", > +" CPU 6: c00000001ead8000", > +" CPU 7: c00000001eacc000", > NULL > }; > > diff --git a/ppc64.c b/ppc64.c > index 333a775..c3a3d3a 100644 > --- a/ppc64.c > +++ b/ppc64.c > @@ -3153,6 +3153,44 @@ opalmsg(void) > fprintf(fp, "\n"); > } > > +static void ppc64_print_emergency_stack_info(void) > +{ > + struct machine_specific *ms = machdep->machspec; > + char buf[32]; > + int i; > + > + fprintf(fp, " EMERGENCY STACK: "); > + if (ms->emergency_sp) { > + fprintf(fp, "\n"); > + for (i = 0; i < kt->cpus; i++) { > + sprintf(buf, "CPU %d", i); > + fprintf(fp, "%19s: %lx\n", buf, ms->emergency_sp[i]); > + } > + } else > + fprintf(fp, "(unused)\n"); > + > + fprintf(fp, "NMI EMERGENCY STACK: "); > + if (ms->nmi_emergency_sp) { > + fprintf(fp, "\n"); > + for (i = 0; i < kt->cpus; i++) { > + sprintf(buf, "CPU %d", i); > + fprintf(fp, "%19s: %lx\n", buf, ms->nmi_emergency_sp[i]); > + } > + } else > + fprintf(fp, "(unused)\n"); > + > + fprintf(fp, " MC EMERGENCY STACK: "); > + if (ms->mc_emergency_sp) { > + fprintf(fp, "\n"); > + for (i = 0; i < kt->cpus; i++) { > + sprintf(buf, "CPU %d", i); > + fprintf(fp, "%19s: %lx\n", buf, ms->mc_emergency_sp[i]); > + } > + } else > + fprintf(fp, "(unused)\n"); > + fprintf(fp, "\n"); > +} > + > /* > * Machine dependent command. > */ > @@ -3161,7 +3199,7 @@ ppc64_cmd_mach(void) > { > int c; > > - while ((c = getopt(argcnt, args, "cmo")) != EOF) { > + while ((c = getopt(argcnt, args, "cmoe")) != EOF) { > switch(c) > { > case 'c': > @@ -3171,6 +3209,9 @@ ppc64_cmd_mach(void) > break; > case 'o': > return opalmsg(); > + case 'e': > + ppc64_print_emergency_stack_info(); > + break; Is it necessary to add the 'mach -e' option? Not returning here will lead to call ppc64_display_machine_stats() after this, then I think we can append the information of emergency stacks to the 'mach' command without any option.. And also on x86_64, 'mach' displays various exception stacks. crash> mach | grep STACKS IRQ STACKS: DOUBLEFAULT STACKS: NMI STACKS: DEBUG STACKS: MCE STACKS: VC STACKS: Thanks, Kazu > default: > argerrs++; > break; -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/crash-utility Contribution Guidelines: https://github.com/crash-utility/crash/wiki