Skip to content

Commit b03fbd4

Browse files
author
Peter Zijlstra
committed
sched: Introduce task_is_running()
Replace a bunch of 'p->state == TASK_RUNNING' with a new helper: task_is_running(p). Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Davidlohr Bueso <dave@stgolabs.net> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20210611082838.222401495@infradead.org
1 parent 37aadc6 commit b03fbd4

33 files changed

Lines changed: 40 additions & 41 deletions

File tree

arch/alpha/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ get_wchan(struct task_struct *p)
380380
{
381381
unsigned long schedule_frame;
382382
unsigned long pc;
383-
if (!p || p == current || p->state == TASK_RUNNING)
383+
if (!p || p == current || task_is_running(p))
384384
return 0;
385385
/*
386386
* This one depends on the frame size of schedule(). Do a

arch/arc/kernel/stacktrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ seed_unwind_frame_info(struct task_struct *tsk, struct pt_regs *regs,
8383
* is safe-kept and BLINK at a well known location in there
8484
*/
8585

86-
if (tsk->state == TASK_RUNNING)
86+
if (task_is_running(tsk))
8787
return -1;
8888

8989
frame_info->task = tsk;

arch/arm/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ unsigned long get_wchan(struct task_struct *p)
288288
struct stackframe frame;
289289
unsigned long stack_page;
290290
int count = 0;
291-
if (!p || p == current || p->state == TASK_RUNNING)
291+
if (!p || p == current || task_is_running(p))
292292
return 0;
293293

294294
frame.fp = thread_saved_fp(p);

arch/arm64/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ unsigned long get_wchan(struct task_struct *p)
598598
struct stackframe frame;
599599
unsigned long stack_page, ret = 0;
600600
int count = 0;
601-
if (!p || p == current || p->state == TASK_RUNNING)
601+
if (!p || p == current || task_is_running(p))
602602
return 0;
603603

604604
stack_page = (unsigned long)try_get_task_stack(p);

arch/csky/kernel/stacktrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ unsigned long get_wchan(struct task_struct *task)
115115
{
116116
unsigned long pc = 0;
117117

118-
if (likely(task && task != current && task->state != TASK_RUNNING))
118+
if (likely(task && task != current && !task_is_running(task)))
119119
walk_stackframe(task, NULL, save_wchan, &pc);
120120
return pc;
121121
}

arch/h8300/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ unsigned long get_wchan(struct task_struct *p)
134134
unsigned long stack_page;
135135
int count = 0;
136136

137-
if (!p || p == current || p->state == TASK_RUNNING)
137+
if (!p || p == current || task_is_running(p))
138138
return 0;
139139

140140
stack_page = (unsigned long)p;

arch/hexagon/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ unsigned long get_wchan(struct task_struct *p)
135135
unsigned long fp, pc;
136136
unsigned long stack_page;
137137
int count = 0;
138-
if (!p || p == current || p->state == TASK_RUNNING)
138+
if (!p || p == current || task_is_running(p))
139139
return 0;
140140

141141
stack_page = (unsigned long)task_stack_page(p);

arch/ia64/kernel/process.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ get_wchan (struct task_struct *p)
529529
unsigned long ip;
530530
int count = 0;
531531

532-
if (!p || p == current || p->state == TASK_RUNNING)
532+
if (!p || p == current || task_is_running(p))
533533
return 0;
534534

535535
/*
@@ -542,7 +542,7 @@ get_wchan (struct task_struct *p)
542542
*/
543543
unw_init_from_blocked_task(&info, p);
544544
do {
545-
if (p->state == TASK_RUNNING)
545+
if (task_is_running(p))
546546
return 0;
547547
if (unw_unwind(&info) < 0)
548548
return 0;

arch/m68k/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ unsigned long get_wchan(struct task_struct *p)
268268
unsigned long fp, pc;
269269
unsigned long stack_page;
270270
int count = 0;
271-
if (!p || p == current || p->state == TASK_RUNNING)
271+
if (!p || p == current || task_is_running(p))
272272
return 0;
273273

274274
stack_page = (unsigned long)task_stack_page(p);

arch/mips/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ unsigned long get_wchan(struct task_struct *task)
662662
unsigned long ra = 0;
663663
#endif
664664

665-
if (!task || task == current || task->state == TASK_RUNNING)
665+
if (!task || task == current || task_is_running(task))
666666
goto out;
667667
if (!task_stack_page(task))
668668
goto out;

0 commit comments

Comments
 (0)