Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3956575rdg; Wed, 18 Oct 2023 10:29:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGptF+VjQSBnhO8YpSE0Xs+8BJ6ZtJ/ICPtFP5ePiAKFNJcf4gtKUPZtPu1v9R/ACZ6PiS1 X-Received: by 2002:a05:6a00:21d0:b0:6bc:ce7a:6f39 with SMTP id t16-20020a056a0021d000b006bcce7a6f39mr6512434pfj.32.1697650156481; Wed, 18 Oct 2023 10:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697650156; cv=none; d=google.com; s=arc-20160816; b=lRsZeV95+Jdm/medW1RKSRohLhk6nFh5DtreCkDfPhFKQ/LejPHZMWqx/FCjr6yJ5j FiyIDe9rk5VhFWIM2qm6A74W0GtHYaA2Bxm5eiO8yOqftXwOFc3n05wQGiKCxWx5H3jw 6XwMsqJhNDqNAB4b+VJGxchNsbEchvGGv3DeXuDpBUtRMBTetMxRyxnajb7bcd//siYd waQllwMLH/KNQKWFbrN2vMCeSoqnbvD0bztXvJWXQqhzbjklgOvsw4FQcpWHzgnrxitQ OPnfwtTQ4/+K7qB4xJMf8N5qac7JVwOf9WhKkglj6BD0tNm965iWFyXSOErpolycPqoO vDvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=pH5SA7uXc+xftFhRzM7GTfpoxPVl3fU1alXmQpfCEIE=; fh=PSWA2Cew5QTMD2HMgWzLQIgCaRiQdRH2PK6uelRrXPs=; b=E79AUodb0KV7D1YfDYZKmQvc2LevY6yuopzzvewr2FIeLhiH7jwDnt0p/WLqnuamv8 zGLBUJa5ng4terNSawoRgP9JKVMtoJrjONgOem2th5QiNW4gUa/g/Trx+d7oeJdYQLtj Jxrl+KZ59kWlopIlG1QwViHp1MPJg0g1zPtnnubgpsXNz08KLXlU+XWPRWjmtrakcrj5 z6q771git923BJY9TCOjp6BlEKB/jNvV0qJJTWXKwV+0POPwx3fjHnj6n8INJoo8qLFz y1iceoAesGG9CswsDNZ+JiQ2MaB2oyW1K/4TFeF7EWVTo9Z3BH7ysSpyVywwvlEKsnWN rfZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id h18-20020a056a001a5200b0068fe12b361dsi4403973pfv.249.2023.10.18.10.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:29:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id AE02980FCE34; Wed, 18 Oct 2023 10:29:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230304AbjJRR3C convert rfc822-to-8bit (ORCPT + 99 others); Wed, 18 Oct 2023 13:29:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbjJRR24 (ORCPT ); Wed, 18 Oct 2023 13:28:56 -0400 Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C6F426BF; Wed, 18 Oct 2023 10:22:53 -0700 (PDT) Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-57f137dffa5so1006595eaf.1; Wed, 18 Oct 2023 10:22:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697649772; x=1698254572; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KGquFH/+a1RdzcZc8K6W68eVVi5OATd0jI25tQHlZv8=; b=LPHeetMzg/ILxOYIK9wyAxfSZnS+4zcqkRAKzCKSXPhptbNRcF+fUvytUMwX3MjShH +5rrxNob2d/BZZO59Uo/FqEhnxngyIrL3TcODribDkl6Oga6whJtQOdY/H1wA0pS6tUU wxNkC0gIcjgISK4Rnr7aJrDE4es/AEFT3IKeWqZNxRuvr4o0JYA1R/KIISL5kIpTqD1q GardMiSxPKcO3S+a9Z7IO3WBm3om5txBmetKnsUqXJQx+Nv1IaLQCEXyqlEWw6oAQvPU 2cd7Lg64rEA1g6T7PnxrLiNwQSijCGSHnvPCTnkOXFysgDtfBI2zFYvsc+C42WxRrpY4 6+XA== X-Gm-Message-State: AOJu0YzYaTGEVjRAIurAw43EOcE2TRrR6Bwu3nwTV2nB7xcI/nCq7vmu ZRU7pR8StG+MpVAGMhHj7bifyCi1MunWtAkxHe5ODQSC X-Received: by 2002:a4a:e1cd:0:b0:581:feb5:ac87 with SMTP id n13-20020a4ae1cd000000b00581feb5ac87mr2078567oot.1.1697649771877; Wed, 18 Oct 2023 10:22:51 -0700 (PDT) MIME-Version: 1.0 References: <20231018162540.667646-1-vincent.guittot@linaro.org> <20231018162540.667646-4-vincent.guittot@linaro.org> In-Reply-To: <20231018162540.667646-4-vincent.guittot@linaro.org> From: "Rafael J. Wysocki" Date: Wed, 18 Oct 2023 19:22:40 +0200 Message-ID: Subject: Re: [PATCH v3 3/6] cpufreq/schedutil: use a fixed reference frequency To: Vincent Guittot Cc: 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, conor.dooley@microchip.com, suagrfillet@gmail.com, ajones@ventanamicro.com, lftan@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 18 Oct 2023 10:29:12 -0700 (PDT) On Wed, Oct 18, 2023 at 6:25 PM Vincent Guittot wrote: > > cpuinfo.max_freq can change at runtime because of boost as an example. This > implies that the value could be different than the one that has been > used when computing the capacity of a CPU. > > The new arch_scale_freq_ref() returns a fixed and coherent reference > frequency that can be used when computing a frequency based on utilization. > > Use this arch_scale_freq_ref() when available and fallback to > policy otherwise. > > Signed-off-by: Vincent Guittot > Reviewed-by: Lukasz Luba > Tested-by: Lukasz Luba Acked-by: Rafael J. Wysocki > > --- > kernel/sched/cpufreq_schedutil.c | 26 ++++++++++++++++++++++++-- > 1 file changed, 24 insertions(+), 2 deletions(-) > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > index 458d359f5991..6e4030482ae8 100644 > --- a/kernel/sched/cpufreq_schedutil.c > +++ b/kernel/sched/cpufreq_schedutil.c > @@ -114,6 +114,28 @@ static void sugov_deferred_update(struct sugov_policy *sg_policy) > } > } > > +/** > + * cpufreq_get_capacity_ref_freq - get the reference frequency of a given CPU that > + * has been used to correlate frequency and compute capacity. > + * @policy: the cpufreq policy of the CPU in question. > + * @use_current: Fallback to current freq instead of policy->cpuinfo.max_freq. > + * > + * Return: the reference CPU frequency to compute a capacity. > + */ > +static __always_inline > +unsigned long get_capacity_ref_freq(struct cpufreq_policy *policy) > +{ > + unsigned int freq = arch_scale_freq_ref(policy->cpu); > + > + if (freq) > + return freq; > + > + if (arch_scale_freq_invariant()) > + return policy->cpuinfo.max_freq; > + > + return policy->cur; > +} > + > /** > * get_next_freq - Compute a new frequency for a given cpufreq policy. > * @sg_policy: schedutil policy object to compute the new frequency for. > @@ -140,10 +162,10 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, > unsigned long util, unsigned long max) > { > struct cpufreq_policy *policy = sg_policy->policy; > - unsigned int freq = arch_scale_freq_invariant() ? > - policy->cpuinfo.max_freq : policy->cur; > + unsigned int freq; > > util = map_util_perf(util); > + freq = get_capacity_ref_freq(policy); > freq = map_util_freq(util, freq, max); > > if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update) > -- > 2.34.1 >