summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pmccontrol/pmccontrol.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pmccontrol/pmccontrol.c')
-rw-r--r--usr.sbin/pmccontrol/pmccontrol.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/usr.sbin/pmccontrol/pmccontrol.c b/usr.sbin/pmccontrol/pmccontrol.c
index 80d4bd7..2a680ae 100644
--- a/usr.sbin/pmccontrol/pmccontrol.c
+++ b/usr.sbin/pmccontrol/pmccontrol.c
@@ -134,33 +134,15 @@ 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;
- cpuset_t haltedcpus, cpumask;
struct pmcc_op *np;
unsigned char *map;
unsigned char op;
int cpu, pmc;
- size_t setsize;
if ((ncpu = pmc_ncpu()) < 0)
err(EX_OSERR, "Unable to determine the number of cpus");
- /* Determine the set of active CPUs. */
- 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,
- &setsize, NULL, 0) < 0)
- err(EX_OSERR, "ERROR: Cannot determine which CPUs are "
- "halted");
- CPU_FILL(&cpumask);
- CPU_NAND(&cpumask, &haltedcpus);
-
/* Determine the maximum number of PMCs in any CPU. */
npmc = 0;
for (c = 0; c < ncpu; c++) {
@@ -207,8 +189,7 @@ pmcc_do_enable_disable(struct pmcc_op_list *op_list)
if (cpu == PMCC_CPU_ALL)
for (i = 0; i < ncpu; i++) {
- if (CPU_ISSET(i, &cpumask))
- SET_PMCS(i, pmc, op);
+ SET_PMCS(i, pmc, op);
}
else
SET_PMCS(cpu, pmc, op);
@@ -240,9 +221,10 @@ pmcc_do_enable_disable(struct pmcc_op_list *op_list)
static int
pmcc_do_list_state(void)
{
- size_t dummy;
+ cpuset_t logical_cpus_mask;
+ long cpusetsize;
+ size_t setsize;
int c, cpu, n, npmc, ncpu;
- unsigned int logical_cpus_mask;
struct pmc_info *pd;
struct pmc_pmcinfo *pi;
const struct pmc_cpuinfo *pc;
@@ -254,17 +236,22 @@ pmcc_do_list_state(void)
pmc_name_of_cputype(pc->pm_cputype),
pc->pm_npmc);
- dummy = sizeof(logical_cpus_mask);
+ /* Determine the set of logical CPUs. */
+ cpusetsize = sysconf(_SC_CPUSET_SIZE);
+ if (cpusetsize == -1 || (u_long)cpusetsize > sizeof(cpuset_t))
+ err(EX_OSERR, "Cannot determine which CPUs are logical");
+ CPU_ZERO(&logical_cpus_mask);
+ setsize = (size_t)cpusetsize;
if (sysctlbyname("machdep.logical_cpus_mask", &logical_cpus_mask,
- &dummy, NULL, 0) < 0)
- logical_cpus_mask = 0;
+ &setsize, NULL, 0) < 0)
+ CPU_ZERO(&logical_cpus_mask);
ncpu = pc->pm_ncpu;
for (c = cpu = 0; cpu < ncpu; cpu++) {
#if defined(__i386__) || defined(__amd64__)
if (pc->pm_cputype == PMC_CPU_INTEL_PIV &&
- (logical_cpus_mask & (1 << cpu)))
+ CPU_ISSET(cpu, &logical_cpus_mask))
continue; /* skip P4-style 'logical' cpus */
#endif
if (pmc_pmcinfo(cpu, &pi) < 0) {
OpenPOWER on IntegriCloud