Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108579064
D38110.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D38110.diff
View Options
diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h
--- a/sys/sys/cpuset.h
+++ b/sys/sys/cpuset.h
@@ -75,23 +75,21 @@
#define CPUSET_FSET __BITSET_FSET(_NCPUWORDS)
#define CPUSET_T_INITIALIZER(x) __BITSET_T_INITIALIZER(x)
-#if !defined(_KERNEL)
#define CPU_ALLOC_SIZE(_s) __BITSET_SIZE(_s)
#define CPU_ALLOC(_s) __cpuset_alloc(_s)
#define CPU_FREE(p) __cpuset_free(p)
-#define CPU_ISSET_S(n, _s, p) __BIT_ISSET(_s, n, p)
-#define CPU_SET_S(n, _s, p) __BIT_SET(_s, n, p)
-#define CPU_CLR_S(n, _s, p) __BIT_CLR(_s, n, p)
-#define CPU_ZERO_S(_s, p) __BIT_ZERO(_s, p)
+#define CPU_ISSET_S(n, _s, p) __BIT_ISSET((_s) * 8, n, p)
+#define CPU_SET_S(n, _s, p) __BIT_SET((_s) * 8, n, p)
+#define CPU_CLR_S(n, _s, p) __BIT_CLR((_s) * 8, n, p)
+#define CPU_ZERO_S(_s, p) __BIT_ZERO((_s) * 8, p)
-#define CPU_OR_S(_s, d, s1, s2) __BIT_OR2(_s, d, s1, s2)
-#define CPU_AND_S(_s, d, s1, s2) __BIT_AND2(_s, d, s1, s2)
-#define CPU_XOR_S(_s, d, s1, s2) __BIT_XOR2(_s, d, s1, s2)
+#define CPU_OR_S(_s, d, s1, s2) __BIT_OR2((_s) * 8, d, s1, s2)
+#define CPU_AND_S(_s, d, s1, s2) __BIT_AND2((_s) * 8, d, s1, s2)
+#define CPU_XOR_S(_s, d, s1, s2) __BIT_XOR2((_s) * 8, d, s1, s2)
-#define CPU_COUNT_S(_s, p) ((int)__BIT_COUNT(_s, p))
-#define CPU_EQUAL_S(_s, p, c) (__BIT_CMP(_s, p, c) == 0)
-#endif
+#define CPU_COUNT_S(_s, p) ((int)__BIT_COUNT((_s) * 8, p))
+#define CPU_EQUAL_S(_s, p, c) (__BIT_CMP((_s) * 8, p, c) == 0)
/*
* Valid cpulevel_t values.
diff --git a/tests/sys/kern/sched_affinity.c b/tests/sys/kern/sched_affinity.c
--- a/tests/sys/kern/sched_affinity.c
+++ b/tests/sys/kern/sched_affinity.c
@@ -50,7 +50,7 @@
setsize = CPU_ALLOC_SIZE(i);
set = CPU_ALLOC(i);
ATF_REQUIRE(set != NULL);
- CPU_ZERO_S(i, set);
+ CPU_ZERO_S(setsize, set);
rv = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
-1, setsize, set);
if (rv == 0) {
@@ -73,18 +73,18 @@
cpusetsize = CPU_ALLOC_SIZE(maxcpuid + 1);
set = CPU_ALLOC(maxcpuid + 1);
ATF_REQUIRE(set != NULL);
- CPU_ZERO_S(maxcpuid + 1, set);
- CPU_SET_S(maxcpuid + 1, maxcpuid + 1, set);
- CPU_SET_S(maxcpuid - 1, maxcpuid + 1, set);
+ CPU_ZERO_S(cpusetsize, set);
+ CPU_SET_S(maxcpuid + 1, cpusetsize, set);
+ CPU_SET_S(maxcpuid - 1, cpusetsize, set);
ATF_REQUIRE(sched_setaffinity(0, cpusetsize, set) == 0);
CPU_FREE(set);
cpusetsize = CPU_ALLOC_SIZE(maxcpus + 1);
set = CPU_ALLOC(maxcpus + 1);
ATF_REQUIRE(set != NULL);
- CPU_ZERO_S(maxcpus + 1, set);
- CPU_SET_S(maxcpuid + 1, maxcpus + 1, set);
- CPU_SET_S(maxcpuid - 1, maxcpus + 1, set);
+ CPU_ZERO_S(cpusetsize, set);
+ CPU_SET_S(maxcpuid + 1, cpusetsize, set);
+ CPU_SET_S(maxcpuid - 1, cpusetsize, set);
ATF_REQUIRE(cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
-1, cpusetsize, set) == -1);
ATF_REQUIRE_EQ(errno, EINVAL);
@@ -104,8 +104,8 @@
cpusetsize = CPU_ALLOC_SIZE(maxcpus + 1);
set = CPU_ALLOC(maxcpus + 1);
ATF_REQUIRE(set != NULL);
- CPU_ZERO_S(maxcpus + 1, set);
- CPU_SET_S(cpu, maxcpus + 1, set);
+ CPU_ZERO_S(cpusetsize, set);
+ CPU_SET_S(cpu, cpusetsize, set);
ATF_REQUIRE(cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
-1, cpusetsize, set) == 0);
ATF_REQUIRE_EQ(cpu, sched_getcpu());
@@ -121,7 +121,7 @@
cpusetsize = CPU_ALLOC_SIZE(maxcpuid + 1);
set = CPU_ALLOC(maxcpuid + 1);
ATF_REQUIRE(set != NULL);
- CPU_ZERO_S(maxcpuid + 1, set);
+ CPU_ZERO_S(cpusetsize, set);
ATF_REQUIRE(sched_setaffinity(0, cpusetsize, set) == -1);
ATF_REQUIRE_EQ(errno, EINVAL);
CPU_FREE(set);
@@ -136,7 +136,7 @@
cpusetsize = CPU_ALLOC_SIZE(maxcpuid + 1);
set = CPU_ALLOC(maxcpuid + 1);
ATF_REQUIRE(set != NULL);
- CPU_ZERO_S(maxcpuid + 1, set);
+ CPU_ZERO_S(cpusetsize, set);
ATF_REQUIRE(cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
-1, cpusetsize, set) == -1);
ATF_REQUIRE_EQ(errno, EDEADLK);
@@ -152,20 +152,20 @@
cpusetsize = CPU_ALLOC_SIZE(maxcpus * 2);
set = CPU_ALLOC(maxcpus * 2);
ATF_REQUIRE(set != NULL);
- CPU_ZERO_S(maxcpus * 2, set);
- ATF_REQUIRE(CPU_COUNT_S(maxcpus * 2, set) == 0);
- CPU_SET_S(0, maxcpus * 2, set);
- ATF_REQUIRE(CPU_COUNT_S(maxcpus * 2, set) == 1);
+ CPU_ZERO_S(cpusetsize, set);
+ ATF_REQUIRE(CPU_COUNT_S(cpusetsize, set) == 0);
+ CPU_SET_S(0, cpusetsize, set);
+ ATF_REQUIRE(CPU_COUNT_S(cpusetsize, set) == 1);
ATF_REQUIRE(cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
-1, cpusetsize, set) == 0);
- CPU_ZERO_S(maxcpus * 2, set);
- CPU_SET_S(maxcpuid, maxcpus * 2, set);
+ CPU_ZERO_S(cpusetsize, set);
+ CPU_SET_S(maxcpuid, cpusetsize, set);
ATF_REQUIRE(cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
-1, cpusetsize, set) == 0);
- CPU_ZERO_S(maxcpus * 2, set);
- CPU_SET_S(maxcpuid + 1, maxcpus * 2, set);
+ CPU_ZERO_S(cpusetsize, set);
+ CPU_SET_S(maxcpuid + 1, cpusetsize, set);
ATF_REQUIRE(cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
-1, cpusetsize, set) == -1);
ATF_REQUIRE_EQ(errno, EINVAL);
@@ -212,7 +212,7 @@
cpusetsize = CPU_ALLOC_SIZE(maxcpuid + 1);
set = CPU_ALLOC(maxcpuid + 1);
ATF_REQUIRE(set != NULL);
- CPU_ZERO_S(maxcpuid + 1, set);
+ CPU_ZERO_S(cpusetsize, set);
ATF_REQUIRE(cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
-1, cpusetsize, set) == 0);
CPU_FREE(set);
@@ -227,26 +227,26 @@
cpusetsize = CPU_ALLOC_SIZE(maxcpus * 2);
set = CPU_ALLOC(maxcpus * 2);
ATF_REQUIRE(set != NULL);
- CPU_ZERO_S(maxcpus * 2, set);
- ATF_REQUIRE(CPU_COUNT_S(maxcpus * 2, set) == 0);
- CPU_SET_S(maxcpuid, maxcpus * 2, set);
- ATF_REQUIRE(CPU_COUNT_S(maxcpus * 2, set) == 1);
+ CPU_ZERO_S(cpusetsize, set);
+ ATF_REQUIRE(CPU_COUNT_S(cpusetsize, set) == 0);
+ CPU_SET_S(maxcpuid, cpusetsize, set);
+ ATF_REQUIRE(CPU_COUNT_S(cpusetsize, set) == 1);
ATF_REQUIRE(cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
-1, cpusetsize, set) == 0);
- CPU_ZERO_S(maxcpus * 2, set);
- ATF_REQUIRE(CPU_COUNT_S(maxcpus * 2, set) == 0);
- CPU_SET_S(maxcpuid + 1, maxcpus * 2, set);
- ATF_REQUIRE(CPU_COUNT_S(maxcpus * 2, set) == 1);
+ CPU_ZERO_S(cpusetsize, set);
+ ATF_REQUIRE(CPU_COUNT_S(cpusetsize, set) == 0);
+ CPU_SET_S(maxcpuid + 1, cpusetsize, set);
+ ATF_REQUIRE(CPU_COUNT_S(cpusetsize, set) == 1);
ATF_REQUIRE(cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
-1, cpusetsize, set) == -1);
ATF_REQUIRE_EQ(errno, EINVAL);
- ATF_REQUIRE(CPU_COUNT_S(maxcpus * 2, set) == 1);
+ ATF_REQUIRE(CPU_COUNT_S(cpusetsize, set) == 1);
ATF_REQUIRE(cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
-1, cpusetsize, set) == 0);
- ATF_REQUIRE(CPU_ISSET_S(maxcpuid + 1, maxcpus * 2, set) == false);
- ATF_REQUIRE(CPU_ISSET_S(maxcpuid, maxcpus * 2, set) == true);
+ ATF_REQUIRE(CPU_ISSET_S(maxcpuid + 1, cpusetsize, set) == false);
+ ATF_REQUIRE(CPU_ISSET_S(maxcpuid, cpusetsize, set) == true);
ATF_REQUIRE_EQ(maxcpuid, (uint32_t)sched_getcpu());
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 27, 1:52 PM (4 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16173013
Default Alt Text
D38110.diff (6 KB)
Attached To
Mode
D38110: sched.h: Fix _S macros for better compatibility with glibc.
Attached
Detach File
Event Timeline
Log In to Comment