Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1480809rdb; Sat, 23 Dec 2023 08:11:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJR15SfeQx7/ZN6znnSltqvApgRWS+f/gkZCFAOu4d4ZC8jy//La/5o3gU0qRqH1B1RXp5 X-Received: by 2002:a05:6214:19e7:b0:67f:43dd:4687 with SMTP id q7-20020a05621419e700b0067f43dd4687mr4651164qvc.1.1703347867560; Sat, 23 Dec 2023 08:11:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703347867; cv=none; d=google.com; s=arc-20160816; b=pnZGwkwPI3YbNJ5bmotJh4iiLza9Y4BSI7ZMQlhOW67thhkK8NGGTrsz5IIasP26Ew F8S5tV1HWvo6XM35D1ZENfFZ/8Qnohg4v9wkquIkFQal3zOz9J/Zm43dKl9MbTDy6Ity 07TzCKPgevwawv0SZEznZ2b/sTqumzHhvTlHspsgVDYMJRV9UX3CzYJp+2qwsCUbsdWy 1tBUd2hm9c/v+eCMwDwe2q99J26mlQnN5t1DI6XHDKRSrO54URyy3AIQdf2FV7HYVW+E b5o4FPYtWzeYhAkItQZnmP+s+5bPatT7YKDpKLs/tvhRPLruoXwnyaWtr9sCZKLCIxVj 2Hlg== 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=e1rv9KWAedXf+6MAE+TP7MgYC9JX0sCJ0CVk2+10yHE=; fh=TEsDLbIrerrtKaO3DSfFQagWDu9lGo02HT1CddU/55k=; b=LJeGGv2/1cxIZjSLK9XJr8NcwnGfkIpRcbF4qv/09oUiFte9QuUcZTD8VNngkwgdbZ Uv+5RLTlasd+hi6XGPRsPiwGjYmi696GN3QEk+ccn/rzB4d0vhW1lrJzW12byLM51BJG Ww1jABn/HKhNMbNBr0UDvZA5dbVUyzOQBEpMTmMpi7RpcAczFujVEK/+ql+fsrQEOkHB AnJUEqgNarpqQ6McNJVCia88B7o9sfqmqnbnf+iYRFYn3mGAxnkNgy8pnXIjW1xR1753 CURL9kHprKmtRCsNb+IP710ZzsxPdZvqoOZYMkS9ElhRdd/XL9hm0BHUoqVLMWuM0KBZ NEaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qiv5nX7y; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-10493-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a9-20020ac85b89000000b0042777258c58si6864065qta.49.2023.12.23.08.11.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 08:11:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10493-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qiv5nX7y; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-10493-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10493-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5464B1C20C3C for ; Sat, 23 Dec 2023 16:11:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A4861F170; Sat, 23 Dec 2023 16:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qiv5nX7y"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NUuPnOxH" 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 F2DFE12E5B; 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:53 -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=e1rv9KWAedXf+6MAE+TP7MgYC9JX0sCJ0CVk2+10yHE=; b=qiv5nX7yq8qw0Vvi3370RpMkVv5TJ0FU9jHoRs/E8RXSePVX7bNYqNsJgfNv6TTkyVusUm uYn9jIjekTXg6Ra52xPoVul3nkefXp6brD6Nj08cs0XUTrszXelaFA5JQcUHbYytzoABG7 X2RgIEVECQwldYBbFet43WGg/7V8F368awmZWJoH8P3XpnPG02ude50xeNDaAqfpkTPvAD 6Bcz8dwwm2Pmnmk4HleVIkDiSSCDTWAZ7dBfJDP8XbCCEMLdWFaWIp0OzRt+EkgT5WaNJY frjKugRbZilfpDTzSQT+TITZdv6xzZuHF7qXOQkuf/rjtNwG79p+sG2fJ3qbGQ== 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=e1rv9KWAedXf+6MAE+TP7MgYC9JX0sCJ0CVk2+10yHE=; b=NUuPnOxHgdPRlBc9j9feRVpirDY/GQ3UQQWND4SWudco3yVNkg2cblaG58qX43aoinZki0 580XVmNthJ4EynBg== 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] energy_model: Use a fixed reference frequency Cc: Vincent Guittot , Ingo Molnar , Lukasz Luba , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231211104855.558096-5-vincent.guittot@linaro.org> References: <20231211104855.558096-5-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: <170334779328.398.1653649197000520195.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the sched/core branch of tip: Commit-ID: 15cbbd1d317e07b4e5c6aca5d4c5579539a82784 Gitweb: https://git.kernel.org/tip/15cbbd1d317e07b4e5c6aca5d4c5579539a82784 Author: Vincent Guittot AuthorDate: Mon, 11 Dec 2023 11:48:52 +01:00 Committer: Ingo Molnar CommitterDate: Sat, 23 Dec 2023 15:52:35 +01:00 energy_model: Use a fixed reference frequency The last item of a performance domain is not always the performance point that has been used to compute CPU's capacity. This can lead to different target frequency compared with other part of the system like schedutil and would result in wrong energy estimation. A new arch_scale_freq_ref() is available to return a fixed and coherent frequency reference that can be used when computing the CPU's frequency for an level of utilization. Use this function to get this reference frequency. Energy model is never used without defining arch_scale_freq_ref() but can be compiled. Define a default arch_scale_freq_ref() returning 0 in such case. Signed-off-by: Vincent Guittot Signed-off-by: Ingo Molnar Tested-by: Lukasz Luba Reviewed-by: Lukasz Luba Link: https://lore.kernel.org/r/20231211104855.558096-5-vincent.guittot@linaro.org --- include/linux/energy_model.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index adec808..88d91e0 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -224,7 +224,7 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, unsigned long max_util, unsigned long sum_util, unsigned long allowed_cpu_cap) { - unsigned long freq, scale_cpu; + unsigned long freq, ref_freq, scale_cpu; struct em_perf_state *ps; int cpu; @@ -241,10 +241,10 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd, */ cpu = cpumask_first(to_cpumask(pd->cpus)); scale_cpu = arch_scale_cpu_capacity(cpu); - ps = &pd->table[pd->nr_perf_states - 1]; + ref_freq = arch_scale_freq_ref(cpu); max_util = min(max_util, allowed_cpu_cap); - freq = map_util_freq(max_util, ps->frequency, scale_cpu); + freq = map_util_freq(max_util, ref_freq, scale_cpu); /* * Find the lowest performance state of the Energy Model above the