Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1369132

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

From Stephane Gasparini <stephane.gasparini@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq
Date 2016-04-01 11:40 +0200
Message-ID <rj3IB-2lk-9@gated-at.bofh.it> (permalink)
References (1 earlier) <riZ2h-7Bo-5@gated-at.bofh.it> <rj2jv-1v4-5@gated-at.bofh.it> <rj2tc-1yL-15@gated-at.bofh.it> <rj2CS-1CC-7@gated-at.bofh.it> <rj2CS-1CC-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


my comment was about your comment that MSR have wrapped however many times



> On Apr 1, 2016, at 10:03 AM, Peter Zijlstra <peterz@infradead.org> 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);
>> +	rdmsrl(MSR_IA32_MPERF, mperf);
>> +
>> +	aperf_delta = aperf - s->aperf;
>> +	mperf_delta = mperf - s->mperf;
> 
> That means these delta's can be arbitrarily large, in fact the MSRs can
> have wrapped however many times.

The MSRs will not wrap that often.

—
Steph




> On Apr 1, 2016, at 10:29 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> 
> 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 18 446 744 073 709 551 615
>>> 
>>> so even assuming a 10 GHz frequency if my math are good this is more than
>>> 58 years before the MSR wrap around, assuming the device ran always at max
>>> freq.
>> 
>> fair enough.. but going with 10Ghz, cpu_khz would be 10e6 ~ 33 bits,
> 
> I can't do maths this morning; 23 bits
> 
>> which effectively reduces the wrap/overflow time to just 31 bits, which
>> per that frequency is just ~1/4th of a second.
> 
> 41 giving lots more, but a reasonable time to wrap/overflow.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq Len Brown <lenb@kernel.org> - 2016-04-01 06:40 +0200
  Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and  scaling_cur_freqy Thomas Gleixner <tglx@linutronix.de> - 2016-04-01 10:00 +0200
  Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and  scaling_cur_freq Peter Zijlstra <peterz@infradead.org> - 2016-04-01 10:10 +0200
    Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq Stephane Gasparini <stephane.gasparini@linux.intel.com> - 2016-04-01 10:20 +0200
      Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and  scaling_cur_freq Peter Zijlstra <peterz@infradead.org> - 2016-04-01 10:30 +0200
        Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq Stephane Gasparini <stephane.gasparini@linux.intel.com> - 2016-04-01 11:40 +0200
          Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and  scaling_cur_freq Peter Zijlstra <peterz@infradead.org> - 2016-04-01 11:40 +0200
          Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and  scaling_cur_freq Borislav Petkov <bp@alien8.de> - 2016-04-01 12:00 +0200
            Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and scaling_cur_freq Len Brown <lenb@kernel.org> - 2016-04-02 07:30 +0200
      Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and  scaling_cur_freq Peter Zijlstra <peterz@infradead.org> - 2016-04-01 10:30 +0200
  Re: [PATCH] x86: Calculate MHz using APERF/MPERF for cpuinfo and  scaling_cur_freq Peter Zijlstra <peterz@infradead.org> - 2016-04-01 10:20 +0200

csiph-web