Re: [PATCH 07/18] sched/fair: Add push task mechanism for fair

From: Vincent Guittot

Date: Thu Oct 15 2026 - 04:08:43 EST


On Wed, 14 Oct 2026 at 18:28, Shrikanth Hegde <sshegde@xxxxxxxxxxxxx> wrote:
>
>
> >>> +static int
> >>> +select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags);
> >>> +
> >>> +/*
> >>> + * See if the non running fair tasks on this rq can be sent on other CPUs
> >>> + * that fits better with their profile.
> >>> + */
> >>> +static bool fair_push_task(struct rq *rq)
> >>> +{
> >>> + struct task_struct *next_task;
> >>> + int prev_cpu, new_cpu;
> >>> + struct rq_flags rf;
> >>> + struct rq *cur_rq;
> >>
> >> You likely need below to keep clang's context tracking to be happy.
> >>
> >> context_unsafe_alias(rq);
> >
> > I just noticed that I didn't answer to this one
> >
> > Why should I need this ?
> >
> > rq remains the same in fair_push_task(). I'm using rq and new_rq to
> > differentiate both current and new rq
> >
> >>
> I tried to use clang-23 and get below with the series applied.
> It may not be exactly here. But somewhere.

ok, the two functions probably need the below
__releases(__rq_lockp(rq))
__acquires(__rq_lockp(rq))


>
> make LLVM=/opt/llvm-23/bin/ \
> KCFLAGS="-Werror=thread-safety-analysis" \
> V=1 kernel/sched/fair.o
>
> kernel/sched/fair.c:9971:2: error: releasing raw_spinlock 'rq_lockp(rq)' that was not held [-Werror,-Wthread-safety-analysis]
> 9971 | raw_spin_rq_unlock(rq);
> | ^
> kernel/sched/fair.c:9983:2: error: raw_spinlock 'rq_lockp(rq)' is not held on every path through here [-Werror,-Wthread-safety-analysis]
> 9983 | raw_spin_unlock(&next_task->pi_lock);
> | ^
> ./include/linux/spinlock.h:279:32: note: expanded from macro 'raw_spin_unlock'
> 279 | #define raw_spin_unlock(lock) _raw_spin_unlock(lock)
> | ^
> kernel/sched/fair.c:9980:2: note: raw_spinlock acquired here
> 9980 | raw_spin_rq_lock(rq);
> | ^
> kernel/sched/fair.c:10085:2: error: releasing raw_spinlock 'rq_lockp(rq)' that was not held [-Werror,-Wthread-safety-analysis]
> 10085 | rq_unlock(rq, rf);
> | ^
> kernel/sched/fair.c:10093:1: error: raw_spinlock 'rq_lockp(rq)' is not held on every path through here
> [-Werror,-Wthread-safety-analysis]
> 10093 | }
> | ^
> kernel/sched/fair.c:10090:2: note: raw_spinlock acquired here
> 10090 | rq_lock(rq, rf);
> | ^