Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp8001147pxb; Fri, 19 Feb 2021 05:06:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBVF/1IDgri9HLoRJ3nnPVClmE08IkZf/8ZsSxhU738bu7AfIJkSQnkQc2DbTlh7WtF/UI X-Received: by 2002:a17:907:9810:: with SMTP id ji16mr8248565ejc.394.1613739987697; Fri, 19 Feb 2021 05:06:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613739987; cv=none; d=google.com; s=arc-20160816; b=ptFDZhobfwn39HJWTZwiH6bmiE/LK/ZlgO7vA2CtqUS0/GULxniCGjoVmgIU2YGe/q 6u6LQzovJnF17Yyzdscs662QSGyG8mdoKMKFrt+eBZPCd1CKwjb2Gorz25ag1Lk/R0jM YieA3naBvBsjYLj2hMpZmFBl4F57aEmpDE55OH6Jy3/moHo8e0nOVzU5G2e1rjxsrLTZ Uqmne9mGMUEnglyrM6mz8ZK0MX8zQ5SJZvK+XmcAHPxq+tLLPTb/dENASPxiPCrF209z xMnbAIgEkUuFcx6kqIVJe8h3L6/Ci4AruWtxXGwqc07XriMvgfthOVc9XkGDu+51HZ6k JR+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xTG/qyku+SybsgrdZUc4KenER2XFUDa0gCXAqawhPZY=; b=tmPOMjIW7HW/+3MTYKSoSEnISg6J0lVid/ollyQorrUQaPOnAHMIbr3FZYFPXEcP4h qIwRK/UnrgX/n+PL49h4nVtf9HQvWFFXIBSuQNzV9inALY9YAtB//1bwAVYpWp84qst2 5Yqnbo39YfTwTpvhdyyYVmvQC1qsjB14QvI8ya0RTFCgWUxCeaVLOrVYU2CS5IpXDy73 v4GCWy8X0sfoFW4K5w9qOUukESfbb/yvBAuoyxjJRu+VDxX4NWuJt1sCGBj358zpTtMP hAkh3DJltewJZmqyfla34hDg/WiqXwG9ZzeKyY1YgH/L7VJfZ5ivB9Yh9lelIQnV9gtn CSEA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si5724527edp.207.2021.02.19.05.06.02; Fri, 19 Feb 2021 05:06:27 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230245AbhBSNEc (ORCPT + 99 others); Fri, 19 Feb 2021 08:04:32 -0500 Received: from foss.arm.com ([217.140.110.172]:35888 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230177AbhBSNDY (ORCPT ); Fri, 19 Feb 2021 08:03:24 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DB6EA13A1; Fri, 19 Feb 2021 05:02:37 -0800 (PST) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E16553F73B; Fri, 19 Feb 2021 05:02:35 -0800 (PST) From: Valentin Schneider To: linux-kernel@vger.kernel.org Cc: Qais Yousef , Peter Zijlstra , Ingo Molnar , Vincent Guittot , Dietmar Eggemann , Morten Rasmussen , Quentin Perret , Pavan Kondeti , Rik van Riel , Lingutla Chandrasekhar Subject: [PATCH v2 4/7] sched/fair: Introduce a CPU capacity comparison helper Date: Fri, 19 Feb 2021 13:00:00 +0000 Message-Id: <20210219130003.2890-5-valentin.schneider@arm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210219130003.2890-1-valentin.schneider@arm.com> References: <20210219130003.2890-1-valentin.schneider@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org During load-balance, groups classified as group_misfit_task are filtered out if they do not pass group_smaller_max_cpu_capacity(, ); which itself employs fits_capacity() to compare the sgc->max_capacity of both groups. Due to the underlying margin, fits_capacity(X, 1024) will return false for any X > 819. Tough luck, the capacity_orig's on e.g. the Pixel 4 are {261, 871, 1024}. If a CPU-bound task ends up on one of those "medium" CPUs, misfit migration will never intentionally upmigrate it to a CPU of higher capacity due to the aforementioned margin. One may argue the 20% margin of fits_capacity() is excessive in the advent of counter-enhanced load tracking (APERF/MPERF, AMUs), but one point here is that fits_capacity() is meant to compare a utilization value to a capacity value, whereas here it is being used to compare two capacity values. As CPU capacity and task utilization have different dynamics, a sensible approach here would be to add a new helper dedicated to comparing CPU capacities. Reviewed-by: Qais Yousef Signed-off-by: Valentin Schneider --- kernel/sched/fair.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 24119f9ad191..cc16d0e0b9fb 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -113,6 +113,13 @@ int __weak arch_asym_cpu_priority(int cpu) */ #define fits_capacity(cap, max) ((cap) * 1280 < (max) * 1024) +/* + * The margin used when comparing CPU capacities. + * is 'cap1' noticeably greater than 'cap2' + * + * (default: ~5%) + */ +#define capacity_greater(cap1, cap2) ((cap1) * 1024 > (cap2) * 1078) #endif #ifdef CONFIG_CFS_BANDWIDTH -- 2.27.0