Re: [PATCH 1/1] sched/fair:Reduce unnecessary check preempt in the sched tick

From: jun qian
Date: Tue Apr 13 2021 - 22:10:38 EST


Peter Zijlstra <peterz@xxxxxxxxxxxxx> 于2021年4月13日周二 下午10:24写道:
>
> On Tue, Apr 13, 2021 at 09:18:42PM +0800, qianjun.kernel@xxxxxxxxx wrote:
> > From: jun qian <qianjun.kernel@xxxxxxxxx>
> >
> > If it has been determined that the current cpu need resched in the
> > early stage of for_each_sched_entity, then there is no need to check
> > preempt in the subsequent se->parent entity_tick.
>
> Right, but does it actually do anything, except increase linecount?
>
> > Signed-off-by: jun qian <qianjun.kernel@xxxxxxxxx>
> > ---
> > kernel/sched/fair.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 1a68a0536add..c0d135100d54 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -4352,8 +4352,13 @@ 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;
> >
> > + /* If the TIF_NEED_RESCHED has been set, it is no need to check again */
> > + if (test_tsk_need_resched(rq->curr))
> > + return;
> > +
> > ideal_runtime = sched_slice(cfs_rq, curr);
> > delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
> > if (delta_exec > ideal_runtime) {
>
> Also, I think that's placed wrong; this way we can mis clear_buddies().

thanks, i will modify it in the next version