this_rq
struct rq *rq = this_rq();
struct rq *lowest_rq = NULL, *rq = this_rq();
rq = this_rq();
struct rq *rq = this_rq();
__acquires(__rq_lockp(this_rq()))
__acquire(__rq_lockp(this_rq()));
__releases(__rq_lockp(this_rq()))
struct rq *rq = this_rq();
__releases(__rq_lockp(this_rq()))
schedstat_inc(this_rq()->sched_count);
struct rq *rq = this_rq();
if (!cpu_dying(rq->cpu) || rq != this_rq())
struct rq *rq = this_rq();
if (rq == this_rq())
struct rq *rq = this_rq();
steal -= this_rq()->prev_steal_time;
this_rq()->prev_steal_time += steal;
} else if (p == this_rq()->idle) {
else if ((p != this_rq()->idle) || (irq_count() != HARDIRQ_OFFSET))
static void pull_dl_task(struct rq *this_rq)
int this_cpu = this_rq->cpu, cpu;
if (likely(!dl_overloaded(this_rq)))
for_each_cpu(cpu, this_rq->rd->dlo_mask) {
if (this_rq->dl.dl_nr_running &&
dl_time_before(this_rq->dl.earliest_dl.curr,
double_lock_balance(this_rq, src_rq);
dl_task_is_earliest_deadline(p, this_rq)) {
move_queued_task_locked(src_rq, this_rq, p);
double_unlock_balance(this_rq, src_rq);
raw_spin_rq_unlock(this_rq);
raw_spin_rq_lock(this_rq);
resched_curr(this_rq);
static bool consume_remote_task(struct rq *this_rq, struct task_struct *p,
raw_spin_rq_unlock(this_rq);
move_remote_task_to_local_dsq(p, 0, src_rq, this_rq);
raw_spin_rq_lock(this_rq);
dsq = find_dsq_for_dispatch(sch, this_rq(), dsq_id, p);
static bool kick_one_cpu(s32 cpu, struct rq *this_rq, unsigned long *ksyncs)
struct scx_rq *this_scx = &this_rq->scx;
if ((cpu_online(cpu) || cpu == cpu_of(this_rq)) &&
static void kick_one_cpu_if_idle(s32 cpu, struct rq *this_rq)
(cpu_online(cpu) || cpu == cpu_of(this_rq)))
struct rq *this_rq = this_rq();
struct scx_rq *this_scx = &this_rq->scx;
should_wait |= kick_one_cpu(cpu, this_rq, ksyncs);
kick_one_cpu_if_idle(cpu, this_rq);
raw_spin_rq_lock(this_rq);
resched_curr(this_rq);
raw_spin_rq_unlock(this_rq);
struct rq *this_rq, *src_rq, *locked_rq;
this_rq = this_rq();
in_balance = this_rq->scx.flags & SCX_RQ_IN_BALANCE;
if (this_rq != src_rq) {
raw_spin_rq_unlock(this_rq);
dst_dsq = find_dsq_for_dispatch(sch, this_rq, dsq_id, p);
if (this_rq != locked_rq) {
raw_spin_rq_lock(this_rq);
struct rq *this_rq;
this_rq = this_rq();
if (scx_rq_bypassing(this_rq))
cpumask_set_cpu(cpu, this_rq->scx.cpus_to_kick_if_idle);
cpumask_set_cpu(cpu, this_rq->scx.cpus_to_kick);
cpumask_set_cpu(cpu, this_rq->scx.cpus_to_preempt);
cpumask_set_cpu(cpu, this_rq->scx.cpus_to_wait);
irq_work_queue(&this_rq->scx.kick_cpus_irq_work);
ret = READ_ONCE(this_rq()->scx.local_dsq.nr);
rq = this_rq();
rq = this_rq();
static int sched_balance_rq(int this_cpu, struct rq *this_rq,
.dst_rq = this_rq,
WARN_ON_ONCE(rq != this_rq());
static void _nohz_idle_balance(struct rq *this_rq, unsigned int flags)
int this_cpu = this_rq->cpu;
static bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
unsigned int flags = this_rq->nohz_idle_balance;
this_rq->nohz_idle_balance = 0;
_nohz_idle_balance(this_rq, flags);
static void nohz_newidle_balance(struct rq *this_rq)
int this_cpu = this_rq->cpu;
if (this_rq->avg_idle < sysctl_sched_migration_cost)
static inline bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
static inline void nohz_newidle_balance(struct rq *this_rq) { }
static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
__must_hold(__rq_lockp(this_rq))
int this_cpu = this_rq->cpu;
update_misfit_status(NULL, this_rq);
if (this_rq->ttwu_pending)
this_rq->idle_stamp = rq_clock(this_rq);
rq_unpin_lock(this_rq, rf);
sd = rcu_dereference_sched_domain(this_rq->sd);
if (!get_rd_overloaded(this_rq->rd) ||
this_rq->avg_idle < sd->max_newidle_lb_cost) {
__sched_balance_update_blocked_averages(this_rq);
rq_modified_begin(this_rq, &fair_sched_class);
raw_spin_rq_unlock(this_rq);
if (this_rq->avg_idle < curr_cost + sd->max_newidle_lb_cost)
pulled_task = sched_balance_rq(this_cpu, this_rq,
raw_spin_rq_lock(this_rq);
if (curr_cost > this_rq->max_idle_balance_cost)
this_rq->max_idle_balance_cost = curr_cost;
if (this_rq->cfs.h_nr_queued && !pulled_task)
if (rq_modified_above(this_rq, &fair_sched_class))
if (time_after(this_rq->next_balance, next_balance))
this_rq->next_balance = next_balance;
this_rq->idle_stamp = 0;
nohz_newidle_balance(this_rq);
rq_repin_lock(this_rq, rf);
struct rq *this_rq = this_rq();
enum cpu_idle_type idle = this_rq->idle_balance;
if (nohz_idle_balance(this_rq, idle))
sched_balance_update_blocked_averages(this_rq->cpu);
sched_balance_domains(this_rq, idle);
static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
__must_hold(__rq_lockp(this_rq));
if (rq == this_rq()) {
this_rq()->nr_running <= 1 &&
struct root_domain *rd = this_rq()->rd;
if (!is_rd_overutilized(this_rq()->rd)) {
idle_set_state(this_rq(), idle_state);
calc_load_nohz_fold(this_rq());
struct rq *this_rq = this_rq();
this_rq->calc_load_update = READ_ONCE(calc_load_update);
if (time_before(jiffies, this_rq->calc_load_update))
if (time_before(jiffies, this_rq->calc_load_update + 10))
this_rq->calc_load_update += LOAD_FREQ;
void calc_global_load_tick(struct rq *this_rq)
if (time_before(jiffies, this_rq->calc_load_update))
delta = calc_load_fold_active(this_rq, 0);
this_rq->calc_load_update += LOAD_FREQ;
long calc_load_fold_active(struct rq *this_rq, long adjust)
nr_active = this_rq->nr_running - adjust;
nr_active += (long)this_rq->nr_uninterruptible;
if (nr_active != this_rq->calc_load_active) {
delta = nr_active - this_rq->calc_load_active;
this_rq->calc_load_active = nr_active;
struct rq *rq = this_rq();
rq = this_rq();
static void pull_rt_task(struct rq *this_rq)
int this_cpu = this_rq->cpu, cpu;
int rt_overload_count = rt_overloaded(this_rq);
cpumask_test_cpu(this_rq->cpu, this_rq->rd->rto_mask))
tell_cpu_to_push(this_rq);
for_each_cpu(cpu, this_rq->rd->rto_mask) {
this_rq->rt.highest_prio.curr)
double_lock_balance(this_rq, src_rq);
if (p && (p->prio < this_rq->rt.highest_prio.curr)) {
move_queued_task_locked(src_rq, this_rq, p);
double_unlock_balance(this_rq, src_rq);
raw_spin_rq_unlock(this_rq);
raw_spin_rq_lock(this_rq);
resched_curr(this_rq);
return this_rq()->rd->span;
extern void calc_global_load_tick(struct rq *this_rq);
extern long calc_load_fold_active(struct rq *this_rq, long adjust);
rq = this_rq();
void (*task_woken)(struct rq *this_rq, struct task_struct *task);
void (*switching_from)(struct rq *this_rq, struct task_struct *task);
void (*switched_from) (struct rq *this_rq, struct task_struct *task);
void (*switching_to) (struct rq *this_rq, struct task_struct *task);
void (*switched_to) (struct rq *this_rq, struct task_struct *task);
u64 (*get_prio) (struct rq *this_rq, struct task_struct *task);
void (*prio_changed) (struct rq *this_rq, struct task_struct *task,
void (*reweight_task)(struct rq *this_rq, struct task_struct *task,
static inline int _double_lock_balance(struct rq *this_rq, struct rq *busiest)
__must_hold(__rq_lockp(this_rq))
raw_spin_rq_unlock(this_rq);
double_rq_lock(this_rq, busiest);
static inline int _double_lock_balance(struct rq *this_rq, struct rq *busiest)
__must_hold(__rq_lockp(this_rq))
if (__rq_lockp(this_rq) == __rq_lockp(busiest)) {
double_rq_clock_clear_update(this_rq, busiest);
double_rq_clock_clear_update(this_rq, busiest);
if (rq_order_less(this_rq, busiest)) {
double_rq_clock_clear_update(this_rq, busiest);
raw_spin_rq_unlock(this_rq);
double_rq_lock(this_rq, busiest);
static inline int double_lock_balance(struct rq *this_rq, struct rq *busiest)
__must_hold(__rq_lockp(this_rq))
return _double_lock_balance(this_rq, busiest);
static inline void double_unlock_balance(struct rq *this_rq, struct rq *busiest)
if (__rq_lockp(this_rq) != __rq_lockp(busiest))
lock_set_subclass(&__rq_lockp(this_rq)->dep_map, 0, _RET_IP_);
rq = this_rq();
int BPF_PROG(fentry_fentry, int this_cpu, struct rq *this_rq,