From patchwork Mon Oct 9 10:36:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 13413359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2E99BE95A91 for ; Mon, 9 Oct 2023 10:37:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hHdIUyU87qgyhSWdpQlJ7IuizBxscGHw1KGJfhkVMxU=; b=rP1rDTG5w7ErUP X1C0x/JxOPs/UxvG3OeTPOnPFDugQoEfb+HV25SRoWcsiF9BSQNVZfL1zCfbd8c8pmS7Lq2KT3jAJ ak7fwKR6QLgaC5hZeNEijdTzPUHDfgYjot8BkNTpJ0ZQxzkVmLcwRZmtqFET4RtMJI6j9ruxVEX+W FothA41iKRwhY6Lz5vRtEhjopJ6TRWpobRU4QxVeL0aBoNA/dXmuslRKy6nKaNeHn9nhkeFC3yXyJ XRTY3svA9422GPIrbvfejmz9Yviz+ndfhoV387V6zwhIfOT2MR6hWC5icMeFUEE5X98CLlQ6ms1tK OCEj+jYEsZZFYFWjRSyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpncx-00AFeS-10; Mon, 09 Oct 2023 10:36:43 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpncr-00AFXz-06 for linux-arm-kernel@bombadil.infradead.org; Mon, 09 Oct 2023 10:36:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=kNKKT3nz1YObI5oerkbE50Couf3/jlljKZ/fkPRsfb8=; b=o/L/eK4m8JzO11/JFLK+KulzPr Y9h2lPczJLOHXFLwpdxGgx3rW+kf6M4O6y9eSBJMXXK60WNCYkEbemJXvCZIziucQrDsesjJIBNg3 7rIm7/Ste3OkvPg1YE3LQXYhXPOVG/Wpyp8SYWYB3xS7U3fbe29GhwJYR5OYIb/XLqlunT0VXArz5 HkqKuG78skzTy7bqt+eQGBOovK2hEc10+JPXbYxd//YVXi09yFXKPpgN4wa70RBQKfrvQyMwhwOsA VGxHFeeHmvORHhYzKcQbP7YwBeZ/xaDU0k4iJPCZmNcdzp6b5DK53PUNLPvig+lcCqiOln76vBaBI I7m/zxUw==; Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpncl-00Fnie-1X for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 10:36:35 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4054496bde3so40312275e9.1 for ; Mon, 09 Oct 2023 03:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696847789; x=1697452589; darn=lists.infradead.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=kNKKT3nz1YObI5oerkbE50Couf3/jlljKZ/fkPRsfb8=; b=gPc08vcY9r26P5KrGGQzdJrRxX78S2rgWPzurQwWN7wa/bAb27HBw6A4kt4hEO4jh7 IOrBUJMLWr4FKqD5hnLvV+BTreukM1OhuL/dbt1k6PtPDCusTjkKlacroT1zodYISHHM WLYJijELCA5RZ/rTBYHi0mkBDciIfuf76awHFfiucv7lYPhHc2MTh6BQ31lxbGNw88cF PyhGiXmyhL+rnSXac/6nhYwECzRnl9eWY4mdGTFseunzyfQJM0EfTAuBEsWSeNwyMDWk YClYe1vWE571StxaWrD0VOEOF098gTdkrxs9mDHbdqaholVOyJ9+lDOycMOEdu3JZs6a kzhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696847789; x=1697452589; 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=kNKKT3nz1YObI5oerkbE50Couf3/jlljKZ/fkPRsfb8=; b=OeVeurm6ujKjf9J5h1z8DMa+vVxKK+Uw1Eo77xa41ZTjoutJokRqNFOdnykNLRpKIq N3O/SeAzMNcG9MYXcDDpSNoozIYYUbVVFatgITLEPmN4CS5AEQtbYJRZJgoD78BGrWG8 pSFKEMYViT6blraBiiu0Vjcj4eYr6POqdPDN60SIPGp1wHcb0cX5Is/kPrgB8Hvbpj/h 42QvlPPh2s9zA9dU5JP2W4N8sL4lacr+JMb9snXlVWxNW4T0uTpVWh3/PVA4Vmi6Qjw8 gGjQ965DTtUxtmw6emQ5e8lak9YQplz49+JVB4Tegu9kFgt7zni8M/EXrm5Py6LWrwel jGRg== X-Gm-Message-State: AOJu0Yzmy2QCJRlfU+jUW0C67I6hX8IIOCUU47SkiYKyOb83GhrVKkQP Rx+d8VQcwhNxCelvjzDsnHQEIA== X-Google-Smtp-Source: AGHT+IG26Qla65j//2waJk5p+C3Wp1IkFGp+wjCfVC7nMqMP8R+PELrHfGujdUavK8O0HgXO8xjo4Q== X-Received: by 2002:a5d:4586:0:b0:321:5e2f:37e1 with SMTP id p6-20020a5d4586000000b003215e2f37e1mr13248647wrq.19.1696847789459; Mon, 09 Oct 2023 03:36:29 -0700 (PDT) Received: from vingu-book.. ([2a01:e0a:f:6020:53f1:24bc:5e47:821d]) by smtp.gmail.com with ESMTPSA id f16-20020adfdb50000000b0031ff89af0e4sm9226722wrj.99.2023.10.09.03.36.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 03:36:28 -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, 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 Cc: conor.dooley@microchip.com, suagrfillet@gmail.com, ajones@ventanamicro.com, lftan@kernel.org, Vincent Guittot Subject: [PATCH v2 3/6] cpufreq: use the fixed and coherent frequency for scaling capacity Date: Mon, 9 Oct 2023 12:36:18 +0200 Message-Id: <20231009103621.374412-4-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231009103621.374412-1-vincent.guittot@linaro.org> References: <20231009103621.374412-1-vincent.guittot@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231009_113633_259195_BB92BF43 X-CRM114-Status: GOOD ( 13.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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;