From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AF592AEFE; Thu, 3 Jul 2025 09:29:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751534969; cv=none; b=ZfqgIo0v+jA07Q5/BfaIjIFHrwkdmHUyS4hbmon7DcIEgFGi7Bsm36LcQ/hVfBCtlffJ7sq28low3xGv+DUU8mkw+a6VgSFi9tXGHhUF6KWOQG5sGxQyvc84z6oqMI9AmoCmhAPJvkTw4xC5rFgOUFtks/MCrjPiKergmTDWBqs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751534969; c=relaxed/simple; bh=IkMlE040LUQcsX0QjWWAw+3qdRDLQ2DX/AwnoQdxHP4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QuEpu21BTkBHCXu1JsPedSD3oQw1Gy/zrqmIJ/yL3/AsFC1nnXenNdiJDKWLcDReeQs2RtnMfhCj+sxj0qVGE4DUQKtfRYgvjQxfMxM/qY6L0FmpYNpwC320mUYGpZYcIue/9ZBiFNhoP+XAfr+7Kdt04KBb5IsyLxdiBfL+bsY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 D2E0E1655; Thu, 3 Jul 2025 02:29:11 -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 6C3FE3F58B; Thu, 3 Jul 2025 02:29:22 -0700 (PDT) Date: Thu, 3 Jul 2025 11:29:12 +0200 From: Beata Michalska To: Prashant Malani Cc: Jie Zhan , Ionela Voinescu , Ben Segall , Dietmar Eggemann , Ingo Molnar , Juri Lelli , open list , "open list:CPU FREQUENCY SCALING FRAMEWORK" , Mel Gorman , Peter Zijlstra , "Rafael J. Wysocki" , Steven Rostedt , Valentin Schneider , Vincent Guittot , Viresh Kumar , z00813676 Subject: Re: [PATCH v2 2/2] cpufreq: CPPC: Dont read counters for idle CPUs Message-ID: References: <20250619000925.415528-1-pmalani@google.com> <20250619000925.415528-3-pmalani@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi Prashant, On Wed, Jul 02, 2025 at 11:38:11AM -0700, Prashant Malani wrote: > Hi All, > > Ionela, Beata, could you kindly review ? > I've totally missed that - apologies for that. Will try to have a look within next day or two. --- BR Beata > On Fri, 27 Jun 2025 at 10:07, Prashant Malani wrote: > > > > Hi Jie, > > > > On Fri, 27 Jun 2025 at 00:55, Jie Zhan wrote: > > > > > > > > > Hi Prashant, > > > > > > Sorry for a late reply as I'm busy on other stuff and this doesn't seem to > > > be an easy issue to solve. > > > > > > > No worries, the ping was in general to all the people in the thread :) > > > > > For the latest kernel, [1] provides a new 'cpuinfo_avg_freq' sysfs file to > > > reflect the frequency base on AMUs, which is supposed to be more stable. > > > Though it usually shows 'Resource temporarily unavailable' on my platform > > > at the moment and looks a bit buggy. > > > > > > Most of the related discussions can be found in the reference links in [1]. > > > [1] https://lore.kernel.org/linux-pm/20250131162439.3843071-1-beata.michalska@arm.com/ > > > > > > As reported, the current frequency sampling method may show an large error > > > on 1) 100% load, 2) high memory access pressure, 3) idle cpus in your case. > > > > > > AFAICS, they may all come from the unstable latency accessing remote AMUs > > > for 4 times but delaying a fixed 2us sampling window. > > > > I tried applying [1] which consolidates the ref and del register reads > > into 1 IPI, but that did not make a difference. The values still > > fluctuate wildly. > > > > > > > > Increase the sampling windows seems to help but also increase the time > > > overhead, so that's not favoured by people. > > > > > > > This experiment did not appear to help in our case. It's a point in > > the direction that this method is inherently inaccurate during idle > > situations. > > > > > On 20/06/2025 13:07, Prashant Malani wrote: > > > > Hi Jie, > > > > On Thu, 19 Jun 2025 at 20:53, Jie Zhan wrote: > > > >> On 19/06/2025 08:09, Prashant Malani wrote: > > > >>> t0: ref=899127636, del=3012458473 > > > >>> t1: ref=899129626, del=3012466509 > > > >>> perf=40 > > > >> > > > >> In this case, the target cpu is mostly idle but not fully idle during the > > > >> sampling window since the counter grows a little bit. > > > >> Perhaps some interrupts happen to run on the cpu shortly. > > > > > > Check back here again, I don't think it 'mostly idle'. > > > Diff of ref counters is around 2000, and I guess the ref counter freq is > > > 1GHz on your platform? That's exactly 2us, so the target cpu is mostly > > > busy. > > I think it is pertinent to note: the actual act of reading the CPPC counters > will (at least for ACPI_ADR_SPACE_FIXED_HARDWARE counters) > wake the CPU up, so even if a CPU *was* idle, the reading of the counters > calls cpc_read_ffh() [1] which does an IPI on the target CPU [2] thus waking > it up from WFI. > > And that brings us back to the original assertion made in this patch: > the counter values are quite unreliable when the CPU is in this > idle (or rather I should correct that to, waking from WFI) state. > > This work around probably hits more types of implementations, but > I can't see another way to limit it to only ARM FFH. Open to suggestions! > > [1] https://elixir.bootlin.com/linux/v6.15.4/source/arch/arm64/kernel/topology.c#L482 > [2] https://elixir.bootlin.com/linux/v6.15.4/source/arch/arm64/kernel/topology.c#L453 > > Best regards, > > -Prashant > > > -- > -Prashant