From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754164AbbBTLOU (ORCPT ); Fri, 20 Feb 2015 06:14:20 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:55095 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753999AbbBTLOT (ORCPT ); Fri, 20 Feb 2015 06:14:19 -0500 Date: Fri, 20 Feb 2015 12:14:04 +0100 From: Peter Zijlstra To: Vincent Guittot Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, preeti@linux.vnet.ibm.com, Morten.Rasmussen@arm.com, kamalesh@linux.vnet.ibm.com, riel@redhat.com, efault@gmx.de, nicolas.pitre@linaro.org, dietmar.eggemann@arm.com, linaro-kernel@lists.linaro.org Subject: Re: [PATCH RESEND v9 08/10] sched: replace capacity_factor by usage Message-ID: <20150220111404.GM5029@twins.programming.kicks-ass.net> References: <1421316570-23097-1-git-send-email-vincent.guittot@linaro.org> <1421316570-23097-9-git-send-email-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1421316570-23097-9-git-send-email-vincent.guittot@linaro.org> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 15, 2015 at 11:09:28AM +0100, Vincent Guittot wrote: > Finally, the sched_group->sched_group_capacity->capacity_orig has been removed > because it's no more used during load balance. Maybe do that in a separate patch to avoid cluttering this one? > [1] https://lkml.org/lkml/2014/8/12/295 Patch references are like: 9a5d9ba6a363 ("sched/fair: Allow calculate_imbalance() to move idle cpus") > /* > + * Check whether the capacity of the rq has been noticeably reduced by side > + * activity. The imbalance_pct is used for the threshold. > + * Return true is the capacity is reduced > */ > static inline int > +check_cpu_capacity(struct rq *rq, struct sched_domain *sd) > { > + return ((rq->cpu_capacity * sd->imbalance_pct) < > + (rq->cpu_capacity_orig * 100)); > } How about cpu_has_capacity() to be consistent with the below function? This comment could use whitespace: > /* > + * group_has_capacity returns true if the group has spare capacity that could > + * be used by some tasks. We consider that a group has spare capacity if the > + * number of task is smaller than the number of CPUs or if the usage is lower > + * than the available capacity for CFS tasks. For the latter, we use a > + * threshold to stabilize the state, to take into account the variance of the > + * tasks' load and to return true if the available capacity in meaningful for > + * the load balancer. As an example, an available capacity of 1% can appear > + * but it doesn't make any benefit for the load balance. > */ > +static inline bool > +group_has_capacity(struct lb_env *env, struct sg_lb_stats *sgs) > { > + if ((sgs->group_capacity * 100) > > + (sgs->group_usage * env->sd->imbalance_pct)) > + return true; > > + if (sgs->sum_nr_running < sgs->group_weight) > + return true; > + > + return false; > +} Would it not make sense to first do the nr_running test, its cheaper than the multiplication thing. > +/* > + * group_is_overloaded returns true if the group has more tasks than it can > + * handle. We consider that a group is overloaded if the number of tasks is > + * greater than the number of CPUs and the tasks already use all available > + * capacity for CFS tasks. For the latter, we use a threshold to stabilize > + * the state, to take into account the variance of tasks' load and to return > + * true if available capacity is no more meaningful for load balancer > + */ > +static inline bool > +group_is_overloaded(struct lb_env *env, struct sg_lb_stats *sgs) > +{ > + if (sgs->sum_nr_running <= sgs->group_weight) > + return false; > > + if ((sgs->group_capacity * 100) < > + (sgs->group_usage * env->sd->imbalance_pct)) > + return true; > > + return false; > } Maybe a note on the difference between group_is_overloaded() and !group_has_capacity()? As to the comment, I think it can be reduced by referring to the comment of group_has_capacity(). > /* > * In case the child domain prefers tasks go to siblings > + * first, lower the sg capacity so that we'll try > * and move all the excess tasks away. We lower the capacity > * of a group only if the local group has the capacity to fit > + * these excess tasks. The extra check prevents the case where > + * you always pull from the heaviest group when it is already > + * under-utilized (possible with a large weight task outweighs > + * the tasks on the system). > */ > if (prefer_sibling && sds->local && > + group_has_capacity(env, &sds->local_stat) && > + (sgs->sum_nr_running > 1)) { > + sgs->group_no_capacity = 1; > + sgs->group_type = group_overloaded; > + } Looks OK otherwise I suppose.