From patchwork Fri Oct 27 08:03:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 158808 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp438304vqb; Fri, 27 Oct 2023 01:08:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGi7DAjOKHX2+lG6MVHWpK/5Ss2f51Ca80D28ZnPHWizMGKnRpzbxkKmY0Wp1Ag52xPFAeI X-Received: by 2002:a81:e20a:0:b0:5a7:b9b1:c0c5 with SMTP id p10-20020a81e20a000000b005a7b9b1c0c5mr1791350ywl.3.1698394081090; Fri, 27 Oct 2023 01:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698394081; cv=none; d=google.com; s=arc-20160816; b=S1zmrmrjkFjlFgklJqe3WwO1DDoA5o/GYf4cRisfoXycJhm3npGsJhfBLsy/ub/nyq 8QDEev4F0Yj+JrZsODAB51Zw0bqXcB1/vXjOMdF/0SKVKAw6UtdCPaubJKF1X1f3xY7d Bd0M7zZVnG+RB/a5xvPy+mblYgW441gpEGDovluwTW/tA827vt97ZcsO8pwJKMQW5mhP u2Yc8sZ+L2O67kU/PWrqlj4gRlHoIXUuKJZBciB6tXxdbKQ56M9aCMB/nRC1q1uP1XaL hbgzsJdBYa/ELs/sRqATf1acI5WOjNsL2gGRzovhGBYr8nGvNKgSjELMlpsXXcElzabT 5F5g== 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=r/qdhwYexgC4eelalZMREFYWDVhGmAVpyIy4h5YJd+Y=; fh=aqXlZKEuqBn32GiqXwfBTBEPXMVE+dzbtwpLcW+Wljc=; b=fFK0wT901xzVFhIDbLUFS3gZ7l3iARNd8bZMENXmkMrJ0/PdOvc28s23F/sF9R2oP2 v01MqOxcxm9kABbZ1P1iU/Ya0Oxtzlla66Vo/kf0xui0JMC2cuNNmoXkfrcb4PGkyych qPozLyUEES3S5E6dOPsBqOYT71YzEub7w0PIeLRNwsai8WwRB5SzGHzHXhU7QKBIdfIp TN/7NLIyUE7zjdHEToElHY1m9lK3t/dWrgwWyaz77J2e0Dir+eesvRbmq7KNvaL/h614 me/YdV32JOcbCqVxQWXunRlGVlKA0dlLtvKyXqrapy4X7Nv0pPYSSyF8XQWPTCYkrbu1 GmbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UwG/4VS2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id n204-20020a8172d5000000b00589c065b71csi1824784ywc.61.2023.10.27.01.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 01:08:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UwG/4VS2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 7328980B1E5F; Fri, 27 Oct 2023 01:05:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231624AbjJ0IEU (ORCPT + 26 others); Fri, 27 Oct 2023 04:04:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235073AbjJ0IEP (ORCPT ); Fri, 27 Oct 2023 04:04:15 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDB3AD45 for ; Fri, 27 Oct 2023 01:04:11 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2c4fdf94666so23442711fa.2 for ; Fri, 27 Oct 2023 01:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698393849; x=1698998649; 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=r/qdhwYexgC4eelalZMREFYWDVhGmAVpyIy4h5YJd+Y=; b=UwG/4VS2MSxnkHtnsQpx9o/IPbZw1SxCBiaWXkPAhvhzizTMzCCoLnLGF4IHzjENat p41YfyeuOalrUJevD4TBvRf890ua3fFIJoTyZdQDjvv8D3qHL11Ntu/6ji8O9I0mp7zt anztlSB/tAGfuE/cy2m4NgHBbFDhm39MQhI8VLPBWD5W2qjTAfJNX3MP05Aj4SXC2SAS +dCFxr2+vbXfCASS4kYKZoZNlXyQU9TnhvA64gvJV3qmfKdLXvk+vaXI5ZjbAUWy5cMN DS/HtrOHsQ1DBTnsFgr4/qM8B1P5gFIn8msWC/ZrDXdhoMwFttPih9Gy5hZU7d19DQed Sgcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698393849; x=1698998649; 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=r/qdhwYexgC4eelalZMREFYWDVhGmAVpyIy4h5YJd+Y=; b=BrJrTLOoOKTqm7LCz9o8c8QJKGiUI603f+7AvqeO8tY6sayLCP5d6x/CtUBc24LXWQ C/B14thDYmLZIWCN9OS22Tzefv/KKHknRkwSpgCX7BCmK9eu0jq8YjDpKM71DgGIAXAT wyq0EwqCUekX3+tDWGck0dDgOS3GcpYV7vpC0E8D1NUzHV07ud1qCVJltnOYIuX6PTiJ C8CXkZQub2zpyF4rv7dkvvC2d2VwXO+64aG39O7wE4TQFB8xSYw54ri026K56UMTXbtp 1mTsn2l94Tr5Gvzu9hhYM7/iDnftEhv7BOopqEzhW53xD4MCUAH7wLfF6cQsMzG4V52p 6YIQ== X-Gm-Message-State: AOJu0Yz4buJgLwVn/N5iBO5rSdRjeXJNDI6qRMwVUrF3gDyWRUtYn1Z3 bWmQMAIhw2hGlEDSZOjkWJJE/w== X-Received: by 2002:a2e:8217:0:b0:2c5:1eb6:bd1e with SMTP id w23-20020a2e8217000000b002c51eb6bd1emr1414040ljg.43.1698393849239; Fri, 27 Oct 2023 01:04:09 -0700 (PDT) Received: from vingu-book.. ([2a01:e0a:f:6020:c5e:e24e:ad0b:58c6]) by smtp.gmail.com with ESMTPSA id 17-20020a05600c025100b004083729fc14sm4397488wmj.20.2023.10.27.01.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 01:04:08 -0700 (PDT) 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, acpica-devel@lists.linuxfoundation.org Cc: conor.dooley@microchip.com, suagrfillet@gmail.com, ajones@ventanamicro.com, lftan@kernel.org, Vincent Guittot Subject: [PATCH v2 2/7] cpufreq: use the fixed and coherent frequency for scaling capacity Date: Fri, 27 Oct 2023 10:03:55 +0200 Message-Id: <20231027080400.56703-3-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231027080400.56703-1-vincent.guittot@linaro.org> References: <20231027080400.56703-1-vincent.guittot@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Fri, 27 Oct 2023 01:05:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780895272005463526 X-GMAIL-MSGID: 1780895272005463526 cpuinfo.max_freq can change at runtime because of boost as an example. This implies that the value could be different from the frequency that has been used to compute the capacity of a CPU. The new arch_scale_freq_ref() returns a fixed and coherent frequency that can be used to compute the capacity for a given frequency. Signed-off-by: Vincent Guittot Acked-by: Viresh Kumar Reviewed-by: Lukasz Luba Tested-by: Lukasz Luba Acked-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 4 ++-- include/linux/cpufreq.h | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 60ed89000e82..8c4f9c2f9c44 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -454,7 +454,7 @@ void cpufreq_freq_transition_end(struct cpufreq_policy *policy, arch_set_freq_scale(policy->related_cpus, policy->cur, - policy->cpuinfo.max_freq); + arch_scale_freq_ref(policy->cpu)); spin_lock(&policy->transition_lock); policy->transition_ongoing = false; @@ -2174,7 +2174,7 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy, policy->cur = freq; arch_set_freq_scale(policy->related_cpus, freq, - policy->cpuinfo.max_freq); + arch_scale_freq_ref(policy->cpu)); cpufreq_stats_record_transition(policy, freq); if (trace_cpu_frequency_enabled()) { diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 71d186d6933a..bbc483b4b6e5 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -1211,6 +1211,15 @@ void arch_set_freq_scale(const struct cpumask *cpus, { } #endif + +#ifndef arch_scale_freq_ref +static __always_inline +unsigned int arch_scale_freq_ref(int cpu) +{ + return 0; +} +#endif + /* the following are really really optional */ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;