pmcstat, pmccontrol: catch up with removal of machdep.hlt_cpus sysctl

Reported by:	Pan Tsu <inyaoo@gmail.com>
Reviewed by:	attilio
No objections:	gnn
This commit is contained in:
Andriy Gapon 2011-07-15 11:30:41 +00:00
parent 745bae379d
commit 44735e89b3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=224057
2 changed files with 3 additions and 31 deletions

View File

@ -30,7 +30,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/cpuset.h>
#include <sys/sysctl.h>
#include <assert.h>
@ -134,33 +133,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 +188,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);

View File

@ -552,7 +552,7 @@ int
main(int argc, char **argv)
{
double interval;
int option, npmc, ncpu, haltedcpus;
int option, npmc, ncpu;
int c, check_driver_stats, current_cpu, current_sampling_count;
int do_callchain, do_descendants, do_logproccsw, do_logprocexit;
int do_print;
@ -617,14 +617,6 @@ main(int argc, char **argv)
if (sysctlbyname("hw.ncpu", &ncpu, &dummy, NULL, 0) < 0)
err(EX_OSERR, "ERROR: Cannot determine the number of CPUs");
cpumask = (1 << ncpu) - 1;
haltedcpus = 0;
if (ncpu > 1) {
if (sysctlbyname("machdep.hlt_cpus", &haltedcpus, &dummy,
NULL, 0) < 0)
err(EX_OSERR, "ERROR: Cannot determine which CPUs are "
"halted");
cpumask &= ~haltedcpus;
}
while ((option = getopt(argc, argv,
"CD:EF:G:M:NO:P:R:S:TWc:df:gk:m:n:o:p:qr:s:t:vw:z:")) != -1)
@ -637,7 +629,7 @@ main(int argc, char **argv)
case 'c': /* CPU */
if (optarg[0] == '*' && optarg[1] == '\0')
cpumask = ((1 << ncpu) - 1) & ~haltedcpus;
cpumask = (1 << ncpu) - 1;
else
cpumask = pmcstat_get_cpumask(optarg);