summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pmccontrol/pmccontrol.c
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2011-06-28 06:26:03 +0000
committergrehan <grehan@FreeBSD.org>2011-06-28 06:26:03 +0000
commit2c6741be0f59191f2283eb268e4f7690399d578a (patch)
treeb139c8c6dcca4fa284815daade405b75886ee360 /usr.sbin/pmccontrol/pmccontrol.c
parent3c35264f695e0a1f8a04dbcca1c93bb5159b2274 (diff)
parent19ae02bba572390c7299166228d31e54003e094a (diff)
downloadFreeBSD-src-2c6741be0f59191f2283eb268e4f7690399d578a.zip
FreeBSD-src-2c6741be0f59191f2283eb268e4f7690399d578a.tar.gz
IFC @ r222830
Diffstat (limited to 'usr.sbin/pmccontrol/pmccontrol.c')
-rw-r--r--usr.sbin/pmccontrol/pmccontrol.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/usr.sbin/pmccontrol/pmccontrol.c b/usr.sbin/pmccontrol/pmccontrol.c
index cce1e0e..80d4bd7 100644
--- a/usr.sbin/pmccontrol/pmccontrol.c
+++ b/usr.sbin/pmccontrol/pmccontrol.c
@@ -28,8 +28,9 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/queue.h>
+#include <sys/cpuset.h>
#include <sys/sysctl.h>
#include <assert.h>
@@ -133,26 +134,32 @@ pmcc_init_debug(void)
static int
pmcc_do_enable_disable(struct pmcc_op_list *op_list)
{
+ long cpusetsize;
int c, error, i, j, ncpu, npmc, t;
- cpumask_t haltedcpus, cpumask;
+ cpuset_t haltedcpus, cpumask;
struct pmcc_op *np;
unsigned char *map;
unsigned char op;
int cpu, pmc;
- size_t dummy;
+ size_t setsize;
if ((ncpu = pmc_ncpu()) < 0)
err(EX_OSERR, "Unable to determine the number of cpus");
/* Determine the set of active CPUs. */
- cpumask = (1 << ncpu) - 1;
- dummy = sizeof(int);
- haltedcpus = (cpumask_t) 0;
+ cpusetsize = sysconf(_SC_CPUSET_SIZE);
+ if (cpusetsize == -1 || (u_long)cpusetsize > sizeof(cpuset_t)) {
+ err(EX_OSERR, "ERROR: Cannot determine which CPUs are "
+ "halted");
+ }
+ CPU_ZERO(&haltedcpus);
+ setsize = (size_t)cpusetsize;
if (ncpu > 1 && sysctlbyname("machdep.hlt_cpus", &haltedcpus,
- &dummy, NULL, 0) < 0)
+ &setsize, NULL, 0) < 0)
err(EX_OSERR, "ERROR: Cannot determine which CPUs are "
"halted");
- cpumask &= ~haltedcpus;
+ CPU_FILL(&cpumask);
+ CPU_NAND(&cpumask, &haltedcpus);
/* Determine the maximum number of PMCs in any CPU. */
npmc = 0;
@@ -200,7 +207,7 @@ pmcc_do_enable_disable(struct pmcc_op_list *op_list)
if (cpu == PMCC_CPU_ALL)
for (i = 0; i < ncpu; i++) {
- if ((1 << i) & cpumask)
+ if (CPU_ISSET(i, &cpumask))
SET_PMCS(i, pmc, op);
}
else
OpenPOWER on IntegriCloud