Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq

2016-04-24 Thread Pavel Machek
Hi! > +++ b/arch/x86/kernel/cpu/aperfmperf.c > @@ -0,0 +1,76 @@ > +/* > + * x86 APERF/MPERF KHz calculation > + * Used by /proc/cpuinfo and /sys/.../cpufreq/scaling_cur_freq Could we use some shorter filename here? cpu_mhz.c? mhz.c? > +/* > + * aperfmperf_snapshot_khz() -- (english) http://www

Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq

2016-04-01 Thread Len Brown
Thanks for the comments. Re: is this a useful semantic? Yes, average MHz over an interval is significantly more useful than a snapshot of the recent instantaneous frequency. It is possible to convert the former into the later, but it is not possible to reliably and efficiently convert the later i

Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq

2016-04-01 Thread Borislav Petkov
On Fri, Apr 01, 2016 at 11:30:48AM +0200, Stephane Gasparini wrote: > The MSRs will not wrap that often. Unless some yahoo goes and does WRMSR APERF . I think we should handle that gracefully too, regardless of how "smart" that move might be. -- Regards/Gruss, Boris. ECO tip #101: Trim you

Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq

2016-04-01 Thread Peter Zijlstra
On Fri, Apr 01, 2016 at 11:30:48AM +0200, Stephane Gasparini wrote: > my comment was about your comment that MSR have wrapped however many times > Yes, and don't top post.

Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq

2016-04-01 Thread Stephane Gasparini
my comment was about your comment that MSR have wrapped however many times > On Apr 1, 2016, at 10:03 AM, Peter Zijlstra wrote: > > That is; if userspace doesn't request a freq reading we can go without > reading this for a very long time. > >> + >> +rdmsrl(MSR_IA32_APERF, aperf); >> +

Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq

2016-04-01 Thread Peter Zijlstra
On Fri, Apr 01, 2016 at 10:23:23AM +0200, Peter Zijlstra wrote: > > Trim your emails > > On Fri, Apr 01, 2016 at 10:16:42AM +0200, Stephane Gasparini wrote: > > > > That means these delta's can be arbitrarily large, in fact the MSRs can > > > have wrapped however many times. > > > > 64 bits is

Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq

2016-04-01 Thread Peter Zijlstra
Trim your emails On Fri, Apr 01, 2016 at 10:16:42AM +0200, Stephane Gasparini wrote: > > That means these delta's can be arbitrarily large, in fact the MSRs can > > have wrapped however many times. > > 64 bits is 18 446 744 073 709 551 615 > > so even assuming a 10 GHz frequency if my math are

Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq

2016-04-01 Thread Peter Zijlstra
On Fri, Apr 01, 2016 at 12:37:00AM -0400, Len Brown wrote: > From: Len Brown > > For x86 processors with APERF/MPERF and TSC, > return meaningful and consistent MHz in > /proc/cpuinfo and > /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq > > MHz is computed like so: > > MHz = base_MHz * d

Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq

2016-04-01 Thread Stephane Gasparini
— Steph > On Apr 1, 2016, at 10:03 AM, Peter Zijlstra wrote: > > On Fri, Apr 01, 2016 at 12:37:00AM -0400, Len Brown wrote: >> diff --git a/arch/x86/kernel/cpu/aperfmperf.c >> b/arch/x86/kernel/cpu/aperfmperf.c >> new file mode 100644 >> index 000..9380102 >> --- /dev/null >> +++ b/arch

Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq

2016-04-01 Thread Peter Zijlstra
On Fri, Apr 01, 2016 at 12:37:00AM -0400, Len Brown wrote: > diff --git a/arch/x86/kernel/cpu/aperfmperf.c > b/arch/x86/kernel/cpu/aperfmperf.c > new file mode 100644 > index 000..9380102 > --- /dev/null > +++ b/arch/x86/kernel/cpu/aperfmperf.c > @@ -0,0 +1,76 @@ > +/* > + * x86 APERF/MPERF KH

[PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq

2016-03-31 Thread Len Brown
From: Len Brown For x86 processors with APERF/MPERF and TSC, return meaningful and consistent MHz in /proc/cpuinfo and /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq MHz is computed like so: MHz = base_MHz * delta_APERF / delta_MPERF MHz is the average frequency of the busy processor ov