From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 050B3C433B4 for ; Thu, 6 May 2021 04:27:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD26061176 for ; Thu, 6 May 2021 04:27:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232853AbhEFE2N (ORCPT ); Thu, 6 May 2021 00:28:13 -0400 Received: from mga01.intel.com ([192.55.52.88]:31222 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbhEFE2L (ORCPT ); Thu, 6 May 2021 00:28:11 -0400 IronPort-SDR: 5vde3BUTY7/SV8j4SJuhNjAucOypDkPjeJx6bSkrhmheh6G1l7QCdgfJW0FtdVwOHDo87fd3/O e7xgLE3rDyOA== X-IronPort-AV: E=McAfee;i="6200,9189,9975"; a="219249618" X-IronPort-AV: E=Sophos;i="5.82,276,1613462400"; d="scan'208";a="219249618" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2021 21:27:11 -0700 IronPort-SDR: bn4SsDTv6RX2r2OpyNL9PZVdTWdMpYaMnRnMf/Z6XUf6u1SL+0dtUWDewQWoUBhQFlk5F5u3Cs 4cLLnnlQuxMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,276,1613462400"; d="scan'208";a="430313274" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmsmga008.fm.intel.com with ESMTP; 05 May 2021 21:27:11 -0700 Date: Wed, 5 May 2021 21:26:27 -0700 From: Ricardo Neri To: Peter Zijlstra Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Len Brown , Srinivas Pandruvada , Tim Chen , Aubrey Li , "Ravi V. Shankar" , Ricardo Neri , Quentin Perret , "Joel Fernandes (Google)" , linux-kernel@vger.kernel.org, Aubrey Li , Ben Segall , Daniel Bristot de Oliveira Subject: Re: [PATCH v2 3/4] sched/fair: Consider SMT in ASYM_PACKING load balance Message-ID: <20210506042627.GA3388@ranerica-svr.sc.intel.com> References: <20210414020436.12980-1-ricardo.neri-calderon@linux.intel.com> <20210414020436.12980-4-ricardo.neri-calderon@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 03, 2021 at 12:23:36PM +0200, Peter Zijlstra wrote: > On Mon, May 03, 2021 at 12:02:49PM +0200, Peter Zijlstra wrote: > > On Tue, Apr 13, 2021 at 07:04:35PM -0700, Ricardo Neri wrote: > > > @@ -8507,6 +8616,18 @@ static bool update_sd_pick_busiest(struct lb_env *env, > > > if (!sgs->sum_h_nr_running) > > > return false; > > > > > > + /* > > > + * @sg may have been tentatively classified as group_asym_packing. > > > + * Now that we have sufficient information about @sds.local, reassess > > > + * if asym packing migration can be done. Reclassify @sg. The only > > > + * possible results are group_has_spare and group_fully_busy. > > > + */ > > > + if (sgs->group_type == group_asym_packing && > > > + !asym_can_pull_tasks(env->dst_cpu, sds, sgs, sg)) { > > > + sgs->group_asym_packing = 0; > > > + sgs->group_type = group_classify(env->sd->imbalance_pct, sg, sgs); > > > + } > > > > So if this really is all about not having sds.local in > > update_sd_lb_stats(), then that seems fixable. Let me haz a try. > > How's this then? > > --- > kernel/sched/fair.c | 25 ++++++++++++++++++++----- > 1 file changed, 20 insertions(+), 5 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 3bdc41f22909..e9dcbee5b3d9 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -8437,6 +8437,21 @@ group_type group_classify(unsigned int imbalance_pct, > return group_has_spare; > } > > +static inline bool > +sched_asym(struct lb_env *env, struct sd_lb_stats *sds, struct sched_group *group) Thank you Peter for this code! It worked well. I had to make a couple of tweaks. My proposed asym_can_pull_tasks() also needs the statistics of @group. Thus, I added them to the arguments of sched_asym(). Also... > +{ > + /* > + * Because sd->groups starts with the local group, anything that isn't > + * the local group will have access to the local state. > + */ > + if (group == sds->local) > + return false; > + > + /* XXX do magic here */ > + > + return sched_asym_prefer(env->dst_cpu, group->asym_prefer_cpu); > +} > + > /** > * update_sg_lb_stats - Update sched_group's statistics for load balancing. > * @env: The load balancing environment. > @@ -8445,6 +8460,7 @@ group_type group_classify(unsigned int imbalance_pct, > * @sg_status: Holds flag indicating the status of the sched_group > */ > static inline void update_sg_lb_stats(struct lb_env *env, > + struct sd_lb_stats *sds, > struct sched_group *group, > struct sg_lb_stats *sgs, > int *sg_status) > @@ -8453,7 +8469,7 @@ static inline void update_sg_lb_stats(struct lb_env *env, > > memset(sgs, 0, sizeof(*sgs)); > > - local_group = cpumask_test_cpu(env->dst_cpu, sched_group_span(group)); > + local_group = group == sds->local; > > for_each_cpu_and(i, sched_group_span(group), env->cpus) { > struct rq *rq = cpu_rq(i); > @@ -8498,9 +8514,8 @@ static inline void update_sg_lb_stats(struct lb_env *env, > > /* Check if dst CPU is idle and preferred to this group */ > if (env->sd->flags & SD_ASYM_PACKING && > - env->idle != CPU_NOT_IDLE && > - sgs->sum_h_nr_running && > - sched_asym_prefer(env->dst_cpu, group->asym_prefer_cpu)) { > + env->idle != CPU_NOT_IDLE && sgs->sum_h_nr_running && > + sched_asym(env, sds, group)) { > sgs->group_asym_packing = 1; ... I moved this code to be executed after computing sgs->weight as asym_can_pull_tasks() needs this datum as well. May I add your Co-developed-by and Signed-off-by tags to a patch with these changes in my v3 posting? BR, Ricardo