git: 9274eb16e5da - main - cpuset: Add CPU_TEST_{SET,CLR}_ATOMIC
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 07 Aug 2025 09:51:44 UTC
The branch main has been updated by andrew:
URL: https://cgit.FreeBSD.org/src/commit/?id=9274eb16e5da1bd048237cd82366c7db9162aafe
commit 9274eb16e5da1bd048237cd82366c7db9162aafe
Author: Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2025-08-07 09:23:34 +0000
Commit: Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2025-08-07 09:45:15 +0000
cpuset: Add CPU_TEST_{SET,CLR}_ATOMIC
These are similar to CPU_{SET,CLR}_ATOMIC with the addition of
returning true if the CPU bit was set before the change.
Reviewed by: markj
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D51765
---
share/man/man9/cpuset.9 | 14 +++++++++++++-
sys/sys/cpuset.h | 2 ++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/share/man/man9/cpuset.9 b/share/man/man9/cpuset.9
index 20485059a4c8..0ca04f921f82 100644
--- a/share/man/man9/cpuset.9
+++ b/share/man/man9/cpuset.9
@@ -22,7 +22,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd September 23, 2022
+.Dd August 7, 2025
.Dt CPUSET 9
.Os
.Sh NAME
@@ -50,8 +50,10 @@
.Nm CPU_ANDNOT ,
.Nm CPU_XOR ,
.Nm CPU_CLR_ATOMIC ,
+.Nm CPU_TEST_CLR_ATOMIC ,
.Nm CPU_SET_ATOMIC ,
.Nm CPU_SET_ATOMIC_ACQ ,
+.Nm CPU_TEST_SET_ATOMIC ,
.Nm CPU_AND_ATOMIC ,
.Nm CPU_OR_ATOMIC ,
.Nm CPU_COPY_STORE_REL
@@ -93,8 +95,10 @@
.Fn CPU_XOR "cpuset_t *dst" "cpuset_t *src1" "cpuset_t *src2"
.\"
.Fn CPU_CLR_ATOMIC "size_t cpu_idx" "cpuset_t *cpuset"
+.Fn CPU_TEST_CLR_ATOMIC "size_t cpu_idx" "cpuset_t *cpuset"
.Fn CPU_SET_ATOMIC "size_t cpu_idx" "cpuset_t *cpuset"
.Fn CPU_SET_ATOMIC_ACQ "size_t cpu_idx" "cpuset_t *cpuset"
+.Fn CPU_TEST_SET_ATOMIC "size_t cpu_idx" "cpuset_t *cpuset"
.\"
.Fn CPU_AND_ATOMIC "cpuset_t *dst" "cpuset_t *src"
.Fn CPU_OR_ATOMIC "cpuset_t *dst" "cpuset_t *src"
@@ -143,6 +147,10 @@ The
.Fn CPU_CLR_ATOMIC
macro is identical, but the bit representing the CPU is cleared with atomic
machine instructions.
+The
+.Fn CPU_TEST_CLR_ATOMIC
+macro atomically clears the bit representing the CPU and returns whether it
+was set.
.Pp
The
.Fn CPU_COPY
@@ -176,6 +184,10 @@ machine instructions.
The
.Fn CPU_SET_ATOMIC_ACQ
macro sets the bit representing the CPU with atomic acquire semantics.
+The
+.Fn CPU_TEST_SET_ATOMIC
+macro atomically sets the bit representing the CPU and returns whether it was
+set.
.Pp
The
.Fn CPU_ISSET
diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h
index b036b45da283..e861321586db 100644
--- a/sys/sys/cpuset.h
+++ b/sys/sys/cpuset.h
@@ -61,8 +61,10 @@
#define CPU_ANDNOT(d, s1, s2) __BIT_ANDNOT2(CPU_SETSIZE, d, s1, s2)
#define CPU_XOR(d, s1, s2) __BIT_XOR2(CPU_SETSIZE, d, s1, s2)
#define CPU_CLR_ATOMIC(n, p) __BIT_CLR_ATOMIC(CPU_SETSIZE, n, p)
+#define CPU_TEST_CLR_ATOMIC(n, p) __BIT_TEST_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)
+#define CPU_TEST_SET_ATOMIC(n, p) __BIT_TEST_SET_ATOMIC(CPU_SETSIZE, n, p)
#define CPU_AND_ATOMIC(n, p) __BIT_AND_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)