* [PATCH] sched/deadline: Add should_push_task_away helper
@ 2022-08-29 10:05 Shang XiaoJing
2022-08-31 9:23 ` Daniel Bristot de Oliveira
0 siblings, 1 reply; 3+ messages in thread
From: Shang XiaoJing @ 2022-08-29 10:05 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, bristot, vschneid, linux-kernel
Cc: shangxiaojing
Wrap complex and repeated code in helper function should_push_task_away,
which will return true when task b should be pushed to other cores
because of task a.
Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
---
kernel/sched/deadline.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index daa9a7fb5917..8e14dc21d829 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1814,6 +1814,15 @@ static void yield_task_dl(struct rq *rq)
#ifdef CONFIG_SMP
+static inline bool should_push_task_away(struct task_struct *a,
+ struct task_struct *b)
+{
+ return unlikely(dl_task(a)) &&
+ (a->nr_cpus_allowed < 2 ||
+ !dl_entity_preempt(&b->dl, &a->dl)) &&
+ b->nr_cpus_allowed > 1;
+}
+
static int find_later_rq(struct task_struct *task);
static int
@@ -1840,10 +1849,7 @@ select_task_rq_dl(struct task_struct *p, int cpu, int flags)
* other hand, if it has a shorter deadline, we
* try to make it stay here, it might be important.
*/
- select_rq = unlikely(dl_task(curr)) &&
- (curr->nr_cpus_allowed < 2 ||
- !dl_entity_preempt(&p->dl, &curr->dl)) &&
- p->nr_cpus_allowed > 1;
+ select_rq = should_push_task_away(curr, p);
/*
* Take the capacity of the CPU into account to
@@ -2477,10 +2483,7 @@ static void task_woken_dl(struct rq *rq, struct task_struct *p)
{
if (!task_running(rq, p) &&
!test_tsk_need_resched(rq->curr) &&
- p->nr_cpus_allowed > 1 &&
- dl_task(rq->curr) &&
- (rq->curr->nr_cpus_allowed < 2 ||
- !dl_entity_preempt(&p->dl, &rq->curr->dl))) {
+ should_push_task_away(rq->curr, p)) {
push_dl_tasks(rq);
}
}
--
2.17.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] sched/deadline: Add should_push_task_away helper
2022-08-29 10:05 [PATCH] sched/deadline: Add should_push_task_away helper Shang XiaoJing
@ 2022-08-31 9:23 ` Daniel Bristot de Oliveira
2022-08-31 9:30 ` shangxiaojing
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Bristot de Oliveira @ 2022-08-31 9:23 UTC (permalink / raw)
To: Shang XiaoJing, mingo, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
linux-kernel
On 8/29/22 12:05, Shang XiaoJing wrote:
> +static inline bool should_push_task_away(struct task_struct *a,
> + struct task_struct *b)
static inline bool should_push_task_dl(struct task_struct *curr, struct task_struct *p)
a and b are not good variable names, and add the _dl suffix (instead of away).
> +{
> + return unlikely(dl_task(a)) &&
> + (a->nr_cpus_allowed < 2 ||
> + !dl_entity_preempt(&b->dl, &a->dl)) &&
> + b->nr_cpus_allowed > 1;
> +}
> +
-- Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] sched/deadline: Add should_push_task_away helper
2022-08-31 9:23 ` Daniel Bristot de Oliveira
@ 2022-08-31 9:30 ` shangxiaojing
0 siblings, 0 replies; 3+ messages in thread
From: shangxiaojing @ 2022-08-31 9:30 UTC (permalink / raw)
To: Daniel Bristot de Oliveira, mingo, peterz, juri.lelli,
vincent.guittot, dietmar.eggemann, rostedt, bsegall, mgorman,
vschneid, linux-kernel
On 2022/8/31 17:23, Daniel Bristot de Oliveira wrote:
> On 8/29/22 12:05, Shang XiaoJing wrote:
>> +static inline bool should_push_task_away(struct task_struct *a,
>> + struct task_struct *b)
> static inline bool should_push_task_dl(struct task_struct *curr, struct task_struct *p)
>
> a and b are not good variable names, and add the _dl suffix (instead of away).
ok, i like that :-). This will be done in patch v2.
>> +{
>> + return unlikely(dl_task(a)) &&
>> + (a->nr_cpus_allowed < 2 ||
>> + !dl_entity_preempt(&b->dl, &a->dl)) &&
>> + b->nr_cpus_allowed > 1;
>> +}
>> +
> -- Daniel
Thanks,
Shang XiaoJing
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-31 9:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-29 10:05 [PATCH] sched/deadline: Add should_push_task_away helper Shang XiaoJing
2022-08-31 9:23 ` Daniel Bristot de Oliveira
2022-08-31 9:30 ` shangxiaojing
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®