Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3376713pxf; Mon, 15 Mar 2021 08:15:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3stlhPgiFkleukolVWnJroDJ4CeUBjVhqvXLSiAUkNnFtOTQqY7KJheSxcf18UPPm06RD X-Received: by 2002:a17:906:5450:: with SMTP id d16mr13651962ejp.274.1615821343710; Mon, 15 Mar 2021 08:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615821343; cv=none; d=google.com; s=arc-20160816; b=xC/vM7KQVWGkh0CGnIU6tWPRjFFHjoo8VzHLYNeVANK3cEo88xvywok+YEsTGLpWuL zIQTFMBLwRUglzCHv5+hGRCZ311fSm+eHkL9UxBeLtVDxdUvGM7t+dPXBV88xzft04zw 9FHrQdoodvqnm1C5LibkOM0frepqQx3dMyJGavcqROBCpMkbyWWfHsAwpLDpJzvpIizZ EgzDAXPCBJtFHMfs2oxKblnIefhT7M7u3QjL02sg9Ri0i0UVL+weh1YkxJNFGcMFRa4G wKKCdCt+SMmkD4m2Xs40e/pm9LnfMQgV7YJfCg1FyGFwoi7DSuA1vaeavLdUObRZAfn/ uuuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SX8/O9HkgZUh3ycU9Sl2AhNyXYcupu3NkmSOWldBEXQ=; b=RWRTQj1uVOSnQodYC4YnPfLxGDwUyi6OALPJPUImiGKKvdPKgTCVlRcnmIvXJHG0VC YECzxSr0fziY1YBDmnv0WpDC+mIPDdn8DCLuhK8X+w+ApqVjR1okU2oDZjYQyAXu3uih GW4aeV77Ihe3jDN21qdgKUuBZ0hnuD1jabWxTsaI/Ik/388K3jkKHTEu5oGsLO4kyQw7 ouGJvBqvkQucVIQwq+z9nykN05yCSVhrJGWPD4+umsF0hMX1fXJu67au09srsRgWp4kG M9SxNa/bbIHG03EwP1QA8OApJzMtX2eNEfqkSj5Dwp7+lf9ESvW1Z9MizawaaY6tghSn 9r2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="mJbeER/e"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h8si1069646ejj.598.2021.03.15.08.15.21; Mon, 15 Mar 2021 08:15:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="mJbeER/e"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233137AbhCOPNz (ORCPT + 99 others); Mon, 15 Mar 2021 11:13:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232371AbhCOPNi (ORCPT ); Mon, 15 Mar 2021 11:13:38 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20CB2C06174A for ; Mon, 15 Mar 2021 08:13:38 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id d3so57342035lfg.10 for ; Mon, 15 Mar 2021 08:13:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SX8/O9HkgZUh3ycU9Sl2AhNyXYcupu3NkmSOWldBEXQ=; b=mJbeER/eaVipYMCMADj6CN51JmPG2Snl3InYvsFFFfvoDxR6gkDoC8Dp9SpqGhbO4v 6xReg28qJJgG3YTeI/+/EupXMOfx4WwBff31w7EBO09qyfSyFWnAFBFAO10gbKlX1rWS +qya4GIx41ahaVZRYCf7mEwa4QPu1Wj1HoTIdqf8PJ8wFeaAORreDNt+XLIt3cZKJP7Z 1RpSfnZtfTqE6zeCoBSistfOGvCNrdSvTQ1stW0BEw3lSgsuWu6mp/GG5HzcgRB8hGCE 20DGNXLHvSgYeFKvLPa+VwoVBH14WqkCudN1m5Sm8KIb4X0cuO5tIjcXX37UPBoIjRsm ORXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SX8/O9HkgZUh3ycU9Sl2AhNyXYcupu3NkmSOWldBEXQ=; b=XQJjICoPpfS6cPKAQBTz+Ub5ju/WJEJHfZIcGosw6/MoxS6OV5y4bIpzgX5C6eaA0M uMarEDVUTuE9nmjWfwp89hJ5MnAVJnIy3Vobci06NhWDbckYa/kk8LsclJ/PMOPrBaZX 2Ufu7r4Pf+iTj/JTWp+SsaPBMg5132RZkxKollntEb5eOVhAhXM5tnoyjNkaBCBUOWLs ZcbI6DxKhRuIXl88xV/UApl3N9vITBAJW9kyzbCGWuAxoK2QP6IbJFni6MX/y0VIeBNs YbXJMreIfziZq+QOt3fMI7ZaktaFUX6FOt9cOMfatutx6ssiYSyyTVC0FBTYru7nvmkv u8YA== X-Gm-Message-State: AOAM532OSFR5jmuBHoq+M9cs7TPwgQFUagn0yGuu5+jTBLVLx8fH0TfY ndetDnoRseWobduDoNImHKXFefDnzh8z26vprZjp3g== X-Received: by 2002:ac2:53a7:: with SMTP id j7mr8898591lfh.305.1615821216560; Mon, 15 Mar 2021 08:13:36 -0700 (PDT) MIME-Version: 1.0 References: <20210311120527.167870-1-valentin.schneider@arm.com> <20210311120527.167870-7-valentin.schneider@arm.com> In-Reply-To: <20210311120527.167870-7-valentin.schneider@arm.com> From: Vincent Guittot Date: Mon, 15 Mar 2021 16:13:24 +0100 Message-ID: Subject: Re: [PATCH v3 6/7] sched/fair: Filter out locally-unsolvable misfit imbalances To: Valentin Schneider Cc: linux-kernel , Qais Yousef , Peter Zijlstra , Ingo Molnar , Dietmar Eggemann , Morten Rasmussen , Quentin Perret , Pavan Kondeti , Rik van Riel , Lingutla Chandrasekhar Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 11 Mar 2021 at 13:05, Valentin Schneider wrote: > > Consider the following (hypothetical) asymmetric CPU capacity topology, > with some amount of capacity pressure (RT | DL | IRQ | thermal): > > DIE [ ] > MC [ ][ ] > 0 1 2 3 > > | CPU | capacity_orig | capacity | > |-----+---------------+----------| > | 0 | 870 | 860 | > | 1 | 870 | 600 | > | 2 | 1024 | 850 | > | 3 | 1024 | 860 | > > If CPU1 has a misfit task, then CPU0, CPU2 and CPU3 are valid candidates to > grant the task an uplift in CPU capacity. Consider CPU0 and CPU3 as > sufficiently busy, i.e. don't have enough spare capacity to accommodate > CPU1's misfit task. This would then fall on CPU2 to pull the task. > > This currently won't happen, because CPU2 will fail > > capacity_greater(capacity_of(CPU2), sg->sgc->max_capacity) which has been introduced by the previous patch: patch5 > > in update_sd_pick_busiest(), where 'sg' is the [0, 1] group at DIE > level. In this case, the max_capacity is that of CPU0's, which is at this > point in time greater than that of CPU2's. This comparison doesn't make > much sense, given that the only CPUs we should care about in this scenario > are CPU1 (the CPU with the misfit task) and CPU2 (the load-balance > destination CPU). > > Aggregate a misfit task's load into sgs->group_misfit_task_load only if > env->dst_cpu would grant it a capacity uplift. Separately track whether a > sched_group contains a misfit task to still classify it as > group_misfit_task and not pick it as busiest group when pulling from a Could you give more details about why we should keep tracking the group as misfit ? Do you have a UC in mind ? > lower-capacity CPU (which is the current behaviour and prevents > down-migration). > > Since find_busiest_queue() can now iterate over CPUs with a higher capacity > than the local CPU's, add a capacity check there. > > Reviewed-by: Qais Yousef > Signed-off-by: Valentin Schneider > --- > kernel/sched/fair.c | 39 ++++++++++++++++++++++++++++++--------- > 1 file changed, 30 insertions(+), 9 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 1e8a242cd1f7..41cdda7a8ea6 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -5759,6 +5759,12 @@ static unsigned long capacity_of(int cpu) > return cpu_rq(cpu)->cpu_capacity; > } > > +/* Is CPU a's capacity noticeably greater than CPU b's? */ > +static inline bool cpu_capacity_greater(int a, int b) > +{ > + return capacity_greater(capacity_of(a), capacity_of(b)); > +} > + > static void record_wakee(struct task_struct *p) > { > /* > @@ -8091,7 +8097,8 @@ struct sg_lb_stats { > unsigned int group_weight; > enum group_type group_type; > unsigned int group_asym_packing; /* Tasks should be moved to preferred CPU */ > - unsigned long group_misfit_task_load; /* A CPU has a task too big for its capacity */ > + unsigned long group_misfit_task_load; /* Task load that can be uplifted */ > + int group_has_misfit_task; /* A CPU has a task too big for its capacity */ > #ifdef CONFIG_NUMA_BALANCING > unsigned int nr_numa_running; > unsigned int nr_preferred_running; > @@ -8364,7 +8371,7 @@ group_type group_classify(unsigned int imbalance_pct, > if (sgs->group_asym_packing) > return group_asym_packing; > > - if (sgs->group_misfit_task_load) > + if (sgs->group_has_misfit_task) > return group_misfit_task; > > if (!group_has_capacity(imbalance_pct, sgs)) > @@ -8447,10 +8454,21 @@ static inline void update_sg_lb_stats(struct lb_env *env, > continue; > > /* Check for a misfit task on the cpu */ > - if (sd_has_asym_cpucapacity(env->sd) && > - sgs->group_misfit_task_load < rq->misfit_task_load) { > - sgs->group_misfit_task_load = rq->misfit_task_load; > - *sg_status |= SG_OVERLOAD; > + if (!sd_has_asym_cpucapacity(env->sd) || > + !rq->misfit_task_load) > + continue; > + > + *sg_status |= SG_OVERLOAD; > + sgs->group_has_misfit_task = true; > + > + /* > + * Don't attempt to maximize load for misfit tasks that can't be > + * granted a CPU capacity uplift. > + */ > + if (cpu_capacity_greater(env->dst_cpu, i)) { > + sgs->group_misfit_task_load = max( > + sgs->group_misfit_task_load, > + rq->misfit_task_load); Please encapsulate all this misfit specific code in a dedicated function which will be called from update_sg_lb_stats > } > } > > @@ -8501,7 +8519,7 @@ static bool update_sd_pick_busiest(struct lb_env *env, > /* Don't try to pull misfit tasks we can't help */ > if (static_branch_unlikely(&sched_asym_cpucapacity) && > sgs->group_type == group_misfit_task && > - (!capacity_greater(capacity_of(env->dst_cpu), sg->sgc->max_capacity) || > + (!sgs->group_misfit_task_load || > sds->local_stat.group_type != group_has_spare)) > return false; > > @@ -9448,15 +9466,18 @@ static struct rq *find_busiest_queue(struct lb_env *env, > case migrate_misfit: > /* > * For ASYM_CPUCAPACITY domains with misfit tasks we > - * simply seek the "biggest" misfit task. > + * simply seek the "biggest" misfit task we can > + * accommodate. > */ > + if (!cpu_capacity_greater(env->dst_cpu, i)) > + continue; > + > if (rq->misfit_task_load > busiest_load) { > busiest_load = rq->misfit_task_load; > busiest = rq; > } > > break; > - > } > } > > -- > 2.25.1 >