Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3880457rdb; Mon, 11 Dec 2023 02:49:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmZ835MTy1GYfdas9vxdyz/KW7XX2QoOnLSlWRIvPx3txJKguCzUUdahUYmQOgD6rUdpWr X-Received: by 2002:a05:6a00:a91:b0:6ce:2732:1ded with SMTP id b17-20020a056a000a9100b006ce27321dedmr1900583pfl.39.1702291766458; Mon, 11 Dec 2023 02:49:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702291766; cv=none; d=google.com; s=arc-20160816; b=UzvmdzSgkLLjD/bpOndTux4nKsL2H5jks3gOqO1qOSOYXIhBbfP5KQwC2IEwmPXnvR x0pUOEJ6y3bJ8CWmyDk7kgihxZ3+THK1CgLGRIYQ1J6GZGO8bFZLAquT9ynfMnjxC1Wt R0UZLDCNZpJq3UNcKGpBDj9r0RQLP2B9DLDWuX3V4m7hmYKy1SFTA76LNVQezb0CwBUR w0pnci7v0AJitbjhd/+POymjiBy4YrVTiUIUfKqB+EHWy9JmWYCsh0QpRj67E0cnhtKs bJCbFeT4z6UdlK37ta3nxxIae0nf6R7qGwBsmBdmU+S8lbQQkwgQ+pM3bhvWHy0D1aV3 jiMQ== 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 :dkim-signature; bh=19YdKXep2h2XKs9tI+n1uE2b2ri9zL5T7djiTxR5FZs=; fh=m1RMQkhqhelqGHSEjFmV3Y+WASpNyNPj5/fiCJx83/o=; b=Mv3kSZg6rmy9qp/xviZgYcvjj+9dz2QpG7UWus4E+FpxSmGSp73BjIK26ZOtguMGXl 2F6avDUv6IZGZfN0Fwrcu70+vn49ya1wuTx2Lyq7f8mHHQJtuO9ZrLTiveDf4g9nLu4z qOkOg6K+Jig3MtO4T+DDQXDnwyMpg8/sBdIUHq2QMgvMEMZNPd13CDP3lfg65SmGlvRv hxIJWtQ1lXAYbmQlFQy4YkVeReTID/ielK16BxsYsiaA1MfNKU3UNpMBt4GvMPpXS7Lm Qxwxm9a6pYnm3Nz6L3I6UuwNl5oJWZOaGWpWNpMKDTo3Z4XBAJw2ppYGMoJBpI0oTCP6 ZUog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=caxgzVPW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n189-20020a6327c6000000b005b87df75d54si5826869pgn.83.2023.12.11.02.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 02:49:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=caxgzVPW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6C058805AC1A; Mon, 11 Dec 2023 02:49:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234489AbjLKKtJ (ORCPT + 99 others); Mon, 11 Dec 2023 05:49:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234446AbjLKKtC (ORCPT ); Mon, 11 Dec 2023 05:49:02 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B43BEA for ; Mon, 11 Dec 2023 02:49:07 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3334254cfa3so2342256f8f.1 for ; Mon, 11 Dec 2023 02:49:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702291746; x=1702896546; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=19YdKXep2h2XKs9tI+n1uE2b2ri9zL5T7djiTxR5FZs=; b=caxgzVPWvGkUC4/QPdofkQlRsb5EcFWebyQalIeP2tPQI7TEDFpFgOIFHE2bL4QdGk w/q+KH3lrWW0RdMxQ4eQ79Wh8VrIWWLOiHm+KLYn/zMNNBmbrMMrhH3Z3CZyEAPUhOtm H80WTj4mj3crsdN807njsgqWOP2i5e1z33UXPOZ9by2x6/AnLvo3CFoHDg4MjKXWkG5U xuqH5LZ5+5r8J9p058PxhoKi+dMN1BgaMgdkTfgFx9s0/Sxn3sqwN+/I11je7OIMnMq8 GPsbWD1zX42XvWVsYFnvLwLhivPAPt2GzNBB3DQw1arXlSUp2OmXtsLWSoNsI6lSy0cO KyLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702291746; x=1702896546; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=19YdKXep2h2XKs9tI+n1uE2b2ri9zL5T7djiTxR5FZs=; b=syRplrZIDaKMPermPjztxDR+vW8QrUoeIl6tZ+8cfcRjB7SYQ1ajbH6fkra+fUmidD YtGvVcChkDVQ47HzFI3YenA0aoTgwxcmF19WNzAbtogf5Ng+RVeixitxydo/6M31qC31 1lgXmsGdnJQu2NJTIqcu1SV8Ct8Tp6WlXLiPhLDMauk7pR/RcmmhZXsFu6JcIWaKxUzp nDdxCvGE8PFxAN8yvSz2+egtAmRxLTS84veqFAr2N/zWDTpoi/Gou7c+t+ZWPBrXuXjy NYITKlga2QXe2GoEPvwQXh8CiJEEQM0a5RZZFilv7y7cbVoebWh1vM+edRKAesPJmOYP k8Lw== X-Gm-Message-State: AOJu0YwJOD6edUOkCxr4o4gYgXBfeePYt1+GmyG6V7WUvwfQFRfbyRQ0 JfTT9BWxL1yYmSMRIWPPAQS/Eg== X-Received: by 2002:adf:f3cf:0:b0:333:3d26:7b01 with SMTP id g15-20020adff3cf000000b003333d267b01mr3106219wrp.13.1702291745981; Mon, 11 Dec 2023 02:49:05 -0800 (PST) Received: from vingu-book.. ([2a01:e0a:f:6020:a8d:abc:f0ae:3066]) by smtp.gmail.com with ESMTPSA id e16-20020adffd10000000b003346db01263sm8232579wrr.104.2023.12.11.02.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 02:49:05 -0800 (PST) From: Vincent Guittot To: linux@armlinux.org.uk, catalin.marinas@arm.com, will@kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, sudeep.holla@arm.com, gregkh@linuxfoundation.org, rafael@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, viresh.kumar@linaro.org, lenb@kernel.org, robert.moore@intel.com, lukasz.luba@arm.com, ionela.voinescu@arm.com, pierre.gondois@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org Cc: conor.dooley@microchip.com, suagrfillet@gmail.com, ajones@ventanamicro.com, lftan@kernel.org, beata.michalska@arm.com, Vincent Guittot Subject: [PATCH v7 4/7] energy_model: Use a fixed reference frequency Date: Mon, 11 Dec 2023 11:48:52 +0100 Message-Id: <20231211104855.558096-5-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211104855.558096-1-vincent.guittot@linaro.org> References: <20231211104855.558096-1-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 11 Dec 2023 02:49:25 -0800 (PST) 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 Reviewed-by: Lukasz Luba Tested-by: Lukasz Luba --- 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 adec808b371a..88d91e087471 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 -- 2.34.1