From patchwork Sat Dec 23 16:09:53 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: 182983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1752229dyi; Sat, 23 Dec 2023 08:12:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGn8V/ATDMyYgekjaj+rl5CQyiqYXvSOSmcItfjV2XQPDg/rhLQ8SpdTzvCszNPLJfP5uBW X-Received: by 2002:a05:6a20:4c10:b0:195:10aa:eb29 with SMTP id fm16-20020a056a204c1000b0019510aaeb29mr3249905pzb.33.1703347926245; Sat, 23 Dec 2023 08:12:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703347926; cv=none; d=google.com; s=arc-20160816; b=uNVAUMTh2COFex2HbcjgUE+6mgx31Ao9VbTVTMfIl/Ixvh7FdFJSiUzZocAuMAV5c3 fsaOEs9gh2MqY+DiyWACEaA7fDmOz6g21PrQlyYvyTUSfEjxRtb16E1ppjvmIlnClVwL JHdbicxIbdoIaiiGHhxjIbFUkjAYg2iTbkAnpJetoA/Aof9jGwZh/HAtZaWzxiIm7z60 czjKOWQUa6OdtnOzimAsVF81rj4AJv+9lfSBzX7x3x7P13H0kjVbYXbRNfI+raMr6kgq w3z4z32FLR4IOhJnfR/31rBJh22TN1X6wHKY5F+9pAFXVOZnEKB9S9cVeYTuRbDGfCgZ 0e2g== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10493-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e18-20020a656bd2000000b005c69365abb9si5462720pgw.697.2023.12.23.08.12.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 08:12:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10493-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10493-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 466D2B21346 for ; Sat, 23 Dec 2023 16:12:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92149225A6; 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="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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784982290405731237 X-GMAIL-MSGID: 1786089754888381047 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