Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752598Ab3EFD0T (ORCPT ); Sun, 5 May 2013 23:26:19 -0400 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:42125 "EHLO e28smtp08.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752135Ab3EFD0S (ORCPT ); Sun, 5 May 2013 23:26:18 -0400 Message-ID: <5187226C.3000509@linux.vnet.ibm.com> Date: Mon, 06 May 2013 08:54:28 +0530 From: Preeti U Murthy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Alex Shi CC: mingo@redhat.com, peterz@infradead.org, tglx@linutronix.de, akpm@linux-foundation.org, arjan@linux.intel.com, bp@alien8.de, pjt@google.com, namhyung@kernel.org, efault@gmx.de, morten.rasmussen@arm.com, vincent.guittot@linaro.org, gregkh@linuxfoundation.org, viresh.kumar@linaro.org, linux-kernel@vger.kernel.org, len.brown@intel.com, rafael.j.wysocki@intel.com, jkosina@suse.cz, clark.williams@gmail.com, tony.luck@intel.com, keescook@chromium.org, mgorman@suse.de, riel@redhat.com Subject: Re: [patch v7 02/21] sched: set initial value of runnable avg for new forked task References: <1365040862-8390-1-git-send-email-alex.shi@intel.com> <1365040862-8390-3-git-send-email-alex.shi@intel.com> In-Reply-To: <1365040862-8390-3-git-send-email-alex.shi@intel.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050603-2000-0000-0000-00000BFC83B7 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2480 Lines: 77 Hi Alex, The below patch looks good to me. On 04/04/2013 07:30 AM, 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 > --- > 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 54eaaa2..8843cd3 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -1564,6 +1564,7 @@ static void __sched_fork(struct task_struct *p) > #ifdef CONFIG_SMP > p->se.avg.runnable_avg_period = 0; > p->se.avg.runnable_avg_sum = 0; > + p->se.avg.decay_count = 0; > #endif > #ifdef CONFIG_SCHEDSTATS > memset(&p->se.statistics, 0, sizeof(p->se.statistics)); > @@ -1651,6 +1652,11 @@ void sched_fork(struct task_struct *p) > p->sched_reset_on_fork = 0; > } > > + /* New forked task assumed with full utilization */ > +#if defined(CONFIG_SMP) > + p->se.avg.load_avg_contrib = p->se.load.weight; > +#endif > + > if (!rt_prio(p->prio)) > p->sched_class = &fair_sched_class; > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 9c2f726..2881d42 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -1508,6 +1508,10 @@ static inline void enqueue_entity_load_avg(struct cfs_rq *cfs_rq, > * We track migrations using entity decay_count <= 0, on a wake-up > * migration we use a negative decay count to track the remote decays > * accumulated while sleeping. > + * > + * When enqueue a new forked task, the se->avg.decay_count == 0, so > + * we bypass update_entity_load_avg(), use avg.load_avg_contrib initial > + * value: se->load.weight. > */ > if (unlikely(se->avg.decay_count <= 0)) { > se->avg.last_runnable_update = rq_of(cfs_rq)->clock_task; > Reviewed-by:Preeti U Murthy Thanks Regards Preeti U Murthy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/