Re: [PATCH v4 2/6] sched: set initial value of runnable avg for new forked task

Peter Zijlstra
2013-05-02T11:02:54Z

On Sat, Apr 27, 2013 at 01:25:40PM +0800, Alex Shi wrote:
> We need initialize the se.avg.{decay_count, load_avg_contrib} for a
> new forked task.
> Otherwise random values of above variables cause mess when do new task
> enqueue:
> enqueue_task_fair
> enqueue_entity
> enqueue_entity_load_avg
>
> and make forking balancing imbalance since incorrect load_avg_contrib.
>
> set avg.decay_count = 0, and avg.load_avg_contrib = se->load.weight to
> resolve such issues.
>
> Signed-off-by: Alex Shi <alex.shi@intel.com>

This patch seems sensible enough..

Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

> ---
> kernel/sched/core.c | 6 ++++++
> kernel/sched/fair.c | 4 ++++
> 2 files changed, 10 insertions(+)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 86e87f1..e0c003a 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c

> + /* New forked task assumed with full utilization */
> +#if defined(CONFIG_SMP)
> + p->se.avg.load_avg_contrib = p->se.load.weight;
> +#endif

We'd typically write: #ifdef CONFIG_SMP
we only use the #if defined() form for multiple CONFIG tests.