From mboxrd@z Thu Jan 1 00:00:00 1970 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 21708D1AD45 for ; Wed, 16 Oct 2024 20:50:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wbIve98BaKDgoqFYFdKCe9wsqQYFUXcwNIIJrzJ8D3U=; b=Ho8Ll0XSluoy7X0HP+rbefvwvA QT5aZ0IcZ2/jd2ZS8W5pqQGdacQToYGv7JSsY2JDA9IUtzFsVznlUfmVihgX2wX2PjxQNAhPLwHM4 yIl9qq+BpJF1i2pLLrWoL9D9eKNb9EsqwrlwHccXmjvken0FRx6Z+fx80h+qzcPttzTHTGdmJL/Wl 11Yi+8ilHn+gPS8W6uhd83UPkLHkrALEyothaTF5hvUyD4GCPrjSavmUSUekRuCjTUfaxFu3669kx TAjtSNyvMh1/mMedzMyTodnYmXsse6A+rTkO0Mk5Ai2l9uo6Ina7knHGIzVBCNyM9J6gSme+fQe0O 01OggJRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1AyX-0000000CzV3-2SR4; Wed, 16 Oct 2024 20:50:33 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1AuV-0000000CzDg-2du7 for linux-arm-kernel@lists.infradead.org; Wed, 16 Oct 2024 20:46:25 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 91F32FEC; Wed, 16 Oct 2024 13:46:49 -0700 (PDT) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9DEC03F58B; Wed, 16 Oct 2024 13:46:15 -0700 (PDT) Date: Wed, 16 Oct 2024 22:45:35 +0200 From: Beata Michalska To: Sumit Gupta Cc: Vanshidhar Konda , viresh.kumar@linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, ionela.voinescu@arm.com, sudeep.holla@arm.com, will@kernel.org, catalin.marinas@arm.com, rafael@kernel.org, yang@os.amperecomputing.com, lihuisong@huawei.com, zhanjie9@hisilicon.com, linux-tegra , Bibek Basu Subject: Re: [PATCH v7 3/4] arm64: Provide an AMU-based version of arch_freq_avg_get_on_cpu Message-ID: References: <20240913132944.1880703-1-beata.michalska@arm.com> <20240913132944.1880703-4-beata.michalska@arm.com> <5y3yz2ct2o42c53dc6rwpse3andstjx74lowt2b3hohj4ogbct@nu2szdnxvxid> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241016_134623_781799_79C7CC6C X-CRM114-Status: GOOD ( 52.16 ) 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 On Mon, Oct 14, 2024 at 11:16:36PM +0530, Sumit Gupta wrote: > > > On 11/10/24 21:59, Vanshidhar Konda wrote: > > External email: Use caution opening links or attachments > > > > > > On Thu, Oct 10, 2024 at 01:08:23PM GMT, Beata Michalska wrote: > > > On Thu, Oct 03, 2024 at 02:54:22PM -0700, Vanshidhar Konda wrote: > > > > On Thu, Oct 03, 2024 at 11:39:54PM GMT, Beata Michalska wrote: > > > > > On Thu, Sep 26, 2024 at 04:21:14PM -0700, Vanshidhar Konda wrote: > > > > > > On Thu, Sep 26, 2024 at 12:34:01PM GMT, Beata Michalska wrote: > > > > > > > On Tue, Sep 17, 2024 at 05:41:09PM +0530, Sumit Gupta wrote: > > > > > > > > Hi Beata, > > > > > > > Hi Sumit, > > > > > > > > > > > > > > > > Thank you for the patches. > > > > > > > Thank you for having a look at those. > > > > > > > > > > > > > > > > On 13/09/24 18:59, Beata Michalska wrote: > > > > > > > > > External email: Use caution opening links or attachments > > > > > > > > > > > > > > > > > > > > > > > > > > > With the Frequency Invariance Engine (FIE) being > > > > already wired up with > > > > > > > > > sched tick and making use of relevant (core counter > > > > and constant > > > > > > > > > counter) AMU counters, getting the average frequency > > > > for a given CPU, > > > > > > > > > can be achieved by utilizing the frequency scale > > > > factor which reflects > > > > > > > > > an average CPU frequency for the last tick period length. > > > > > > > > > > > > > > > > > > The solution is partially based on APERF/MPERF > > > > implementation of > > > > > > > > > arch_freq_get_on_cpu. > > > > > > > > > > > > > > > > > > Suggested-by: Ionela Voinescu > > > > > > > > > Signed-off-by: Beata Michalska > > > > > > > > > --- > > > > > > > > >   arch/arm64/kernel/topology.c | 109 > > > > +++++++++++++++++++++++++++++++---- > > > > > > > > >   1 file changed, 99 insertions(+), 10 deletions(-) > > > > > > > > > > > > > > > > > --- snip ---- > > > > > > > > > > > > > > > > > > > >     .. > > > > > > > >   freq_comput: > > > > > > > >     scale = arch_scale_freq_capacity(cpu); > > > > > > > >     freq = scale * arch_scale_freq_ref(cpu); > > > > > > > >   ---- > > > > > > > > > > > > > > > This boils down to the question what that function, and > > > > the information it > > > > > > > provides, represent really. The 'unknown' here simply says > > > > the CPU has been idle > > > > > > > for a while and as such the frequency data is a bit stale > > > > and it does not > > > > > > > represent the average freq the CPU is actually running at > > > > anymore, which is > > > > > > > the intention here really. Or, that the given CPU is a > > > > non-housekeeping one. > > > > > > > Either way I believe this is a useful information, instead > > > > of providing > > > > > > > stale data with no indication on whether the frequency is > > > > really the 'current' > > > > > > > one or not. > > > > > > > > > > > > > > If that is somehow undesirable we can discuss this > > > > further, though I'd rather > > > > > > > avoid exposing an interface where the feedback provided is open to > > > > > > > interpretation at all times. > > > > > > > > > > > > Would it make sense to identify that the frequency reporting > > > > is unknown due to > > > > > > cpu being idle vs some other issue like being a > > > > non-housekeeping CPU? Would > > > > > > returning a value of 0 make it easier for tools to represent > > > > that the CPU is > > > > > > currently idle? > > > > > That is an option. > > > > > Another one would be to return an error for those cases. This > > > > would make it > > > > > easier to distinguish between valid frequency &/| idle CPU vs > > > > tickless CPU > > > > > (EINVAL vs ENOENT) ? > > > > > > > > > > > > > That seems like a good idea but I suspect it would be confusing > > > > to the end user. > > > > > > > > If a user runs `cat > > > > /sys/devices/system/cpu/cpu2/cpuinfo_avg_freq` they would > > > > get an error in some cases or get a number in some other iterations. > > > > > > > That is a fair point but I am not entirely convinced using '0' > > > instead makes > > > things any more clearer as this is in no way a valid CPU frequency. > > > As long as we document the expected behaviour keeping the interface well > > > defined,  both options should be fine I guess. > > > > > > > Another option could be to list out the reason as 'idle' or 'no entry' > > instead of > > returning EINVAL or ENOENT. These wouldn't be valid values either but > > cat on the > > sysfs node wouldn't return an error. > > > > Thanks, > > Vanshidhar > > > > Ya, listing the clear reason sounds better. > > Thank you, > Sumit Gupta > I'd still prefer returning an error as that is a clear indication on failure upon read. Furthermore, that would also make that attribute stick to single-type rule for sysfs, which is currently not the case and will not be if we return 'idle' or 'no entry'. That said, I am happy to make that change if that would be the final decision and that one is not mine, as the change is ultimately the cpufreq one. --- BR Beata > > > @Viresh: what is your opinion on that one ? > > > > > > --- > > > BR > > > Beata > > > > Thanks, > > .... > > > > > > > > > > +               cpu = ref_cpu; > > > > > > > > > +               goto retry; > > > > > > > > > +       } > > > > > > > > > +       /* > > > > > > > > > +        * Reversed computation to the one used to determine > > > > > > > > > +        * the arch_freq_scale value > > > > > > > > > +        * (see amu_scale_freq_tick for details) > > > > > > > > > +        */ > > > > > > > > > +       scale = arch_scale_freq_capacity(cpu); > > > > > > > > > +       freq = scale * arch_scale_freq_ref(cpu); > > > > > > > > > +       freq >>= SCHED_CAPACITY_SHIFT; > > > > > > > > > +       return freq; > > > > > > > > > +} > > > > > > > > > + > > > > > > > > > > > > > > > > >   static void amu_fie_setup(const struct cpumask *cpus) > > > > > > > > >   { > > > > > > > > >          int cpu; > > > > > > > > > -- > > > > > > > > > 2.25.1 > > > > > > > > >