Skip to content

Commit 51204e0

Browse files
lenbrafaeljw
authored andcommitted
x86: do not use cpufreq_quick_get() for /proc/cpuinfo "cpu MHz"
cpufreq_quick_get() allows cpufreq drivers to over-ride cpu_khz that is otherwise reported in x86 /proc/cpuinfo "cpu MHz". There are four problems with this scheme, any of them is sufficient justification to delete it. 1. Depending on which cpufreq driver is loaded, the behavior of this field is different. 2. Distros complain that they have to explain to users why and how this field changes. Distros have requested a constant. 3. The two major providers of this information, acpi_cpufreq and intel_pstate, both "get it wrong" in different ways. acpi_cpufreq lies to the user by telling them that they are running at whatever frequency was last requested by software. intel_pstate lies to the user by telling them that they are running at the average frequency computed over an undefined measurement. But an average computed over an undefined interval, is itself, undefined... 4. On modern processors, user space utilities, such as turbostat(1), are more accurate and more precise, while supporing concurrent measurement over arbitrary intervals. Users who have been consulting /proc/cpuinfo to track changing CPU frequency will be dissapointed that it no longer wiggles -- perhaps being unaware of the limitations of the information they have been consuming. Yes, they can change their scripts to look in sysfs cpufreq/scaling_cur_frequency. Here they will find the same data of dubious quality here removed from /proc/cpuinfo. The value in sysfs will be addressed in a subsequent patch to address issues 1-3, above. Issue 4 will remain -- users that really care about accurate frequency information should not be using either proc or sysfs kernel interfaces. They should be using using turbostat(8), or a similar purpose-built analysis tool. Signed-off-by: Len Brown <len.brown@intel.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 41f1830 commit 51204e0

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

arch/x86/kernel/cpu/proc.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <linux/timex.h>
33
#include <linux/string.h>
44
#include <linux/seq_file.h>
5-
#include <linux/cpufreq.h>
65

76
/*
87
* Get CPU information for use by the procfs.
@@ -76,14 +75,9 @@ static int show_cpuinfo(struct seq_file *m, void *v)
7675
if (c->microcode)
7776
seq_printf(m, "microcode\t: 0x%x\n", c->microcode);
7877

79-
if (cpu_has(c, X86_FEATURE_TSC)) {
80-
unsigned int freq = cpufreq_quick_get(cpu);
81-
82-
if (!freq)
83-
freq = cpu_khz;
78+
if (cpu_has(c, X86_FEATURE_TSC))
8479
seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
85-
freq / 1000, (freq % 1000));
86-
}
80+
cpu_khz / 1000, (cpu_khz % 1000));
8781

8882
/* Cache size */
8983
if (c->x86_cache_size >= 0)

0 commit comments

Comments
 (0)