Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp291077pxf; Thu, 11 Mar 2021 04:07:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlogLFUw85c+wVUD0A4X9QzCuWLBKatCXYdbMhOWeonyqPD38umptPc9QtMhAjgWZVDOWH X-Received: by 2002:a17:906:1dc2:: with SMTP id v2mr2802539ejh.350.1615464442192; Thu, 11 Mar 2021 04:07:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615464442; cv=none; d=google.com; s=arc-20160816; b=es3YmTrD70KVLpKXSEu7wiisGbhCpS8AkvJZG2eEOxrwoPkm3U+9+0sMyef0JV1qwU Nk/5pTkS/3RwXMEFAEhFhljAXn7Wfohl5LvPO96Yct8oRl3U+Q+AUTR8CPpr/tnc19Zi Wd1KHo93nKMRwn9MOqC4EUPCh49M0cDN9T6jYL4mHzuVpqH9/k/e2d12xggjgEG69ja7 /AhztmUIB+FbMZnoVoJZHj845/AOdcvZr9BgDwcOayxR8U41lue2K8jfy/EiqFw6AaXi GMBFfCkhG9GKtjfUL3zh28Zwyx454kzaA15ihUCUPodFBj7FyskTAdo1aU+sZlv218ly NtYQ== 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=YqgEaJiK4T62TxyxmBsTucJLFmdtvYSll4rZGbNp61c=; b=gOleRkUkxJ2qesnfL3N9Ttj577lfn2fXC9TTDCRuDv+jYrJIlN3ujYEA0ACuSlRzPp QdSgG5W99S8dBo1nIkLapDt6x0NTv6Kr7oEwHswi90utUT3p2YbCCl3mP3Ikr0USKpCn pv1iuCpSeS7/fMjd++/UStnnQGWqY7evGCtH8FX8BHBXA+95xn5SxSP9/rcZNFE2r9yJ IU1w1XUVIbJJAtFMkXnkZyTdWrccfrVv1xoTXKIYG2ZDzzxyJmSZcCcC7A2TVF4t6wlr xrA4U5DND+y3HXl81/4UY6axY9/qyDxdNNSMXEI+QdfUWA9RGo1+OZnACLZrI+fGLzH/ A9Pw== 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 y14si1614435ejw.723.2021.03.11.04.06.59; Thu, 11 Mar 2021 04:07:22 -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 S233060AbhCKMGH (ORCPT + 99 others); Thu, 11 Mar 2021 07:06:07 -0500 Received: from foss.arm.com ([217.140.110.172]:34072 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233023AbhCKMFm (ORCPT ); Thu, 11 Mar 2021 07:05:42 -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 8201B11FB; Thu, 11 Mar 2021 04:05:42 -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 EDBDE3F793; Thu, 11 Mar 2021 04:05:40 -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 v3 4/7] sched/fair: Introduce a CPU capacity comparison helper Date: Thu, 11 Mar 2021 12:05:24 +0000 Message-Id: <20210311120527.167870-5-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311120527.167870-1-valentin.schneider@arm.com> References: <20210311120527.167870-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 db892f6e222f..ddb2ab3edf6d 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.25.1