Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177548587
D61512.1794684687.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.1794684687.diff
View Options
diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c
--- a/sys/kern/kern_cpuset.c
+++ b/sys/kern/kern_cpuset.c
@@ -310,6 +310,19 @@
return (set);
}
+/*
+ * Keep CPU_SET_ONECPU in step with cs_mask. Called wherever the mask changes.
+ */
+static void
+cpuset_flags_update(struct cpuset *set)
+{
+
+ if (CPU_COUNT(&set->cs_mask) == 1)
+ set->cs_flags |= CPU_SET_ONECPU;
+ else
+ set->cs_flags &= ~CPU_SET_ONECPU;
+}
+
/*
* Initialize a set in the space provided in 'set' with the provided parameters.
* The set is returned with a single ref. May return EDEADLK if the set
@@ -336,6 +349,7 @@
mtx_lock_spin(&cpuset_lock);
set->cs_domain = domain;
CPU_AND(&set->cs_mask, &set->cs_mask, &parent->cs_mask);
+ cpuset_flags_update(set);
set->cs_id = id;
set->cs_parent = cpuset_ref(parent);
LIST_INSERT_HEAD(&parent->cs_children, set, cs_siblings);
@@ -677,6 +691,7 @@
mtx_assert(&cpuset_lock, MA_OWNED);
CPU_AND(&set->cs_mask, &set->cs_mask, mask);
+ cpuset_flags_update(set);
LIST_FOREACH(nset, &set->cs_children, cs_siblings)
cpuset_update(nset, &set->cs_mask);
@@ -1659,6 +1674,7 @@
LIST_INSERT_HEAD(&cpuset_ids, set, cs_link);
refcount_init(&set->cs_ref, 1);
set->cs_flags = CPU_SET_ROOT | CPU_SET_RDONLY;
+ cpuset_flags_update(set);
set->cs_domain = domainset0;
cpuset_zero = set;
cpuset_root = &set->cs_mask;
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
@@ -1404,6 +1404,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)
@@ -1425,6 +1426,15 @@
*/
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;
+ if (td->td_cpuset->cs_flags & CPU_SET_ONECPU) {
+ SCHED_STAT_INC(pickcpu_onecpu);
+ return (CPU_FFS(mask) - 1);
+ }
/*
* Prefer to run interrupt threads on the processors that generate
* the interrupt.
@@ -1490,7 +1500,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
@@ -149,6 +149,7 @@
#define CPU_SET_ROOT 0x0001 /* Set is a root set. */
#define CPU_SET_RDONLY 0x0002 /* No modification allowed. */
+#define CPU_SET_ONECPU 0x0004 /* Mask holds a single cpu. */
extern cpuset_t *cpuset_root;
struct prison;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 14, 7:31 PM (15 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41731328
Default Alt Text
D61512.1794684687.diff (2 KB)
Attached To
Mode
D61512: sched_ule: Skip the CPU search for threads bound to one CPU
Attached
Detach File
Event Timeline