* [PATCH V2 1/1] sched/fair:Reduce unnecessary check preempt in the sched tick
@ 2021-04-14 2:22 qianjun.kernel
2021-04-14 7:12 ` Peter Zijlstra
0 siblings, 1 reply; 2+ messages in thread
From: qianjun.kernel @ 2021-04-14 2:22 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, bristot
Cc: linux-kernel, jun qian
From: jun qian <qianjun.kernel@gmail.com>
As you are already set the TIF_NEED_RESCHED, there is no need
to check resched again.
Signed-off-by: jun qian <qianjun.kernel@gmail.com>
---
kernel/sched/fair.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 794c2cb945f8..1a69b5fffe4a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4360,19 +4360,26 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
{
unsigned long ideal_runtime, delta_exec;
struct sched_entity *se;
+ struct rq *rq = rq_of(cfs_rq);
s64 delta;
ideal_runtime = sched_slice(cfs_rq, curr);
delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
if (delta_exec > ideal_runtime) {
- resched_curr(rq_of(cfs_rq));
+ if (!test_tsk_need_resched(rq->curr))
+ resched_curr(rq_of(cfs_rq));
/*
* The current task ran long enough, ensure it doesn't get
* re-elected due to buddy favours.
*/
clear_buddies(cfs_rq, curr);
return;
- }
+ /*
+ * If here with TIF_NEED_RESCHED already set from the early entity_tick,
+ * there is no need to check again.
+ */
+ } else if (test_tsk_need_resched(rq->curr))
+ return;
/*
* Ensure that a task that missed wakeup preemption by a
--
2.18.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH V2 1/1] sched/fair:Reduce unnecessary check preempt in the sched tick
2021-04-14 2:22 [PATCH V2 1/1] sched/fair:Reduce unnecessary check preempt in the sched tick qianjun.kernel
@ 2021-04-14 7:12 ` Peter Zijlstra
0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2021-04-14 7:12 UTC (permalink / raw)
To: qianjun.kernel
Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
bsegall, mgorman, bristot, linux-kernel
On Wed, Apr 14, 2021 at 10:22:29AM +0800, qianjun.kernel@gmail.com wrote:
> From: jun qian <qianjun.kernel@gmail.com>
>
> As you are already set the TIF_NEED_RESCHED, there is no need
> to check resched again.
Still no justification; does this actually help anything?
> Signed-off-by: jun qian <qianjun.kernel@gmail.com>
> ---
> kernel/sched/fair.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 794c2cb945f8..1a69b5fffe4a 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -4360,19 +4360,26 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
> {
> unsigned long ideal_runtime, delta_exec;
> struct sched_entity *se;
> + struct rq *rq = rq_of(cfs_rq);
> s64 delta;
>
> ideal_runtime = sched_slice(cfs_rq, curr);
> delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
> if (delta_exec > ideal_runtime) {
> - resched_curr(rq_of(cfs_rq));
> + if (!test_tsk_need_resched(rq->curr))
> + resched_curr(rq_of(cfs_rq));
> /*
> * The current task ran long enough, ensure it doesn't get
> * re-elected due to buddy favours.
> */
> clear_buddies(cfs_rq, curr);
> return;
> - }
> + /*
> + * If here with TIF_NEED_RESCHED already set from the early entity_tick,
> + * there is no need to check again.
> + */
> + } else if (test_tsk_need_resched(rq->curr))
> + return;
This is horrific style. And, afaict, completely unnecessary.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-14 7:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14 2:22 [PATCH V2 1/1] sched/fair:Reduce unnecessary check preempt in the sched tick qianjun.kernel
2021-04-14 7:12 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).