From dea0ed669066779744383f4e3a123f23d1a95d6d Mon Sep 17 00:00:00 2001 From: "Bjoern A. Zeeb" Date: Mon, 7 Jul 2008 21:32:02 +0000 Subject: [PATCH] Add a `show cpusets' DDB command to print numbered root and assigned CPU affinity sets. Reviewed by: brooks --- share/man/man4/ddb.4 | 9 ++++++++- sys/kern/kern_cpuset.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/share/man/man4/ddb.4 b/share/man/man4/ddb.4 index e0a8a257c361..f822071c9840 100644 --- a/share/man/man4/ddb.4 +++ b/share/man/man4/ddb.4 @@ -60,7 +60,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 8, 2008 +.Dd July 7, 2008 .Dt DDB 4 .Os .Sh NAME @@ -584,6 +584,13 @@ header file. Show brief information about the TTY subsystem. .\" .Pp +.It Ic show Cm cpusets +Print numbered root and assigned CPU affinity sets. +See +.Xr cpuset 2 +for more details. +.\" +.Pp .It Ic show Cm cyrixreg Show registers specific to the Cyrix processor. .\" diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index ee27a0b92c04..2a4c248744cc 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -31,6 +31,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_ddb.h" + #include #include #include @@ -54,6 +56,10 @@ __FBSDID("$FreeBSD$"); #include +#ifdef DDB +#include +#endif /* DDB */ + /* * cpusets provide a mechanism for creating and manipulating sets of * processors for the purpose of constraining the scheduling of threads to @@ -975,3 +981,30 @@ out: free(mask, M_TEMP); return (error); } + +#ifdef DDB +DB_SHOW_COMMAND(cpusets, db_show_cpusets) +{ + struct cpuset *set; + int cpu, once; + + LIST_FOREACH(set, &cpuset_ids, cs_link) { + db_printf("set=%p id=%-6u ref=%-6d flags=0x%04x parent id=%d\n", + set, set->cs_id, set->cs_ref, set->cs_flags, + (set->cs_parent != NULL) ? set->cs_parent->cs_id : 0); + db_printf(" mask="); + for (once = 0, cpu = 0; cpu < CPU_SETSIZE; cpu++) { + if (CPU_ISSET(cpu, &set->cs_mask)) { + if (once == 0) { + db_printf("%d", cpu); + once = 1; + } else + db_printf(",%d", cpu); + } + } + db_printf("\n"); + if (db_pager_quit) + break; + } +} +#endif /* DDB */