Skip to content

Commit 18adad1

Browse files
cobrien7Peter Zijlstra
authored andcommitted
sched: Consolidate pick_*_task to task_is_pushable helper
This patch consolidates rt and deadline pick_*_task functions to a task_is_pushable() helper This patch was broken out from a larger chain migration patch originally by Connor O'Brien. [jstultz: split out from larger chain migration patch, renamed helper function] Signed-off-by: Connor O'Brien <[email protected]> Signed-off-by: John Stultz <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Metin Kaya <[email protected]> Reviewed-by: Valentin Schneider <[email protected]> Reviewed-by: Christian Loehle <[email protected]> Tested-by: K Prateek Nayak <[email protected]> Tested-by: Metin Kaya <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2b05a0b commit 18adad1

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

kernel/sched/deadline.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2487,14 +2487,6 @@ static void task_fork_dl(struct task_struct *p)
24872487
/* Only try algorithms three times */
24882488
#define DL_MAX_TRIES 3
24892489

2490-
static int pick_dl_task(struct rq *rq, struct task_struct *p, int cpu)
2491-
{
2492-
if (!task_on_cpu(rq, p) &&
2493-
cpumask_test_cpu(cpu, &p->cpus_mask))
2494-
return 1;
2495-
return 0;
2496-
}
2497-
24982490
/*
24992491
* Return the earliest pushable rq's task, which is suitable to be executed
25002492
* on the CPU, NULL otherwise:
@@ -2513,7 +2505,7 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu
25132505
if (next_node) {
25142506
p = __node_2_pdl(next_node);
25152507

2516-
if (pick_dl_task(rq, p, cpu))
2508+
if (task_is_pushable(rq, p, cpu))
25172509
return p;
25182510

25192511
next_node = rb_next(next_node);

kernel/sched/rt.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,15 +1773,6 @@ static void put_prev_task_rt(struct rq *rq, struct task_struct *p, struct task_s
17731773
/* Only try algorithms three times */
17741774
#define RT_MAX_TRIES 3
17751775

1776-
static int pick_rt_task(struct rq *rq, struct task_struct *p, int cpu)
1777-
{
1778-
if (!task_on_cpu(rq, p) &&
1779-
cpumask_test_cpu(cpu, &p->cpus_mask))
1780-
return 1;
1781-
1782-
return 0;
1783-
}
1784-
17851776
/*
17861777
* Return the highest pushable rq's task, which is suitable to be executed
17871778
* on the CPU, NULL otherwise
@@ -1795,7 +1786,7 @@ static struct task_struct *pick_highest_pushable_task(struct rq *rq, int cpu)
17951786
return NULL;
17961787

17971788
plist_for_each_entry(p, head, pushable_tasks) {
1798-
if (pick_rt_task(rq, p, cpu))
1789+
if (task_is_pushable(rq, p, cpu))
17991790
return p;
18001791
}
18011792

kernel/sched/sched.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3799,6 +3799,16 @@ void move_queued_task_locked(struct rq *src_rq, struct rq *dst_rq, struct task_s
37993799
set_task_cpu(task, dst_rq->cpu);
38003800
activate_task(dst_rq, task, 0);
38013801
}
3802+
3803+
static inline
3804+
bool task_is_pushable(struct rq *rq, struct task_struct *p, int cpu)
3805+
{
3806+
if (!task_on_cpu(rq, p) &&
3807+
cpumask_test_cpu(cpu, &p->cpus_mask))
3808+
return true;
3809+
3810+
return false;
3811+
}
38023812
#endif
38033813

38043814
#ifdef CONFIG_RT_MUTEXES

0 commit comments

Comments
 (0)