Skip to content

Commit 0b9d46f

Browse files
author
Peter Zijlstra
committed
sched: Rename task_running() to task_on_cpu()
There is some ambiguity about task_running() in that it is unrelated to TASK_RUNNING but instead tests ->on_cpu. As such, rename the thing task_on_cpu(). Suggested-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/Yxhkhn55uHZx+NGl@hirez.programming.kicks-ass.net
1 parent 96c1c0c commit 0b9d46f

6 files changed

Lines changed: 14 additions & 14 deletions

File tree

kernel/sched/core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,7 +2777,7 @@ static int affine_move_task(struct rq *rq, struct task_struct *p, struct rq_flag
27772777
return -EINVAL;
27782778
}
27792779

2780-
if (task_running(rq, p) || READ_ONCE(p->__state) == TASK_WAKING) {
2780+
if (task_on_cpu(rq, p) || READ_ONCE(p->__state) == TASK_WAKING) {
27812781
/*
27822782
* MIGRATE_ENABLE gets here because 'p == current', but for
27832783
* anything else we cannot do is_migration_disabled(), punt
@@ -3289,11 +3289,11 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
32893289
*
32903290
* NOTE! Since we don't hold any locks, it's not
32913291
* even sure that "rq" stays as the right runqueue!
3292-
* But we don't care, since "task_running()" will
3292+
* But we don't care, since "task_on_cpu()" will
32933293
* return false if the runqueue has changed and p
32943294
* is actually now running somewhere else!
32953295
*/
3296-
while (task_running(rq, p)) {
3296+
while (task_on_cpu(rq, p)) {
32973297
if (match_state && unlikely(READ_ONCE(p->__state) != match_state))
32983298
return 0;
32993299
cpu_relax();
@@ -3306,7 +3306,7 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
33063306
*/
33073307
rq = task_rq_lock(p, &rf);
33083308
trace_sched_wait_task(p);
3309-
running = task_running(rq, p);
3309+
running = task_on_cpu(rq, p);
33103310
queued = task_on_rq_queued(p);
33113311
ncsw = 0;
33123312
if (!match_state || READ_ONCE(p->__state) == match_state)
@@ -8648,7 +8648,7 @@ int __sched yield_to(struct task_struct *p, bool preempt)
86488648
if (curr->sched_class != p->sched_class)
86498649
goto out_unlock;
86508650

8651-
if (task_running(p_rq, p) || !task_is_running(p))
8651+
if (task_on_cpu(p_rq, p) || !task_is_running(p))
86528652
goto out_unlock;
86538653

86548654
yielded = curr->sched_class->yield_to_task(rq, p);

kernel/sched/core_sched.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static unsigned long sched_core_update_cookie(struct task_struct *p,
8888
* core has now entered/left forced idle state. Defer accounting to the
8989
* next scheduling edge, rather than always forcing a reschedule here.
9090
*/
91-
if (task_running(rq, p))
91+
if (task_on_cpu(rq, p))
9292
resched_curr(rq);
9393

9494
task_rq_unlock(rq, p, &rf);

kernel/sched/deadline.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ static void task_fork_dl(struct task_struct *p)
20922092

20932093
static int pick_dl_task(struct rq *rq, struct task_struct *p, int cpu)
20942094
{
2095-
if (!task_running(rq, p) &&
2095+
if (!task_on_cpu(rq, p) &&
20962096
cpumask_test_cpu(cpu, &p->cpus_mask))
20972097
return 1;
20982098
return 0;
@@ -2244,7 +2244,7 @@ static struct rq *find_lock_later_rq(struct task_struct *task, struct rq *rq)
22442244
if (double_lock_balance(rq, later_rq)) {
22452245
if (unlikely(task_rq(task) != rq ||
22462246
!cpumask_test_cpu(later_rq->cpu, &task->cpus_mask) ||
2247-
task_running(rq, task) ||
2247+
task_on_cpu(rq, task) ||
22482248
!dl_task(task) ||
22492249
!task_on_rq_queued(task))) {
22502250
double_unlock_balance(rq, later_rq);
@@ -2474,7 +2474,7 @@ static void pull_dl_task(struct rq *this_rq)
24742474
*/
24752475
static void task_woken_dl(struct rq *rq, struct task_struct *p)
24762476
{
2477-
if (!task_running(rq, p) &&
2477+
if (!task_on_cpu(rq, p) &&
24782478
!test_tsk_need_resched(rq->curr) &&
24792479
p->nr_cpus_allowed > 1 &&
24802480
dl_task(rq->curr) &&

kernel/sched/fair.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7935,7 +7935,7 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
79357935
/* Record that we found at least one task that could run on dst_cpu */
79367936
env->flags &= ~LBF_ALL_PINNED;
79377937

7938-
if (task_running(env->src_rq, p)) {
7938+
if (task_on_cpu(env->src_rq, p)) {
79397939
schedstat_inc(p->stats.nr_failed_migrations_running);
79407940
return 0;
79417941
}

kernel/sched/rt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,7 +1845,7 @@ static void put_prev_task_rt(struct rq *rq, struct task_struct *p)
18451845

18461846
static int pick_rt_task(struct rq *rq, struct task_struct *p, int cpu)
18471847
{
1848-
if (!task_running(rq, p) &&
1848+
if (!task_on_cpu(rq, p) &&
18491849
cpumask_test_cpu(cpu, &p->cpus_mask))
18501850
return 1;
18511851

@@ -2000,7 +2000,7 @@ static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq)
20002000
*/
20012001
if (unlikely(task_rq(task) != rq ||
20022002
!cpumask_test_cpu(lowest_rq->cpu, &task->cpus_mask) ||
2003-
task_running(rq, task) ||
2003+
task_on_cpu(rq, task) ||
20042004
!rt_task(task) ||
20052005
!task_on_rq_queued(task))) {
20062006

@@ -2458,7 +2458,7 @@ static void pull_rt_task(struct rq *this_rq)
24582458
*/
24592459
static void task_woken_rt(struct rq *rq, struct task_struct *p)
24602460
{
2461-
bool need_to_push = !task_running(rq, p) &&
2461+
bool need_to_push = !task_on_cpu(rq, p) &&
24622462
!test_tsk_need_resched(rq->curr) &&
24632463
p->nr_cpus_allowed > 1 &&
24642464
(dl_task(rq->curr) || rt_task(rq->curr)) &&

kernel/sched/sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,7 @@ static inline int task_current(struct rq *rq, struct task_struct *p)
20512051
return rq->curr == p;
20522052
}
20532053

2054-
static inline int task_running(struct rq *rq, struct task_struct *p)
2054+
static inline int task_on_cpu(struct rq *rq, struct task_struct *p)
20552055
{
20562056
#ifdef CONFIG_SMP
20572057
return p->on_cpu;

0 commit comments

Comments
 (0)