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 8367AC4345F for ; Tue, 16 Apr 2024 15:46:52 +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:In-Reply-To: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=FXkZ72qFBDJToSDCDJi3ysso5TQPgD3BjCE/J/xB9Do=; b=i9O6wZqVNsBTV9 B4mm9WMwjS6tvGsN24IuKnxl19lrVFQoHF5IOo+vZi3gHE4iVvJ9cHy4bvG74EQ+mViHDfGsYKM0b QtEsFRfmQEG1kW4VsHzmIqfIY0BYKadultVAbGmS2mWi8+xG1Mmv+Zhvf3k8UwLKLEnhpf6kFbQMw HdQzAoPwhRl/yDD8MJLq6BOzG6wQUy4EdC9FHJhbPhYlQBS1YVam/q25NaEiMMpC5KHSk7QiQVmpR Nhm3fnF3mGqstfA2oS1VpZ7ZnUsR0uyPx1DyuJyvfyyaF3+h7JLjdUxELoeEB+zqumZKJft7Z9s71 GiRTdouGpWfl5f+M9ghw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwl16-0000000Cow2-0GPf; Tue, 16 Apr 2024 15:46:40 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwl12-0000000CovC-3cB2 for linux-arm-kernel@lists.infradead.org; Tue, 16 Apr 2024 15:46:39 +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 AD564339; Tue, 16 Apr 2024 08:46:58 -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 BEF0D3F792; Tue, 16 Apr 2024 08:46:27 -0700 (PDT) Date: Tue, 16 Apr 2024 17:46:18 +0200 From: Beata Michalska To: Vanshidhar Konda Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ionela.voinescu@arm.com, sudeep.holla@arm.com, will@kernel.org, catalin.marinas@arm.com, vincent.guittot@linaro.org, sumitg@nvidia.com, yang@os.amperecomputing.com, lihuisong@huawei.com, viresh.kumar@linaro.org Subject: Re: [PATCH v4 4/4] cpufreq: Use arch specific feedback for cpuinfo_cur_freq Message-ID: References: <20240405133319.859813-1-beata.michalska@arm.com> <20240405133319.859813-5-beata.michalska@arm.com> <76zutrz47zs6i2cquvjo2qn7myxpq7e3c6alhper7n3wrkhf5h@22l5t5pio2cd> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <76zutrz47zs6i2cquvjo2qn7myxpq7e3c6alhper7n3wrkhf5h@22l5t5pio2cd> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240416_084637_010996_894A7560 X-CRM114-Status: GOOD ( 29.86 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Apr 15, 2024 at 09:23:10PM -0700, Vanshidhar Konda wrote: > On Fri, Apr 05, 2024 at 02:33:19PM +0100, Beata Michalska wrote: > > Some architectures provide a way to determine an average frequency over > > a certain period of time based on available performance monitors (AMU on > > ARM or APERF/MPERf on x86). With those at hand, enroll arch_freq_get_on_cpu > > into cpuinfo_cur_freq policy sysfs attribute handler, which is expected to > > represent the current frequency of a given CPU, as obtained by the hardware. > > This is the type of feedback that counters do provide. > > > > --- snip --- > > While testing this patch series on AmpereOne system, I simulated CPU > frequency throttling when the system is under power or thermal > constraints. > > In this scenario, based on the user guilde, I expect scaling_cur_freq > is the frequency the kernel requests from the hardware; cpuinfo_cur_freq > is the actual frequency that the hardware is able to run at during the > power or thermal constraints. There has been a discussion on scaling_cur_freq vs cpuinfo_cur_freq [1]. The guidelines you are referring here (assuming you mean [2]) are kinda out-of-sync already as scaling_cur_freq has been wired earlier to use arch specific feedback. As there was no Arm dedicated implementation of arch_freq_get_on_cpu, this went kinda unnoticed. The conclusion of the above mentioned discussion (though rather unstated explicitly) was to keep the current behaviour of scaling_cur_freq and align both across different archs: so with the patches, both attributes will provide hw feedback on current frequency, when available. Note that if we are to adhere to the docs cpuinfo_cur_freq is the place to use the counters really. That change was also requested through [3] Adding @Viresh in case there was any shift in the tides .... > > The AmpereOne system I'm testing on has the following configuration: > - Max frequency is 3000000 > - Support for AMU registers > - ACPI CPPC feedback counters use PCC register space > - Fedora 39 with 6.7.5 kernel > - Fedora 39 with 6.9.0-rc3 + this patch series > > With 6.7.5 kernel: > Core scaling_cur_freq cpuinfo_cur_freq > ---- ---------------- ---------------- > 0 3000000 2593000 > 1 3000000 2613000 > 2 3000000 2625000 > 3 3000000 2632000 > So if I got it right from the info you have provided the numbers above are obtained without applying the patches. In that case, scaling_cur_freq will use policy->cur (in your case) showing last frequency set, not necessarily the actual freq, whereas cpuinfo_cur_freq uses __cpufreq_get and AMU counters. > With 6.9.0-rc3 + this patch series: > Core scaling_cur_freq cpuinfo_cur_freq > ---- ---------------- ---------------- > 0 2671875 2671875 > 1 2589632 2589632 > 2 2648437 2648437 > 3 2698242 2698242 > With the patches applied both scaling_cur_freq and cpuinfo_cur_freq will use AMU counters, or fie scale factor obtained based on AMU counters to be more precise: both should now show similar/same frequency (as discussed in [1]) I'd say due to existing implementation for scaling_cur_freq (which we cannot change at this point) this is unavoidable. > In the second case we can't identify that the CPU frequency is > being throttled by the hardware. I noticed this behavior with > or without this patch. > I am not entirely sure comparing the two should be a way to go about throttling (whether w/ or w/o the changes). It would probably be best to refer to thermal sysfs and get a hold of cur_state which should indicate current throttle state: /sys/class/thermal/thermal_zone[0-*]/cdev[0-*]/cur_state with values above '0' implying ongoing throttling. The appropriate thermal_zone can be identified through 'type' attribute. Thank you for giving those patches a spin. --- BR Beata --- [1] https://lore.kernel.org/all/20230609043922.eyyqutbwlofqaddz@vireshk-i7/ [2] https://elixir.bootlin.com/linux/latest/source/Documentation/admin-guide/pm/cpufreq.rst#L197 [3] https://lore.kernel.org/lkml/2cfbc633-1e94-d741-2337-e1b0cf48b81b@nvidia.com/ --- > Thanks, > Vanshi _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel