Skip to content

Commit be365ce

Browse files
author
Peter Zijlstra
committed
sched/proxy: Switch proxy to use p->is_blocked
Rather than gate the proxy paths with p->blocked_on, use p->is_blocked. This opens up the state: '->is_blocked && !->blocked_on' for future use. Notably, only proxy and delayed tasks can be ->on_rq && ->is_blocked, and it is guaranteed that sched_class::pick_task() will never return a delayed task. Therefore any task returned from pick_next_task() that has ->is_blocked set, must be a proxy task. Suggested-by: K Prateek Nayak <kprateek.nayak@amd.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20260526113322.477954312%40infradead.org
1 parent 7918cf3 commit be365ce

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

kernel/sched/core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3764,7 +3764,7 @@ static inline void proxy_reset_donor(struct rq *rq)
37643764
*/
37653765
static inline bool proxy_needs_return(struct rq *rq, struct task_struct *p)
37663766
{
3767-
if (!task_is_blocked(p))
3767+
if (!p->is_blocked)
37683768
return false;
37693769

37703770
/*
@@ -6866,14 +6866,14 @@ find_proxy_task(struct rq *rq, struct task_struct *donor, struct rq_flags *rf)
68666866
bool curr_in_chain = false;
68676867
int this_cpu = cpu_of(rq);
68686868
struct task_struct *p;
6869-
struct mutex *mutex;
68706869
int owner_cpu;
68716870

68726871
/* Follow blocked_on chain. */
6873-
for (p = donor; (mutex = p->blocked_on); p = owner) {
6872+
for (p = donor; p->is_blocked; p = owner) {
68746873
/* if its PROXY_WAKING, do return migration or run if current */
6875-
if (mutex == PROXY_WAKING) {
6876-
clear_task_blocked_on(p, PROXY_WAKING);
6874+
struct mutex *mutex = p->blocked_on;
6875+
if (!mutex || mutex == PROXY_WAKING) {
6876+
clear_task_blocked_on(p, mutex);
68776877
if (task_current(rq, p)) {
68786878
p->is_blocked = 0;
68796879
return p;
@@ -7147,7 +7147,7 @@ static void __sched notrace __schedule(int sched_mode)
71477147

71487148
rq_set_donor(rq, next);
71497149
next->blocked_donor = NULL;
7150-
if (unlikely(next->is_blocked && next->blocked_on)) {
7150+
if (unlikely(next->is_blocked)) {
71517151
next = find_proxy_task(rq, next, &rf);
71527152
if (!next) {
71537153
zap_balance_callbacks(rq);

0 commit comments

Comments
 (0)