Re: [PATCH] sched/fair: optimize entity_tick()

From: Peter Zijlstra
Date: Mon Jul 18 2022 - 06:10:44 EST


On Mon, Jul 18, 2022 at 05:49:37PM +0800, Peng Zhang wrote:
> From: "zhangpeng.00" <zhangpeng.00@xxxxxxxxxxxxx>
>
> entity_tick() will be called to check preemption by calculating each
> sched_entity's time_slice in a task group tree from bottom to top.
>
> If a need_resched_flag is set by a checking of a sched_entity,
> there is no necessary to check preemption of the sched_entity's
> parent and ancestor entity.
>
> So we can test if the need_resched_flag has been set before calling
> check_preempt_tick() to avoid unnecessary calculations.
>
> Signed-off-by: zhangpeng.00 <zhangpeng.00@xxxxxxxxxxxxx>

Optimization patches should come with numbers showing they're worth it.

Also; did you consider side-effects from check_preempt_tick(), like
clearing buddy state etc.. ?