Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched: Minimise repeated sched_proxy_exec() checking

Peter noted: Compilers are really bad (as in they utterly refuse)
optimizing (even when marked with __pure) the static branch
things, and will happily emit multiple identical in a row.

So pull out the one obvious sched_proxy_exec() branch in
__schedule() and remove some of the 'implicit' ones in that
path.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: John Stultz <jstultz@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://patch.msgid.link/20260324191337.1841376-3-jstultz@google.com

authored by

John Stultz and committed by
Peter Zijlstra
37341ec5 e0ca8991

+9 -11
+9 -11
kernel/sched/core.c
··· 6597 6597 struct mutex *mutex; 6598 6598 6599 6599 /* Follow blocked_on chain. */ 6600 - for (p = donor; task_is_blocked(p); p = owner) { 6601 - mutex = p->blocked_on; 6602 - /* Something changed in the chain, so pick again */ 6603 - if (!mutex) 6604 - return NULL; 6600 + for (p = donor; (mutex = p->blocked_on); p = owner) { 6605 6601 /* 6606 6602 * By taking mutex->wait_lock we hold off concurrent mutex_unlock() 6607 6603 * and ensure @owner sticks around. ··· 6828 6832 next = pick_next_task(rq, rq->donor, &rf); 6829 6833 rq_set_donor(rq, next); 6830 6834 rq->next_class = next->sched_class; 6831 - if (unlikely(task_is_blocked(next))) { 6832 - next = find_proxy_task(rq, next, &rf); 6833 - if (!next) 6834 - goto pick_again; 6835 - if (next == rq->idle) 6836 - goto keep_resched; 6835 + if (sched_proxy_exec()) { 6836 + if (unlikely(next->blocked_on)) { 6837 + next = find_proxy_task(rq, next, &rf); 6838 + if (!next) 6839 + goto pick_again; 6840 + if (next == rq->idle) 6841 + goto keep_resched; 6842 + } 6837 6843 } 6838 6844 picked: 6839 6845 clear_tsk_need_resched(prev);