Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1802920rdb; Mon, 9 Oct 2023 03:37:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9UTjS9DJMLbdzaH42KJ/iYDx+liHa4X3AT9u1Bm2qwBb+yJEayD0rI9tnKtf+JzKsjGsH X-Received: by 2002:a05:6a00:248a:b0:68e:29a6:e247 with SMTP id c10-20020a056a00248a00b0068e29a6e247mr14111314pfv.10.1696847823024; Mon, 09 Oct 2023 03:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696847823; cv=none; d=google.com; s=arc-20160816; b=VCy2T5hgG7+EXV3HNtspeyQafo2JR62LKArcEfNIKav3TSFk6AIEQWlCfa8uuLpSqa eS5ICLs5swXLANyR9Ot/xvW+uENCVIjeNxlwn2C+wfNGrhU9v2hv1XmFjAtf+mFapTrl FI9CklVt65mxLxrRXtJZKAON6E2cXV3tzWq3B+4Zu8PJ5bx7EtEI0LLf8L3cyw7a4iQH E6zUhmF/1Tg8IdZzahHJtSG4QCgyzCRgwUPJhgb+IMz6PQxuuWVYsosrIg9bcw798Ciu Su1Kvudyd5oSroCWp/kzmBh3v2+LCstomOH/f6Yzh4n5f2J6svQkAf8nip7J9JYOMJKJ qh0A== 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=kNKKT3nz1YObI5oerkbE50Couf3/jlljKZ/fkPRsfb8=; fh=CTzDJVM7oULtQm/gNhTIYIp8l1hhytXd8GM++3u6z3Y=; b=p/tMi9QZc3mYEklkTRe8iuq6ovFUnPBzrydR9PpvByiUwZ+oP9Vre84KbFd1oNIYlg poTRGqtgWYhOWpSrThpR/1QyzOdCC++I8X+NutNCO4aMFpWLfpq/o/8F7ok0gK7PBxNa SW2DrCfLY9SIMzrqD/CEpuGpDqLeTOh6Ypf6m6OXcpDNmM8J3Njmot41jMh6vXPNECHp ioQwI8J8FwpeBkuHr+Uzfk4ayInTFhILmiCeN1fMY9jMxuAHouns3tgLxEqE3PV+nvNO HV/WdN3h3H5UUyzEr/KuXIyXnnUZ3TlIm8HGlP8f2csWWO1sE/jHD8v/scI3sI/5FHIr jwLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KKeeHEgw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id z8-20020a056a00240800b00690f49d9e44si7346264pfh.400.2023.10.09.03.37.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 03:37:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KKeeHEgw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 7F28E8052BEE; Mon, 9 Oct 2023 03:36:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345962AbjJIKgi (ORCPT + 99 others); Mon, 9 Oct 2023 06:36:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345908AbjJIKge (ORCPT ); Mon, 9 Oct 2023 06:36:34 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FB549F for ; Mon, 9 Oct 2023 03:36:31 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40566f8a093so40290105e9.3 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=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=kNKKT3nz1YObI5oerkbE50Couf3/jlljKZ/fkPRsfb8=; b=KKeeHEgwkzQ7bGffr2RggX/J5Aa4SZbzSD22Y5kids44XDdQavj8NZcLWx99fYBZ44 wIcGSDTNGZfBUNPtXTPGSYvprHajbjEV5o3pkN9iozzacYoFjWK0YowgKFPjbyxhUr/N sj9jnBgC4u8sVATjbsjYf0H32w6xoMuBLH4CdlRu4BmmZkHjZvKyjwPmlp+SR6paFCiG 5vHmH2oc5AFL7ysO68tWlkmkvKm/FlEnSh7vog1EsBd11/nWf5R8L6d903K82pOls5oX OByluKj0k3RjPvFjgO9OGw3mKzpAlxhqx6BGxGRs+z2Y0e6+w0Ws8l9y2fI1DXs0KydH 5S3Q== 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=lj8sDb7d71reqkL7KiXT4F0zf7LumGTZoCDr8XzpiedJ2wzPCrCjmaESUsGdByA00f J4HbqQHABjQJclGEFmtECddmbofAqNk1XOSQGqD1c27G+9t0AeMuKpQEsC1I6JRnCPlU +YXmoVf92S3Tk6wYI71GF8kpnOnFzYjIadtfFKasJ09QVXwmKi8YffV9c2VjdoCN/gWw QfwoBrZfbFR1wccOMLz6daWMFTIqdb1eL8MRDFZBUtgXg46zhNfuUz1eC5O0LzXeCbLQ tq1nMcQZnwQZvHq/45EkeqNGL17i0Z6PLBzEjQwVx6E8+f2Hoi9mrcMK8QBJcf0mRqOu 22wQ== X-Gm-Message-State: AOJu0YwOfLAMsJNjZUOvy9OlvOyrjSjzcUyRJh1Vki9iaQkkk1QUHh0f 5eIioeVMhslEpGuADYABkjo3zQ== 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Mon, 09 Oct 2023 03:36:57 -0700 (PDT) X-Spam-Level: ** 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 --- 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; -- 2.34.1