From: Beata Michalska <beata.michalska@arm.com>
To: Jie Zhan <zhanjie9@hisilicon.com>
Cc: 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,
viresh.kumar@linaro.org, sumitg@nvidia.com,
yang@os.amperecomputing.com, vanshikonda@os.amperecomputing.com,
lihuisong@huawei.com
Subject: Re: [PATCH v7 1/4] cpufreq: Introduce an optional cpuinfo_avg_freq sysfs entry
Date: Thu, 26 Sep 2024 12:42:45 +0200 [thread overview]
Message-ID: <ZvU6pdjAljs55dqH@arm.com> (raw)
In-Reply-To: <09887c82-2813-59c3-2ff2-0b7223b37b9e@hisilicon.com>
On Wed, Sep 25, 2024 at 04:58:36PM +0800, Jie Zhan wrote:
> Hi Beata,
Hi Jie
>
> Great thanks for the update.
>
> On 13/09/2024 21:29, Beata Michalska wrote:
> > Currently the CPUFreq core exposes two sysfs attributes that can be used
> > to query current frequency of a given CPU(s): namely cpuinfo_cur_freq
> > and scaling_cur_freq. Both provide slightly different view on the
> > subject and they do come with their own drawbacks.
> >
> > cpuinfo_cur_freq provides higher precision though at a cost of being
> > rather expensive. Moreover, the information retrieved via this attribute
> > is somewhat short lived as frequency can change at any point of time
> > making it difficult to reason from.
> >
> > scaling_cur_freq, on the other hand, tends to be less accurate but then
> > the actual level of precision (and source of information) varies between
> > architectures making it a bit ambiguous.
> >
> > The new attribute, cpuinfo_avg_freq, is intended to provide more stable,
> > distinct interface, exposing an average frequency of a given CPU(s), as
> > reported by the hardware, over a time frame spanning no more than a few
> > milliseconds. As it requires appropriate hardware support, this
> > interface is optional.
> >
> > Signed-off-by: Beata Michalska <beata.michalska@arm.com>
> > ---
> > Documentation/admin-guide/pm/cpufreq.rst | 10 ++++++++
> > drivers/cpufreq/cpufreq.c | 31 ++++++++++++++++++++++++
> > include/linux/cpufreq.h | 1 +
> > 3 files changed, 42 insertions(+)
> >
> > diff --git a/Documentation/admin-guide/pm/cpufreq.rst b/Documentation/admin-guide/pm/cpufreq.rst
> > index fe1be4ad88cb..2204d6132c05 100644
> > --- a/Documentation/admin-guide/pm/cpufreq.rst
> > +++ b/Documentation/admin-guide/pm/cpufreq.rst
> > @@ -248,6 +248,16 @@ are the following:
> > If that frequency cannot be determined, this attribute should not
> > be present.
> >
> > +``cpuinfo_avg_freq``
> > + An average frequency (in KHz) of all CPUs belonging to a given policy,
> > + derived from a hardware provided feedback and reported on a time frame
> > + spanning at most few milliseconds.
>
> I don't think it's necessary to put the 'at most few milliseconds'
> limitation on.
>
> It's supposed to be fine for other platforms to implement the interface
> with a longer time period, e.g. a few seconds, in the future. Otherwise,
> this would probably force the implementation of 'cpuinfo_avg_freq' to be
> binded with the 'scale freq tick' stuff.
Actually the sched_tick was intentionally omitted from the description
to avoid associating one with another.
Not really sure how useful it would be to have a longer time-frames for the
average frequency though.
It is still intended to be rather accurate - thus the 'at most few
milliseconds' statement. Extending that period reduces the accuracy.
If we allow that - meaning getting average frequency over different time-frame
spans , we introduce yet again platform specific behaviour for common interface,
which might not be that desired.
>
> > +
> > + This is expected to be based on the frequency the hardware actually runs
> > + at and, as such, might require specialised hardware support (such as AMU
> > + extension on ARM). If one cannot be determined, this attribute should
> > + not be present.
> > +
> > ``cpuinfo_max_freq``
> > Maximum possible operating frequency the CPUs belonging to this policy
> > can run at (in kHz).
>
> ...
>
> > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> > index d4d2f4d1d7cb..48262073707e 100644
> > --- a/include/linux/cpufreq.h
> > +++ b/include/linux/cpufreq.h
> > @@ -1195,6 +1195,7 @@ static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_
> > #endif
> >
> > extern unsigned int arch_freq_get_on_cpu(int cpu);
> > +extern int arch_freq_avg_get_on_cpu(int cpu);
>
> It's werid to have two different functions with mostly the same behaviour,
> i.e. arch_freq_get_on_cpu() and arch_freq_avg_get_on_cpu().
>
> Appreciated that there would be some capatibility work with x86 at the
> moment if merging them, e.g. return type, default implementation, impact on
> some userspace tools, etc.
The intention here was indeed to have a clean distinction between the two.
>
> Anyhow, are they supposed to be merged in the near future?
That depends on any further comments on that new sysfs attribute I guess.
---
Thanks
Beata
>
>
> Thanks,
> Jie
> >
> > #ifndef arch_set_freq_scale
> > static __always_inline
next prev parent reply other threads:[~2024-09-26 10:43 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-13 13:29 [PATCH v7 0/4] Add support for AArch64 AMUv1-based average freq Beata Michalska
2024-09-13 13:29 ` [PATCH v7 1/4] cpufreq: Introduce an optional cpuinfo_avg_freq sysfs entry Beata Michalska
2024-09-25 8:58 ` Jie Zhan
2024-09-26 10:42 ` Beata Michalska [this message]
2024-10-29 7:04 ` Viresh Kumar
2024-10-29 11:31 ` Rafael J. Wysocki
2024-11-04 8:01 ` Beata Michalska
2024-11-04 13:26 ` Rafael J. Wysocki
2024-11-04 8:00 ` Beata Michalska
2024-11-08 6:28 ` Viresh Kumar
2024-09-13 13:29 ` [PATCH v7 2/4] arm64: amu: Delay allocating cpumask for AMU FIE support Beata Michalska
2024-09-13 13:29 ` [PATCH v7 3/4] arm64: Provide an AMU-based version of arch_freq_avg_get_on_cpu Beata Michalska
2024-09-17 12:11 ` Sumit Gupta
2024-09-26 10:34 ` Beata Michalska
2024-09-26 23:21 ` Vanshidhar Konda
2024-10-03 21:39 ` Beata Michalska
2024-10-03 21:54 ` Vanshidhar Konda
2024-10-10 11:08 ` Beata Michalska
2024-10-11 16:29 ` Vanshidhar Konda
2024-10-14 17:46 ` Sumit Gupta
2024-10-16 20:45 ` Beata Michalska
2024-10-29 6:53 ` Viresh Kumar
2024-11-04 7:58 ` Beata Michalska
2024-09-13 13:29 ` [PATCH v7 4/4] arm64: Update AMU-based freq scale factor on entering idle Beata Michalska
2024-10-16 10:59 ` [PATCH v7 0/4] Add support for AArch64 AMUv1-based average freq Catalin Marinas
2024-10-16 20:51 ` Beata Michalska
2024-10-27 18:16 ` Beata Michalska
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZvU6pdjAljs55dqH@arm.com \
--to=beata.michalska@arm.com \
--cc=catalin.marinas@arm.com \
--cc=ionela.voinescu@arm.com \
--cc=lihuisong@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sudeep.holla@arm.com \
--cc=sumitg@nvidia.com \
--cc=vanshikonda@os.amperecomputing.com \
--cc=viresh.kumar@linaro.org \
--cc=will@kernel.org \
--cc=yang@os.amperecomputing.com \
--cc=zhanjie9@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.