From owner-svn-src-all@FreeBSD.ORG Thu Jun 13 20:46:06 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id F3648801; Thu, 13 Jun 2013 20:46:05 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D798711EB; Thu, 13 Jun 2013 20:46:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5DKk5hq006445; Thu, 13 Jun 2013 20:46:05 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5DKk3xd006430; Thu, 13 Jun 2013 20:46:03 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201306132046.r5DKk3xd006430@svn.freebsd.org> From: Jeff Roberson Date: Thu, 13 Jun 2013 20:46:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251703 - in head/sys: amd64/amd64 i386/i386 i386/xen kern mips/mips sparc64/sparc64 sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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: Thu, 13 Jun 2013 20:46:06 -0000 Author: jeff Date: Thu Jun 13 20:46:03 2013 New Revision: 251703 URL: http://svnweb.freebsd.org/changeset/base/251703 Log: - Add a BIT_FFS() macro and use it to replace cpusetffs_obj() Discussed with: attilio Sponsored by: EMC / Isilon Storage Division Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/i386/i386/mp_machdep.c head/sys/i386/i386/pmap.c head/sys/i386/xen/mp_machdep.c head/sys/i386/xen/pmap.c head/sys/kern/kern_cpuset.c head/sys/mips/mips/mp_machdep.c head/sys/sparc64/sparc64/mp_machdep.c head/sys/sys/bitset.h head/sys/sys/cpuset.h Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Thu Jun 13 20:41:09 2013 (r251702) +++ head/sys/amd64/amd64/mp_machdep.c Thu Jun 13 20:46:03 2013 (r251703) @@ -1150,7 +1150,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask ipi_all_but_self(vector); } else { ncpu = 0; - while ((cpu = cpusetobj_ffs(&mask)) != 0) { + while ((cpu = CPU_FFS(&mask)) != 0) { cpu--; CPU_CLR(cpu, &mask); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, @@ -1299,7 +1299,7 @@ ipi_selected(cpuset_t cpus, u_int ipi) if (ipi == IPI_STOP_HARD) CPU_OR_ATOMIC(&ipi_nmi_pending, &cpus); - while ((cpu = cpusetobj_ffs(&cpus)) != 0) { + while ((cpu = CPU_FFS(&cpus)) != 0) { cpu--; CPU_CLR(cpu, &cpus); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); Modified: head/sys/i386/i386/mp_machdep.c ============================================================================== --- head/sys/i386/i386/mp_machdep.c Thu Jun 13 20:41:09 2013 (r251702) +++ head/sys/i386/i386/mp_machdep.c Thu Jun 13 20:46:03 2013 (r251703) @@ -1249,7 +1249,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask ipi_all_but_self(vector); } else { ncpu = 0; - while ((cpu = cpusetobj_ffs(&mask)) != 0) { + while ((cpu = CPU_FFS(&mask)) != 0) { cpu--; CPU_CLR(cpu, &mask); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, @@ -1398,7 +1398,7 @@ ipi_selected(cpuset_t cpus, u_int ipi) if (ipi == IPI_STOP_HARD) CPU_OR_ATOMIC(&ipi_nmi_pending, &cpus); - while ((cpu = cpusetobj_ffs(&cpus)) != 0) { + while ((cpu = CPU_FFS(&cpus)) != 0) { cpu--; CPU_CLR(cpu, &cpus); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); Modified: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Thu Jun 13 20:41:09 2013 (r251702) +++ head/sys/i386/i386/pmap.c Thu Jun 13 20:46:03 2013 (r251703) @@ -1957,7 +1957,7 @@ pmap_lazyfix(pmap_t pmap) spins = 50000000; /* Find least significant set bit. */ - lsb = cpusetobj_ffs(&mask); + lsb = CPU_FFS(&mask); MPASS(lsb != 0); lsb--; CPU_SETOF(lsb, &mask); Modified: head/sys/i386/xen/mp_machdep.c ============================================================================== --- head/sys/i386/xen/mp_machdep.c Thu Jun 13 20:41:09 2013 (r251702) +++ head/sys/i386/xen/mp_machdep.c Thu Jun 13 20:46:03 2013 (r251703) @@ -1039,7 +1039,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask ipi_all_but_self(vector); } else { ncpu = 0; - while ((cpu = cpusetobj_ffs(&mask)) != 0) { + while ((cpu = CPU_FFS(&mask)) != 0) { cpu--; CPU_CLR(cpu, &mask); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, @@ -1132,7 +1132,7 @@ ipi_selected(cpuset_t cpus, u_int ipi) if (ipi == IPI_STOP_HARD) CPU_OR_ATOMIC(&ipi_nmi_pending, &cpus); - while ((cpu = cpusetobj_ffs(&cpus)) != 0) { + while ((cpu = CPU_FFS(&cpus)) != 0) { cpu--; CPU_CLR(cpu, &cpus); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); Modified: head/sys/i386/xen/pmap.c ============================================================================== --- head/sys/i386/xen/pmap.c Thu Jun 13 20:41:09 2013 (r251702) +++ head/sys/i386/xen/pmap.c Thu Jun 13 20:46:03 2013 (r251703) @@ -1707,7 +1707,7 @@ pmap_lazyfix(pmap_t pmap) spins = 50000000; /* Find least significant set bit. */ - lsb = cpusetobj_ffs(&mask); + lsb = CPU_FFS(&mask); MPASS(lsb != 0); lsb--; CPU_SETOF(lsb, &mask); Modified: head/sys/kern/kern_cpuset.c ============================================================================== --- head/sys/kern/kern_cpuset.c Thu Jun 13 20:41:09 2013 (r251702) +++ head/sys/kern/kern_cpuset.c Thu Jun 13 20:46:03 2013 (r251703) @@ -621,26 +621,6 @@ out: } /* - * Calculate the ffs() of the cpuset. - */ -int -cpusetobj_ffs(const cpuset_t *set) -{ - size_t i; - int cbit; - - cbit = 0; - for (i = 0; i < _NCPUWORDS; i++) { - if (set->__bits[i] != 0) { - cbit = ffsl(set->__bits[i]); - cbit += i * _NCPUBITS; - break; - } - } - return (cbit); -} - -/* * Return a string representing a valid layout for a cpuset_t object. * It expects an incoming buffer at least sized as CPUSETBUFSIZ. */ Modified: head/sys/mips/mips/mp_machdep.c ============================================================================== --- head/sys/mips/mips/mp_machdep.c Thu Jun 13 20:41:09 2013 (r251702) +++ head/sys/mips/mips/mp_machdep.c Thu Jun 13 20:46:03 2013 (r251703) @@ -208,7 +208,7 @@ cpu_mp_setmaxid(void) platform_cpu_mask(&cpumask); mp_ncpus = 0; last = 1; - while ((cpu = cpusetobj_ffs(&cpumask)) != 0) { + while ((cpu = CPU_FFS(&cpumask)) != 0) { last = cpu; cpu--; CPU_CLR(cpu, &cpumask); @@ -251,7 +251,7 @@ cpu_mp_start(void) platform_cpu_mask(&cpumask); while (!CPU_EMPTY(&cpumask)) { - cpuid = cpusetobj_ffs(&cpumask) - 1; + cpuid = CPU_FFS(&cpumask) - 1; CPU_CLR(cpuid, &cpumask); if (cpuid >= MAXCPU) { Modified: head/sys/sparc64/sparc64/mp_machdep.c ============================================================================== --- head/sys/sparc64/sparc64/mp_machdep.c Thu Jun 13 20:41:09 2013 (r251702) +++ head/sys/sparc64/sparc64/mp_machdep.c Thu Jun 13 20:46:03 2013 (r251703) @@ -557,7 +557,7 @@ spitfire_ipi_selected(cpuset_t cpus, u_l { u_int cpu; - while ((cpu = cpusetobj_ffs(&cpus)) != 0) { + while ((cpu = CPU_FFS(&cpus)) != 0) { cpu--; CPU_CLR(cpu, &cpus); spitfire_ipi_single(cpu, d0, d1, d2); Modified: head/sys/sys/bitset.h ============================================================================== --- head/sys/sys/bitset.h Thu Jun 13 20:41:09 2013 (r251702) +++ head/sys/sys/bitset.h Thu Jun 13 20:46:03 2013 (r251703) @@ -150,4 +150,19 @@ (f)->__bits[__i]); \ } while (0) +#define BIT_FFS(_s, p) __extension__ ({ \ + __size_t __i; \ + int __bit; \ + \ + __bit = 0; \ + for (__i = 0; __i < __bitset_words((_s)); __i++) { \ + if ((p)->__bits[__i] != 0) { \ + __bit = ffsl((p)->__bits[__i]); \ + __bit += __i * _BITSET_BITS; \ + break; \ + } \ + } \ + __bit; \ +}) + #endif /* !_SYS_BITSET_H_ */ Modified: head/sys/sys/cpuset.h ============================================================================== --- head/sys/sys/cpuset.h Thu Jun 13 20:41:09 2013 (r251702) +++ head/sys/sys/cpuset.h Thu Jun 13 20:46:03 2013 (r251703) @@ -57,6 +57,7 @@ #define CPU_SET_ATOMIC(n, p) BIT_SET_ATOMIC(CPU_SETSIZE, n, p) #define CPU_OR_ATOMIC(d, s) BIT_OR_ATOMIC(CPU_SETSIZE, d, s) #define CPU_COPY_STORE_REL(f, t) BIT_COPY_STORE_REL(CPU_SETSIZE, f, t) +#define CPU_FFS(p) BIT_FFS(CPU_SETSIZE, p) /* * Valid cpulevel_t values. @@ -118,7 +119,6 @@ void cpuset_rel(struct cpuset *); int cpuset_setthread(lwpid_t id, cpuset_t *); int cpuset_create_root(struct prison *, struct cpuset **); int cpuset_setproc_update_set(struct proc *, struct cpuset *); -int cpusetobj_ffs(const cpuset_t *); char *cpusetobj_strprint(char *, const cpuset_t *); int cpusetobj_strscan(cpuset_t *, const char *);