summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2013-06-13 20:46:03 +0000
committerjeff <jeff@FreeBSD.org>2013-06-13 20:46:03 +0000
commit7ee88fb112275ba704d022b9feebc6bbd4cddf2e (patch)
tree88a1eaa0fdaa8c6f93574ecfb224a95f498892b9
parent21c714c60959a0ddca57e0500d0f93287099f971 (diff)
downloadFreeBSD-src-7ee88fb112275ba704d022b9feebc6bbd4cddf2e.zip
FreeBSD-src-7ee88fb112275ba704d022b9feebc6bbd4cddf2e.tar.gz
- Add a BIT_FFS() macro and use it to replace cpusetffs_obj()
Discussed with: attilio Sponsored by: EMC / Isilon Storage Division
-rw-r--r--sys/amd64/amd64/mp_machdep.c4
-rw-r--r--sys/i386/i386/mp_machdep.c4
-rw-r--r--sys/i386/i386/pmap.c2
-rw-r--r--sys/i386/xen/mp_machdep.c4
-rw-r--r--sys/i386/xen/pmap.c2
-rw-r--r--sys/kern/kern_cpuset.c20
-rw-r--r--sys/mips/mips/mp_machdep.c4
-rw-r--r--sys/sparc64/sparc64/mp_machdep.c2
-rw-r--r--sys/sys/bitset.h15
-rw-r--r--sys/sys/cpuset.h2
10 files changed, 27 insertions, 32 deletions
diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index 5f4aacf..3ad00e7 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -1150,7 +1150,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, vm_offset_t addr1, vm_of
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);
diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c
index a7046d8..9b832ed 100644
--- a/sys/i386/i386/mp_machdep.c
+++ b/sys/i386/i386/mp_machdep.c
@@ -1249,7 +1249,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, vm_offset_t addr1, vm_of
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);
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index d889bf8..0338bb1 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -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);
diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c
index 253cc40..fdfa812 100644
--- a/sys/i386/xen/mp_machdep.c
+++ b/sys/i386/xen/mp_machdep.c
@@ -1039,7 +1039,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, vm_offset_t addr1, vm_of
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);
diff --git a/sys/i386/xen/pmap.c b/sys/i386/xen/pmap.c
index 01a493c..96988e2 100644
--- a/sys/i386/xen/pmap.c
+++ b/sys/i386/xen/pmap.c
@@ -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);
diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c
index 2ef1fa7..507d059 100644
--- a/sys/kern/kern_cpuset.c
+++ b/sys/kern/kern_cpuset.c
@@ -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.
*/
diff --git a/sys/mips/mips/mp_machdep.c b/sys/mips/mips/mp_machdep.c
index 2298124..88c2357 100644
--- a/sys/mips/mips/mp_machdep.c
+++ b/sys/mips/mips/mp_machdep.c
@@ -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) {
diff --git a/sys/sparc64/sparc64/mp_machdep.c b/sys/sparc64/sparc64/mp_machdep.c
index b03412e..fccfb6f 100644
--- a/sys/sparc64/sparc64/mp_machdep.c
+++ b/sys/sparc64/sparc64/mp_machdep.c
@@ -557,7 +557,7 @@ spitfire_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2)
{
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);
diff --git a/sys/sys/bitset.h b/sys/sys/bitset.h
index c93cb2c..dee5542 100644
--- a/sys/sys/bitset.h
+++ b/sys/sys/bitset.h
@@ -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_ */
diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h
index 259070b..511b87a 100644
--- a/sys/sys/cpuset.h
+++ b/sys/sys/cpuset.h
@@ -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 *);
OpenPOWER on IntegriCloud