Skip to content

Commit 7f829bd

Browse files
Fernand SieberPeter Zijlstra
authored andcommitted
sched/core: Optimize core cookie matching check
Early return true if the core cookie matches. This avoids the SMT mask loop to check for an idle core, which might be more expensive on wide platforms. Signed-off-by: Fernand Sieber <sieberf@amazon.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com> Reviewed-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com> Link: https://patch.msgid.link/20251105152538.470586-1-sieberf@amazon.com
1 parent 127b903 commit 7f829bd

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

kernel/sched/sched.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,9 @@ static inline bool sched_core_cookie_match(struct rq *rq, struct task_struct *p)
14321432
if (!sched_core_enabled(rq))
14331433
return true;
14341434

1435+
if (rq->core->core_cookie == p->core_cookie)
1436+
return true;
1437+
14351438
for_each_cpu(cpu, cpu_smt_mask(cpu_of(rq))) {
14361439
if (!available_idle_cpu(cpu)) {
14371440
idle_core = false;
@@ -1443,7 +1446,7 @@ static inline bool sched_core_cookie_match(struct rq *rq, struct task_struct *p)
14431446
* A CPU in an idle core is always the best choice for tasks with
14441447
* cookies.
14451448
*/
1446-
return idle_core || rq->core->core_cookie == p->core_cookie;
1449+
return idle_core;
14471450
}
14481451

14491452
static inline bool sched_group_cookie_match(struct rq *rq,

0 commit comments

Comments
 (0)