From patchwork Sat Dec 23 16:09:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 182982 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1752189dyi; Sat, 23 Dec 2023 08:12:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDzmBe+MTfb3Y25EA43AkYqW4fRwy1Zly52aLqaSV6hreUFS2Axvt6KnrsWuwBGctFW0SC X-Received: by 2002:a17:906:c801:b0:a23:44e7:4a7b with SMTP id cx1-20020a170906c80100b00a2344e74a7bmr1977523ejb.93.1703347923028; Sat, 23 Dec 2023 08:12:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703347923; cv=none; d=google.com; s=arc-20160816; b=SEfzTl8QV0gaoLm9cycnCkxPaLFCvPDZcXynRdEFwbdpxnawiRW23EP3GD7m5/r6mr fr+ThSNSiEDkbxAt0bN8AhH3xV5IGoLtlyyKmE9dToD51GW+lTlsj5SfaIW1uA68NhIb sadoGR1JGdlnCj2U80NicY7zzJmRxSq7pJRkAfPBAgY70KMuEL75nCsYqF6Rvp/MaV9i nkV9mnwI0+lFmyrYq7X2woN/lTg+05TZSHs0sVqik40DMq8Gedpnc3oaZzo/BhS2cvJJ 3RXm3GFhOLpoFgN9CDs6zX07vGQg4Z0RgjpJsQf6U9P0DlT7iKUm07Q4IayOs8udDuNN aqYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=daGgmxq1Q7sIM0XiiBa1w/Df41CqQbVCnY7n5nRIWZU=; fh=oe4lhg1EfvTWr54V+GlayENPsKuTzCS14yFXedZ2BAk=; b=ds8ScWjlKkE0MnkSd3T/EraJwS0gQPELfqk81BFHGRKa4JV/5DXtY3bJr9nH3fN03n 2EB8PfvC9vx6K1JUq7+vm8NWLsWoTuPNcAxR9LUwKINy+h7YJC0cj9CWfIml1xo+Dml2 G8IXc3sk6HUxcRoI5oquz/sZdgenH26rnjdvVVXKm4F+Dz08oi/Mh5f06XEHOsAcdmuU T0iRR14DM7aXqBm5HKEHN9xqEudHCf/srfOF4wEF4YCGCbjFPn9B+bWMdlG37llxsYRR PGitxWvcsVM46u/K8G//NhaET611dQBIhIs148QhFMgqOQ/kuqor43C78U8WRsLmcKlb ITXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eBPWeh7M; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="/DnBW8/O"; spf=pass (google.com: domain of linux-kernel+bounces-10492-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10492-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id jx13-20020a170906ca4d00b00a26ac400a5esi2375696ejb.54.2023.12.23.08.12.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 08:12:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10492-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eBPWeh7M; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="/DnBW8/O"; spf=pass (google.com: domain of linux-kernel+bounces-10492-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10492-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 83D7D1F21AF0 for ; Sat, 23 Dec 2023 16:12:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74780224FC; Sat, 23 Dec 2023 16:10:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="eBPWeh7M"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="/DnBW8/O" X-Original-To: linux-kernel@vger.kernel.org Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E5A912E5E; Sat, 23 Dec 2023 16:09:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Sat, 23 Dec 2023 16:09:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1703347794; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=daGgmxq1Q7sIM0XiiBa1w/Df41CqQbVCnY7n5nRIWZU=; b=eBPWeh7M44Hmb5kvmlPIizB6ZtmWWnNzfWvOW+BoWzTbfVepRC0K5tmff0Gb9AMnKmqGnh dXz73Y/EVVydxP+cts+SWwmYcO2SDTHt6H+Ey9DTlWyWWKBwceGf9Ginde578KSJTw9kaN iAKFuMg2nzW9+RsgjEdMZ4jHw9dx/zRuOlheHzuvA7lpgj0ThG9QuEBa2O/ktK3g7WRoCW eopAsa/2CAM2TcvD/dt3S9V+mUJASWUMVx6rspejmHLsVGF/SEw3ZTVtKE047PU/cV5Jtf BAJQml/3blnIRX+ggPbibTIjiGS5JxxZQlDPgL4mv00KatPK0Q1qNwObNpNQYA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1703347794; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=daGgmxq1Q7sIM0XiiBa1w/Df41CqQbVCnY7n5nRIWZU=; b=/DnBW8/OoEeiWKl1004zAdHKWIBIhsjXDYCuEXnmLyRTcfR+SipNa3VM9gjtexiqAs0TDh uWsqbqxPkwNzxeBQ== From: "tip-bot2 for Vincent Guittot" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] cpufreq/schedutil: Use a fixed reference frequency Cc: Vincent Guittot , Ingo Molnar , Lukasz Luba , Dietmar Eggemann , "Rafael J. Wysocki" , Viresh Kumar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231211104855.558096-4-vincent.guittot@linaro.org> References: <20231211104855.558096-4-vincent.guittot@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170334779405.398.10634104096869499211.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784982299808443709 X-GMAIL-MSGID: 1786089751970423350 The following commit has been merged into the sched/core branch of tip: Commit-ID: b3edde44e5d4504c23a176819865cd603fd16d6c Gitweb: https://git.kernel.org/tip/b3edde44e5d4504c23a176819865cd603fd16d6c Author: Vincent Guittot AuthorDate: Mon, 11 Dec 2023 11:48:51 +01:00 Committer: Ingo Molnar CommitterDate: Sat, 23 Dec 2023 15:52:35 +01:00 cpufreq/schedutil: Use a fixed reference frequency cpuinfo.max_freq can change at runtime because of boost as an example. This implies that the value could be different than the one that has been used when computing the capacity of a CPU. The new arch_scale_freq_ref() returns a fixed and coherent reference frequency that can be used when computing a frequency based on utilization. Use this arch_scale_freq_ref() when available and fallback to policy otherwise. Signed-off-by: Vincent Guittot Signed-off-by: Ingo Molnar Tested-by: Lukasz Luba Reviewed-by: Lukasz Luba Reviewed-by: Dietmar Eggemann Acked-by: Rafael J. Wysocki Acked-by: Viresh Kumar Link: https://lore.kernel.org/r/20231211104855.558096-4-vincent.guittot@linaro.org --- kernel/sched/cpufreq_schedutil.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 4ee8ad7..95c3c09 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -115,6 +115,28 @@ static void sugov_deferred_update(struct sugov_policy *sg_policy) } /** + * get_capacity_ref_freq - get the reference frequency that has been used to + * correlate frequency and compute capacity for a given cpufreq policy. We use + * the CPU managing it for the arch_scale_freq_ref() call in the function. + * @policy: the cpufreq policy of the CPU in question. + * + * Return: the reference CPU frequency to compute a capacity. + */ +static __always_inline +unsigned long get_capacity_ref_freq(struct cpufreq_policy *policy) +{ + unsigned int freq = arch_scale_freq_ref(policy->cpu); + + if (freq) + return freq; + + if (arch_scale_freq_invariant()) + return policy->cpuinfo.max_freq; + + return policy->cur; +} + +/** * get_next_freq - Compute a new frequency for a given cpufreq policy. * @sg_policy: schedutil policy object to compute the new frequency for. * @util: Current CPU utilization. @@ -140,9 +162,9 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, unsigned long util, unsigned long max) { struct cpufreq_policy *policy = sg_policy->policy; - unsigned int freq = arch_scale_freq_invariant() ? - policy->cpuinfo.max_freq : policy->cur; + unsigned int freq; + freq = get_capacity_ref_freq(policy); freq = map_util_freq(util, freq, max); if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update)