From owner-svn-src-all@FreeBSD.ORG Sun Nov 9 08:36:35 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0D171065673; Sun, 9 Nov 2008 08:36:35 +0000 (UTC) (envelope-from jkoshy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BF13A8FC13; Sun, 9 Nov 2008 08:36:35 +0000 (UTC) (envelope-from jkoshy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mA98aZW1034732; Sun, 9 Nov 2008 08:36:35 GMT (envelope-from jkoshy@svn.freebsd.org) Received: (from jkoshy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mA98aZAD034731; Sun, 9 Nov 2008 08:36:35 GMT (envelope-from jkoshy@svn.freebsd.org) Message-Id: <200811090836.mA98aZAD034731@svn.freebsd.org> From: Joseph Koshy Date: Sun, 9 Nov 2008 08:36:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r184782 - head/usr.sbin/pmccontrol X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Nov 2008 08:36:35 -0000 Author: jkoshy Date: Sun Nov 9 08:36:35 2008 New Revision: 184782 URL: http://svn.freebsd.org/changeset/base/184782 Log: Change the meaning of a "*" argument to option -c to mean 'all unhalted CPUs', instead of 'all CPUs'. This change brings pmccontrol(8) in line with pmcstat(8). Modified: head/usr.sbin/pmccontrol/pmccontrol.c Modified: head/usr.sbin/pmccontrol/pmccontrol.c ============================================================================== --- head/usr.sbin/pmccontrol/pmccontrol.c Sun Nov 9 07:58:23 2008 (r184781) +++ head/usr.sbin/pmccontrol/pmccontrol.c Sun Nov 9 08:36:35 2008 (r184782) @@ -133,21 +133,33 @@ pmcc_init_debug(void) static int pmcc_do_enable_disable(struct pmcc_op_list *op_list) { - unsigned char op; int c, error, i, j, ncpu, npmc, t; - int cpu, pmc; + cpumask_t haltedcpus, cpumask; struct pmcc_op *np; unsigned char *map; + unsigned char op; + int cpu, pmc; + size_t dummy; if ((ncpu = pmc_ncpu()) < 0) err(EX_OSERR, "Unable to determine the number of cpus"); - /* determine the maximum number of PMCs in any CPU */ + /* Determine the set of active CPUs. */ + cpumask = (1 << ncpu) - 1; + dummy = sizeof(int); + haltedcpus = (cpumask_t) 0; + if (ncpu > 1 && sysctlbyname("machdep.hlt_cpus", &haltedcpus, + &dummy, NULL, 0) < 0) + err(EX_OSERR, "ERROR: Cannot determine which CPUs are " + "halted"); + cpumask &= ~haltedcpus; + + /* Determine the maximum number of PMCs in any CPU. */ npmc = 0; for (c = 0; c < ncpu; c++) { if ((t = pmc_npmc(c)) < 0) - err(EX_OSERR, "Unable to determine the number of PMCs in " - "CPU %d", c); + err(EX_OSERR, "Unable to determine the number of " + "PMCs in CPU %d", c); npmc = t > npmc ? t : npmc; } @@ -187,8 +199,10 @@ pmcc_do_enable_disable(struct pmcc_op_li #define MAP(M,C,P) (*((M) + (C)*npmc + (P))) if (cpu == PMCC_CPU_ALL) - for (i = 0; i < ncpu; i++) - SET_PMCS(i, pmc, op); + for (i = 0; i < ncpu; i++) { + if ((1 << i) & cpumask) + SET_PMCS(i, pmc, op); + } else SET_PMCS(cpu, pmc, op); }