From 9b7915859dc8a67596b421a12b790a6221e04bf2 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 26 Sep 2005 16:55:11 +0000 Subject: [PATCH] Add "show allpcpu" to DDB, which prints the current CPU id followed by the per-cpu data for all CPUs. This is easier to ask users to do than "figure out how many CPUs you have, now run show pcpu, then run it once for each CPU you have". MFC after: 3 days --- sys/kern/subr_pcpu.c | 52 ++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/sys/kern/subr_pcpu.c b/sys/kern/subr_pcpu.c index bb58ec6d1951..bacf5ba22959 100644 --- a/sys/kern/subr_pcpu.c +++ b/sys/kern/subr_pcpu.c @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include static struct pcpu *cpuid_to_pcpu[MAXCPU]; @@ -97,21 +98,12 @@ pcpu_find(u_int cpuid) } #ifdef DDB -DB_SHOW_COMMAND(pcpu, db_show_pcpu) -{ - struct pcpu *pc; - struct thread *td; - int id; - if (have_addr) - id = ((addr >> 4) % 16) * 10 + (addr % 16); - else - id = PCPU_GET(cpuid); - pc = pcpu_find(id); - if (pc == NULL) { - db_printf("CPU %d not found\n", id); - return; - } +static void +show_pcpu(struct pcpu *pc) +{ + struct thread *td; + db_printf("cpuid = %d\n", pc->pc_cpuid); db_printf("curthread = "); td = pc->pc_curthread; @@ -142,4 +134,36 @@ DB_SHOW_COMMAND(pcpu, db_show_pcpu) witness_list_locks(&pc->pc_spinlocks); #endif } + +DB_SHOW_COMMAND(pcpu, db_show_pcpu) +{ + struct pcpu *pc; + int id; + + if (have_addr) + id = ((addr >> 4) % 16) * 10 + (addr % 16); + else + id = PCPU_GET(cpuid); + pc = pcpu_find(id); + if (pc == NULL) { + db_printf("CPU %d not found\n", id); + return; + } + show_pcpu(pc); +} + +DB_SHOW_COMMAND(allpcpu, db_show_cpu_all) +{ + struct pcpu *pc; + int id; + + db_printf("Current CPU: %d\n\n", PCPU_GET(cpuid)); + for (id = 0; id < mp_maxid; id++) { + pc = pcpu_find(id); + if (pc != NULL) { + show_pcpu(pc); + db_printf("\n"); + } + } +} #endif