From 9825eadf2c5733993c61dbc106d4380ace6b1046 Mon Sep 17 00:00:00 2001 From: Ryan Libby Date: Fri, 13 Dec 2019 09:32:16 +0000 Subject: [PATCH] bitset: rename confusing macro NAND to ANDNOT s/BIT_NAND/BIT_ANDNOT/, and for CPU and DOMAINSET too. The actual implementation is "and not" (or "but not"), i.e. A but not B. Fortunately this does appear to be what all existing callers want. Don't supply a NAND (not (A and B)) operation at this time. Discussed with: jeff Reviewed by: cem Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D22791 --- share/man/man9/Makefile | 4 ++-- share/man/man9/bitset.9 | 14 +++++++------- share/man/man9/cpuset.9 | 8 ++++---- sys/i386/i386/vm_machdep.c | 2 +- sys/kern/kern_cpuset.c | 2 +- sys/kern/kern_rmlock.c | 2 +- sys/kern/sched_4bsd.c | 4 ++-- sys/kern/sched_ule.c | 2 +- sys/kern/subr_kdb.c | 2 +- sys/sparc64/sparc64/mp_machdep.c | 2 +- sys/sys/bitset.h | 4 ++-- sys/sys/cpuset.h | 2 +- sys/sys/domainset.h | 2 +- sys/x86/x86/cpu_machdep.c | 2 +- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 7ab169bcf8ac..9a79aff4cc25 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -607,7 +607,7 @@ MLINKS+=bitset.9 BITSET_DEFINE.9 \ bitset.9 BIT_CMP.9 \ bitset.9 BIT_OR.9 \ bitset.9 BIT_AND.9 \ - bitset.9 BIT_NAND.9 \ + bitset.9 BIT_ANDNOT.9 \ bitset.9 BIT_CLR_ATOMIC.9 \ bitset.9 BIT_SET_ATOMIC.9 \ bitset.9 BIT_SET_ATOMIC_ACQ.9 \ @@ -856,7 +856,7 @@ MLINKS+=cpuset.9 CPUSET_T_INITIALIZER.9 \ cpuset.9 CPU_CMP.9 \ cpuset.9 CPU_OR.9 \ cpuset.9 CPU_AND.9 \ - cpuset.9 CPU_NAND.9 \ + cpuset.9 CPU_ANDNOT.9 \ cpuset.9 CPU_CLR_ATOMIC.9 \ cpuset.9 CPU_SET_ATOMIC.9 \ cpuset.9 CPU_SET_ATOMIC_ACQ.9 \ diff --git a/share/man/man9/bitset.9 b/share/man/man9/bitset.9 index 1d02eee252b5..4aabb81e7605 100644 --- a/share/man/man9/bitset.9 +++ b/share/man/man9/bitset.9 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 7, 2017 +.Dd December 12, 2019 .Dt BITSET 9 .Os .Sh NAME @@ -52,8 +52,8 @@ .Nm BIT_OR2 , .Nm BIT_AND , .Nm BIT_AND2 , -.Nm BIT_NAND , -.Nm BIT_NAND2 , +.Nm BIT_ANDNOT , +.Nm BIT_ANDNOT2 , .Nm BIT_XOR , .Nm BIT_XOR2 , .Nm BIT_CLR_ATOMIC , @@ -116,8 +116,8 @@ .Fa "struct STRUCTNAME *src1" .Fa "struct STRUCTNAME *src2" .Fc -.Fn BIT_NAND "const SETSIZE" "struct STRUCTNAME *dst" "struct STRUCTNAME *src" -.Fo BIT_NAND2 +.Fn BIT_ANDNOT "const SETSIZE" "struct STRUCTNAME *dst" "struct STRUCTNAME *src" +.Fo BIT_ANDNOT2 .Fa "const SETSIZE" .Fa "struct STRUCTNAME *dst" .Fa "struct STRUCTNAME *src1" @@ -412,7 +412,7 @@ equivalent of the scalar: .Fa src2 . ) .Pp The -.Fn BIT_NAND +.Fn BIT_ANDNOT macro clears bits set in .Fa src from @@ -425,7 +425,7 @@ equivalent of the scalar: .Fa ~ src . ) .Pp The -.Fn BIT_NAND2 +.Fn BIT_ANDNOT2 macro computes .Fa src1 bitwise and not diff --git a/share/man/man9/cpuset.9 b/share/man/man9/cpuset.9 index 1d778ad940d3..93cd6fb7f115 100644 --- a/share/man/man9/cpuset.9 +++ b/share/man/man9/cpuset.9 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 29, 2016 +.Dd December 12, 2019 .Dt CPUSET 9 .Os .Sh NAME @@ -48,7 +48,7 @@ .Nm CPU_CMP , .Nm CPU_OR , .Nm CPU_AND , -.Nm CPU_NAND , +.Nm CPU_ANDNOT , .Nm CPU_CLR_ATOMIC , .Nm CPU_SET_ATOMIC , .Nm CPU_SET_ATOMIC_ACQ , @@ -88,7 +88,7 @@ .Fn CPU_CMP "cpuset_t *cpuset1" "cpuset_t *cpuset2" .Fn CPU_OR "cpuset_t *dst" "cpuset_t *src" .Fn CPU_AND "cpuset_t *dst" "cpuset_t *src" -.Fn CPU_NAND "cpuset_t *dst" "cpuset_t *src" +.Fn CPU_ANDNOT "cpuset_t *dst" "cpuset_t *src" .\" .Fn CPU_CLR_ATOMIC "size_t cpu_idx" "cpuset_t *cpuset" .Fn CPU_SET_ATOMIC "size_t cpu_idx" "cpuset_t *cpuset" @@ -303,7 +303,7 @@ is similar, with the same atomic semantics as .Fn CPU_OR_ATOMIC . .Pp The -.Fn CPU_NAND +.Fn CPU_ANDNOT macro removes CPUs in .Fa src from diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index da2e85ee13e4..62c7a6248641 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -598,7 +598,7 @@ sf_buf_shootdown(struct sf_buf *sf, int flags) if ((flags & SFB_CPUPRIVATE) == 0) { other_cpus = all_cpus; CPU_CLR(cpuid, &other_cpus); - CPU_NAND(&other_cpus, &sf->cpumask); + CPU_ANDNOT(&other_cpus, &sf->cpumask); if (!CPU_EMPTY(&other_cpus)) { CPU_OR(&sf->cpumask, &other_cpus); smp_masked_invlpg(other_cpus, sf->kva, kernel_pmap); diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index 2a2b1f8f7a29..d3290853e53f 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -510,7 +510,7 @@ domainset_empty_vm(struct domainset *domain) return (true); /* Remove empty domains from the set and recompute. */ - DOMAINSET_NAND(&domain->ds_mask, &empty); + DOMAINSET_ANDNOT(&domain->ds_mask, &empty); domain->ds_cnt = DOMAINSET_COUNT(&domain->ds_mask); for (i = j = 0; i < DOMAINSET_FLS(&domain->ds_mask); i++) if (DOMAINSET_ISSET(i, &domain->ds_mask)) diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c index 96e11276e9b2..1c54a56613b1 100644 --- a/sys/kern/kern_rmlock.c +++ b/sys/kern/kern_rmlock.c @@ -542,7 +542,7 @@ _rm_wlock(struct rmlock *rm) if (CPU_CMP(&rm->rm_writecpus, &all_cpus)) { /* Get all read tokens back */ readcpus = all_cpus; - CPU_NAND(&readcpus, &rm->rm_writecpus); + CPU_ANDNOT(&readcpus, &rm->rm_writecpus); rm->rm_writecpus = all_cpus; /* diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 72f90099a01e..3cfc76a1afd3 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -1181,7 +1181,7 @@ forward_wakeup(int cpunum) if (forward_wakeup_use_mask) { map = idle_cpus_mask; - CPU_NAND(&map, &dontuse); + CPU_ANDNOT(&map, &dontuse); /* If they are both on, compare and use loop if different. */ if (forward_wakeup_use_loop) { @@ -1366,7 +1366,7 @@ sched_add(struct thread *td, int flags) } else { if (!single_cpu) { tidlemsk = idle_cpus_mask; - CPU_NAND(&tidlemsk, &hlt_cpus_mask); + CPU_ANDNOT(&tidlemsk, &hlt_cpus_mask); CPU_CLR(cpuid, &tidlemsk); if (!CPU_ISSET(cpuid, &idle_cpus_mask) && diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index d3e77d3cda70..b921a68c6e52 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -705,7 +705,7 @@ cpu_search(const struct cpu_group *cg, struct cpu_search *low, if (match & CPU_SEARCH_HIGHEST) hgroup.cs_cpu = -1; if (child) { /* Handle child CPU group. */ - CPU_NAND(&cpumask, &child->cg_mask); + CPU_ANDNOT(&cpumask, &child->cg_mask); switch (match) { case CPU_SEARCH_LOWEST: load = cpu_search_lowest(child, &lgroup); diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index 07a2c7da5a7e..fa379b4da754 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -666,7 +666,7 @@ kdb_trap(int type, int code, struct trapframe *tf) if (!SCHEDULER_STOPPED()) { #ifdef SMP other_cpus = all_cpus; - CPU_NAND(&other_cpus, &stopped_cpus); + CPU_ANDNOT(&other_cpus, &stopped_cpus); CPU_CLR(PCPU_GET(cpuid), &other_cpus); stop_cpus_hard(other_cpus); #endif diff --git a/sys/sparc64/sparc64/mp_machdep.c b/sys/sparc64/sparc64/mp_machdep.c index e9542fd01be0..b95bf2f406d0 100644 --- a/sys/sparc64/sparc64/mp_machdep.c +++ b/sys/sparc64/sparc64/mp_machdep.c @@ -493,7 +493,7 @@ cpu_mp_shutdown(void) if (CPU_CMP(&stopped_cpus, &cpus)) { /* cpus is just a flat "on" mask without curcpu. */ - CPU_NAND(&cpus, &stopped_cpus); + CPU_ANDNOT(&cpus, &stopped_cpus); stop_cpus(cpus); } i = 0; diff --git a/sys/sys/bitset.h b/sys/sys/bitset.h index 2ff5ced872e2..f45a1827a61d 100644 --- a/sys/sys/bitset.h +++ b/sys/sys/bitset.h @@ -149,13 +149,13 @@ (d)->__bits[__i] = (s1)->__bits[__i] & (s2)->__bits[__i];\ } while (0) -#define BIT_NAND(_s, d, s) do { \ +#define BIT_ANDNOT(_s, d, s) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ (d)->__bits[__i] &= ~(s)->__bits[__i]; \ } while (0) -#define BIT_NAND2(_s, d, s1, s2) do { \ +#define BIT_ANDNOT2(_s, d, s1, s2) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ (d)->__bits[__i] = (s1)->__bits[__i] & ~(s2)->__bits[__i];\ diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index 829237df6fd2..8e06dcbdc687 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -57,7 +57,7 @@ #define CPU_CMP(p, c) BIT_CMP(CPU_SETSIZE, p, c) #define CPU_OR(d, s) BIT_OR(CPU_SETSIZE, d, s) #define CPU_AND(d, s) BIT_AND(CPU_SETSIZE, d, s) -#define CPU_NAND(d, s) BIT_NAND(CPU_SETSIZE, d, s) +#define CPU_ANDNOT(d, s) BIT_ANDNOT(CPU_SETSIZE, d, s) #define CPU_CLR_ATOMIC(n, p) BIT_CLR_ATOMIC(CPU_SETSIZE, n, p) #define CPU_SET_ATOMIC(n, p) BIT_SET_ATOMIC(CPU_SETSIZE, n, p) #define CPU_SET_ATOMIC_ACQ(n, p) BIT_SET_ATOMIC_ACQ(CPU_SETSIZE, n, p) diff --git a/sys/sys/domainset.h b/sys/sys/domainset.h index 5a00347f29d3..a2988e7cc27a 100644 --- a/sys/sys/domainset.h +++ b/sys/sys/domainset.h @@ -58,7 +58,7 @@ #define DOMAINSET_CMP(p, c) BIT_CMP(DOMAINSET_SETSIZE, p, c) #define DOMAINSET_OR(d, s) BIT_OR(DOMAINSET_SETSIZE, d, s) #define DOMAINSET_AND(d, s) BIT_AND(DOMAINSET_SETSIZE, d, s) -#define DOMAINSET_NAND(d, s) BIT_NAND(DOMAINSET_SETSIZE, d, s) +#define DOMAINSET_ANDNOT(d, s) BIT_ANDNOT(DOMAINSET_SETSIZE, d, s) #define DOMAINSET_CLR_ATOMIC(n, p) BIT_CLR_ATOMIC(DOMAINSET_SETSIZE, n, p) #define DOMAINSET_SET_ATOMIC(n, p) BIT_SET_ATOMIC(DOMAINSET_SETSIZE, n, p) #define DOMAINSET_SET_ATOMIC_ACQ(n, p) \ diff --git a/sys/x86/x86/cpu_machdep.c b/sys/x86/x86/cpu_machdep.c index d4210b7aea41..384dd82ff370 100644 --- a/sys/x86/x86/cpu_machdep.c +++ b/sys/x86/x86/cpu_machdep.c @@ -447,7 +447,7 @@ cpu_reset(void) if (smp_started) { map = all_cpus; CPU_CLR(PCPU_GET(cpuid), &map); - CPU_NAND(&map, &stopped_cpus); + CPU_ANDNOT(&map, &stopped_cpus); if (!CPU_EMPTY(&map)) { printf("cpu_reset: Stopping other CPUs\n"); stop_cpus(map);