Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177707304
D61512.1795092711.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D61512.1795092711.diff
View Options
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile
--- a/share/man/man9/Makefile
+++ b/share/man/man9/Makefile
@@ -964,6 +964,7 @@
cpuset.9 CPU_EMPTY.9 \
cpuset.9 CPU_ISFULLSET.9 \
cpuset.9 CPU_FFS.9 \
+ cpuset.9 CPU_FFS_AT.9 \
cpuset.9 CPU_COUNT.9 \
cpuset.9 CPU_SUBSET.9 \
cpuset.9 CPU_OVERLAP.9 \
diff --git a/share/man/man9/cpuset.9 b/share/man/man9/cpuset.9
--- 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 August 7, 2025
+.Dd November 17, 2026
.Dt CPUSET 9
.Os
.Sh NAME
@@ -39,6 +39,7 @@
.Nm CPU_EMPTY ,
.Nm CPU_ISFULLSET ,
.Nm CPU_FFS ,
+.Nm CPU_FFS_AT ,
.Nm CPU_COUNT ,
.Nm CPU_SUBSET ,
.Nm CPU_OVERLAP ,
@@ -79,6 +80,8 @@
.Ft int
.Fn CPU_FFS "cpuset_t *cpuset"
.Ft int
+.Fn CPU_FFS_AT "cpuset_t *cpuset" "long start"
+.Ft int
.Fn CPU_COUNT "cpuset_t *cpuset"
.\"
.Ft bool
@@ -248,6 +251,19 @@
macro, you must subtract one from the result.
.Pp
The
+.Fn CPU_FFS_AT
+macro returns the 1-index of the first (lowest) CPU in
+.Fa cpuset
+that is greater than the 1-indexed
+.Fa start ,
+or zero if there is none.
+Passing the result of
+.Fn CPU_FFS
+as
+.Fa start
+finds the second CPU in the set.
+.Pp
+The
.Fn CPU_COUNT
macro returns the total number of CPUs in
.Fa cpuset .
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -1423,6 +1423,7 @@
SCHED_STAT_DEFINE(pickcpu_lowest, "Selected lowest load");
SCHED_STAT_DEFINE(pickcpu_local, "Migrated to current cpu");
SCHED_STAT_DEFINE(pickcpu_migration, "Selection may have caused migration");
+SCHED_STAT_DEFINE(pickcpu_onecpu, "Cpuset allows a single cpu");
static int
sched_pickcpu(struct thread *td, int flags)
@@ -1444,6 +1445,17 @@
*/
if ((flags & SRQ_OURSELF) || !THREAD_CAN_MIGRATE(td))
return (ts->ts_cpu);
+ /*
+ * A thread whose cpuset holds one cpu can only run there, so skip
+ * the topology search.
+ */
+ mask = &td->td_cpuset->cs_mask;
+ cpu = CPU_FFS(mask);
+ MPASS(cpu > 0);
+ if (cpu == CPU_SETSIZE || CPU_FFS_AT(mask, cpu) == 0) {
+ SCHED_STAT_INC(pickcpu_onecpu);
+ return (cpu - 1);
+ }
/*
* Prefer to run interrupt threads on the processors that generate
* the interrupt.
@@ -1509,7 +1521,6 @@
if (ccg == cpu_top)
ccg = NULL;
cpu = -1;
- mask = &td->td_cpuset->cs_mask;
pri = td->td_priority;
r = TD_IS_RUNNING(td);
/*
diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h
--- a/sys/sys/cpuset.h
+++ b/sys/sys/cpuset.h
@@ -69,6 +69,7 @@
#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)
+#define CPU_FFS_AT(p, start) __BIT_FFS_AT(CPU_SETSIZE, p, start)
#define CPU_FLS(p) __BIT_FLS(CPU_SETSIZE, p)
#define CPU_FOREACH_ISSET(i, p) __BIT_FOREACH_ISSET(CPU_SETSIZE, i, p)
#define CPU_FOREACH_ISCLR(i, p) __BIT_FOREACH_ISCLR(CPU_SETSIZE, i, p)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 19, 12:51 PM (18 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41841975
Default Alt Text
D61512.1795092711.diff (2 KB)
Attached To
Mode
D61512: sched_ule: Skip the CPU search for threads bound to one CPU
Attached
Detach File
Event Timeline