Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3916068rdg; Wed, 18 Oct 2023 09:26:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZuop8toICa7nHJQyrAtRRPZtLLvv5T6OzY4w63ScZ2nRsj89tBxdK4NObt7TnhvklYM2z X-Received: by 2002:a17:903:28c4:b0:1c9:d692:3e98 with SMTP id kv4-20020a17090328c400b001c9d6923e98mr4831767plb.3.1697646391907; Wed, 18 Oct 2023 09:26:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697646391; cv=none; d=google.com; s=arc-20160816; b=zaoEDyvkZTTGJND8gPnFVgHZuHmaR/S12CfWjgpXYwcdnGn9KwkpCCThJB1DE+uKbz 1duupDnnfgaadzSmDQlqnThPryM7hPZe/3UE+zJ1HtuJEIqp1EW8e/NEOkcxmXsAGo5Z 6hVEg4B1PsHo3wV9H5hBJNzvIgNWVp9CsxHYVHyIeLNH9JzejBt1Skb2AZy3jldgSr5b 4qxfF4sTaZ5qsjFWWWudrBIRPCj2O2qTb1/ijDKp/bC4Ta/AsOo33iN4mWsMCVLt6YfB Km/pCbOrIsaNC5/a2cxYfA+vQa3tpfstCXKhXg0QiFMqZN37RXrS6Oi2p27cQdremOyb gesw== 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=/Z47rGwNrqDmeGZQL2+O4h6n0CW6ulSbmPrUuoIVrkg=; fh=aqXlZKEuqBn32GiqXwfBTBEPXMVE+dzbtwpLcW+Wljc=; b=wJ/gP+OmmvJuXJhPWZGU+U9fRFzOawYCp1LnKvpxse8nf6f+VUT47qspZ7nDfBmmo4 lRZE+n3U+hJrv+K/f/pB9aJ98xr4ibVA2NxGS/V8pzggMWCEK9XYNXPA5xMvDS56vO/e s+H7MykGEevxmW8nmWW5zLP+YBipIfmZtq/y21Qe6/UarBP12L6lfPNwtuLhMkgdtAbl OCT5hAhuOXowZV+NdPsdT7mRxzDuh13hf6+Lig9WjtcabZZ1ydSROFrH2X7bfuZyYliO EARP5tuQqRhIWrpMMhWIndVX+zavnguSuT7cM6ZBMrd9v5J0yK2McJ9Gi2JqR02jgQuG mvtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f85jNDyj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id v10-20020a1709028d8a00b001c5d09c7b0dsi181618plo.458.2023.10.18.09.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:26:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f85jNDyj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 A03CA804DD9A; Wed, 18 Oct 2023 09:26:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230492AbjJRQ0C (ORCPT + 99 others); Wed, 18 Oct 2023 12:26:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231615AbjJRQZy (ORCPT ); Wed, 18 Oct 2023 12:25:54 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE8DE111 for ; Wed, 18 Oct 2023 09:25:49 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40837ebba42so11655235e9.0 for ; Wed, 18 Oct 2023 09:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697646348; x=1698251148; 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=/Z47rGwNrqDmeGZQL2+O4h6n0CW6ulSbmPrUuoIVrkg=; b=f85jNDyj+YCeVocfqQ9Wnfs6HCEUPsoxfnev59jx74f0GdAE6LnN6JA1kxfwn44r0M QcVN7Ajxs4kNGmRdV91XHS5Bf1UALo7T1EguSZOqENx96Qe2d/+ExLpKKIhs1JBk3B59 o3ekzF3iMtipAtwxwcYx0KL1AyMDSdwQTJq7oqTJ3tOhAyatLMYYLUYmHLhxBBD8dKI9 +LMqXKotmIDdJLSjCVO4QvGu8lpa1JlnfYYDR5ST9NPaVElWRC6o31ezWTF0ZX3PwgMi xg09U1UdhUXKCtLMlM71gEnWP4mF4zSN0KvGVwUJUkfUQQbHe0NCpUnRzRYHibAr29Tk 7PpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697646348; x=1698251148; 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=/Z47rGwNrqDmeGZQL2+O4h6n0CW6ulSbmPrUuoIVrkg=; b=jZwp6Lo7A/0hk027RPr5wrwBhFqTpiY4BVa0QDsjKGzWjDhAoI4FX3omGYYLuoGqkr GhgCv8SP0k47eiuEgW2b87tXdDBLcWA/++6EXa6ihUeJzlLUMd47hVv4KfUrgqHqMfYL tNR6LMUxJ5tmCVEh7rpVpTxf0EB7I3pLAM2U90aNGqigXxwLepIAQrRN3VAh3AAx7Da7 ch6NKhGmoVh9NTvtrd5scW5PFXNuYvvvwBS4nFS+21XQx3iBl+mizDV/psDp9Jx1QQHb 37D9XeVqUIbM1GNE7HCgoVoPmHcckZFjkL+TYmIg+/yYHTMunZzF7/aDWhBoOxyyotwf bDZQ== X-Gm-Message-State: AOJu0YyQ4lBTGGmZ93KK+Xrp17TTOqwKhWvXagNI2lTi4/66nG0EGa8A VKxMEsKG1wpOP+qTtLnhZWlUqg== X-Received: by 2002:a05:600c:4f15:b0:401:bdd7:49ae with SMTP id l21-20020a05600c4f1500b00401bdd749aemr4828030wmq.18.1697646348170; Wed, 18 Oct 2023 09:25:48 -0700 (PDT) Received: from vingu-book.. ([2a01:e0a:f:6020:fcf4:9d83:8d0d:39aa]) by smtp.gmail.com with ESMTPSA id q12-20020a05600c2e4c00b0040648217f4fsm2033503wmf.39.2023.10.18.09.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:25:47 -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 v3 2/6] cpufreq: use the fixed and coherent frequency for scaling capacity Date: Wed, 18 Oct 2023 18:25:36 +0200 Message-Id: <20231018162540.667646-3-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018162540.667646-1-vincent.guittot@linaro.org> References: <20231018162540.667646-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_NONE, SPF_HELO_NONE,SPF_PASS 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]); Wed, 18 Oct 2023 09:26:11 -0700 (PDT) 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 --- 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