cpufreq.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dirk Brandewie <dirk.brandewie@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>,
	Magdalena Dobosz <maj.dobosz@gmail.com>
Cc: dirk.j.brandewie@intel.com,
	"cpufreq@vger.kernel.org" <CPUFREQ@vger.kernel.org>,
	Ross Lagerwall <rosslagerwall@gmail.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Len Brown <lenb@kernel.org>
Subject: Re: cpufreq-info and acpi-cpufreq: reporting MSR_IA32_PERF_CTL as "actual frequency"
Date: Wed, 26 Nov 2014 07:29:46 -0800	[thread overview]
Message-ID: <5475F1EA.7020003@intel.com> (raw)
In-Reply-To: <CAKohpom1=k=KP3csObfBPRqDQSWGyRrJUjw69NW04YB5RppcMw@mail.gmail.com>

On 11/25/2014 10:07 PM, Viresh Kumar wrote:
> On 25 November 2014 at 22:51, Magdalena Dobosz <maj.dobosz@gmail.com> wrote:
>> Hi,
>> I was analyzing the code and behaviour of cpufrequtils (kernel 3.13).
>> I noticed that the value reported by cpufreq-info as the frequency
>> "asserted by call to hardware" (exported to sysfs as
>> "cpuinfo_cur_freq") is always the same as the value reported as the
>> frequency requested by a governor (exported to sysfs as "freq", stored
>> in policy->cur).
>> It was not the case for kernel 3.2 (these two values tend to differ).
>>
>> I found a reason: while using acpi-cpufreq driver, the value reported
>> as hardware frequency is retrieved using  get_cur_freq_on_cpu function
>> (defined in acpi-cpufreq). Now, in kernel version 3.2 this function
>> reads a value from MSR_IA32_PERF_STATUS, while in kernel 3.13 it reads
>> MSR_IA32_PERF_CTL.
>> It is a result of the patch shown below:
>> https://lists.ubuntu.com/archives/kernel-team/2013-June/029493.html
>>
>> It looks like a bug for me - we take a requested frequency (control
>> register) and we report it as "cpuinfo_cur_freq - Current frequency of
>> the CPU as obtained from the hardware, in KHz. This is the frequency
>> the CPU actually runs at." (as desribed in cpufrequtils documentation:
>> https://www.kernel.org/doc/Documentation/cpu-freq/user-guide.txt". I
>> believe we should read status register (MSR_IA32_PERF_STATUS) instead.
>
> Fixed list and cc'd few more.
>
> This is what Len Brown said to that patch:
>
> Ack -- MSR_IA32_PERF_STATUS is ill-conceived.  It is un-reliable
> by its very definition.  Any code that depends on it should be questioned...
>
> @Dirk: Can you help ?

Not really. This issue is one of the reasons that intel_pstate returns a
measured/effective frequency.  There is no way that I know of to get the
instantaneous frequency that the core is running at in the presence of
hardware coordination and idle.  The best you can do is measure the effective
frequency over a sample time.  This is what turbostat and intel_pstate
report.

--Dirk

>


  reply	other threads:[~2014-11-26 15:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-25 17:21 cpufreq-info and acpi-cpufreq: reporting MSR_IA32_PERF_CTL as "actual frequency" Magdalena Dobosz
2014-11-26  6:07 ` Viresh Kumar
2014-11-26 15:29   ` Dirk Brandewie [this message]
2014-11-26 20:41     ` Magdalena Dobosz
2014-11-26 22:37       ` Rafael J. Wysocki
2014-11-27 16:38         ` Magdalena Dobosz
2015-03-14 17:18           ` Len Brown

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=5475F1EA.7020003@intel.com \
    --to=dirk.brandewie@gmail.com \
    --cc=CPUFREQ@vger.kernel.org \
    --cc=dirk.j.brandewie@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=maj.dobosz@gmail.com \
    --cc=rjw@rjwysocki.net \
    --cc=rosslagerwall@gmail.com \
    --cc=viresh.kumar@linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).