cpufreq: Add new attribute "base_frequency"
Subsystems (2)
RFC PATCH 1/3 cpufreq: Add new attribute "base_frequency"
Currently scaling_available_frequencies displays list of available frequencies which can be used to set max/min or current scaling frequency. But because of configurable thermal design power implementation in several Intel CPUs, this is not a guaranteed frequency or a P state, which user can request. After a limit all frequencies (P states) may be purely in opportunistic performance range. For example
Quoted 1 line
cat
scaling_available_frequencies
2301000 2300000 2200000 2000000 1900000 1800000 1700000 1500000 1400000 1300000 1100000 1000000 900000 800000 600000 500000
Here traditionally it is assumed that only 2301000 is a turbo frequency, anything else user can request. But that is not true. Based on the config TDP level, this turbo (boost) start can be much below. For example it can be 2300000 or any other value.
This change adds an optional new attribute called "base_frequency", which displays the max non-turbo frequency (base frequency). For example:
Quoted 1 line
cat
base_frequency
2200000
--- drivers/cpufreq/cpufreq.c | 26 ++++++++++++++++++++++++++ include/linux/cpufreq.h | 2 ++ 2 files changed, 28 insertions(+)
drivers/cpufreq/cpufreq.c +26 -0
@@ -812,6 +812,25 @@ static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf)return sprintf (buf,"%u\n" , policy->cpuinfo.max_freq); } +/* +* show_base_frequency - show the current cpufreq boost start freq +*/ +static ssize_t show_base_frequency (struct cpufreq_policy *policy,char *buf) +{ +unsigned int freq; +int ret; + +if (cpufreq_driver->base_frequency) { + ret = cpufreq_driver->base_frequency (policy->cpu, &freq); +if (!ret) +return sprintf (buf,"%u\n" , freq); +else +return ret; + } + +return -EIO ; +} +cpufreq_freq_attr_ro_perm (cpuinfo_cur_freq,0400 );cpufreq_freq_attr_ro (cpuinfo_min_freq);cpufreq_freq_attr_ro (cpuinfo_max_freq);
@@ -820,6 +839,7 @@ cpufreq_freq_attr_ro(scaling_available_governors);cpufreq_freq_attr_ro (scaling_driver);cpufreq_freq_attr_ro (scaling_cur_freq);cpufreq_freq_attr_ro (bios_limit); +cpufreq_freq_attr_ro (base_frequency);cpufreq_freq_attr_ro (related_cpus);cpufreq_freq_attr_ro (affected_cpus);cpufreq_freq_attr_rw (scaling_min_freq);
@@ -1057,6 +1077,12 @@ static int cpufreq_add_dev_interface(struct cpufreq_policy *policy,return ret; } +if (cpufreq_driver->base_frequency) { + ret =sysfs_create_file (&policy->kobj, &base_frequency.attr); +if (ret) +return ret; + } +return cpufreq_add_dev_symlink (policy); }
include/linux/cpufreq.h +2 -0
@@ -267,6 +267,8 @@ struct cpufreq_driver {/* optional */ int (*bios_limit)(int cpu,unsigned int *limit); +/* optional base_frequency */ +int (*base_frequency)(int cpu,unsigned int *freq);int (*exit)(struct cpufreq_policy *policy);void (*stop_cpu)(struct cpufreq_policy *policy);
Signature · 1 line
2.4.3
RFC PATCH 2/3 cpufreq: user_guide: update for base_frequency
Updated documentation for cpufreq attributes.
--- Documentation/cpu-freq/user-guide.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/cpu-freq/user-guide.txt +4 -0
@@ -212,6 +212,10 @@ bios_limit : If the BIOS tells the OS to limit a CPU to which can be detected through the generic thermal driver. +base_frequency : This shows base frequency of the cpu. Any + request above this is purely opportunistic, if + boost mode is enabled. + If you have selected the "userspace" governor which allows you to set the CPU operating frequency to a specific value, you can read out the current frequency in
Signature · 1 line
2.4.3
RFC PATCH 3/3 cpufreq: acpi_cpufreq: Support base_frequency
In reply to Srinivas PandruvadaUsing new cpufreq base_frequency, displaying the correct base frequency.
--- drivers/cpufreq/acpi-cpufreq.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/cpufreq/acpi-cpufreq.c +25 -0
@@ -640,6 +640,19 @@ static int acpi_cpufreq_blacklist(struct cpuinfo_x86 *c) }#endif +static int acpi_cpufreq_get_base_frequency (int cpu,unsigned int *start) +{ +u64 tar; +int err; + + err =rdmsrl_safe_on_cpu (cpu,MSR_TURBO_ACTIVATION_RATIO , &tar); +if (!err) +/* only supported in core cpus so scaling is fixed */ + *start = tar *100000 ; + +return err; +} +static int acpi_cpufreq_cpu_init (struct cpufreq_policy *policy) {unsigned int i;
@@ -916,6 +929,18 @@ static void __init acpi_cpufreq_boost_init(void)__register_cpu_notifier (&boost_nb);cpu_notifier_register_done (); + +/* Check if we need to register base freq */ +if (boot_cpu_data.x86_vendor ==X86_VENDOR_INTEL ) { +u64 tar; +int err; + + err =rdmsrl_safe (MSR_TURBO_ACTIVATION_RATIO , &tar); +if (!err) + acpi_cpufreq_driver.base_frequency = + acpi_cpufreq_get_base_frequency; + } + } }
Signature · 1 line
2.4.3
Viresh Kumar
maintainerQuoted 16 lines · Srinivas Pandruvada
Currently
scaling_available_frequenciesdisplays list of available frequencies which can be used to set max/min or current scaling frequency. But because of configurable thermal design power implementation in several Intel CPUs, this is not a guaranteed frequency or a P state, which user can request. After a limit all frequencies (P states) may be purely in opportunistic performance range. For exampleQuoted 1 line
cat
scaling_available_frequencies2301000 2300000 2200000 2000000 1900000 1800000 1700000 1500000 1400000 1300000 1100000 1000000 900000 800000 600000 500000
Here traditionally it is assumed that only 2301000 is a turbo frequency, anything else user can request. But that is not true. Based on the config TDP level, this turbo (boost) start can be much below. For example it can be 2300000 or any other value.
Quoted 4 lines
This change adds an optional new attribute called "
base_frequency", which displays the max non-turbo frequency (base frequency). For example:Quoted 1 line
cat
base_frequency2200000
This is something very much acpi-cpufreq driver's specific and I don't really see other platform needing it. So, I would rather add this only for acpi-cpufreq driver, if at all it is required.
Signature · 1 line
viresh
Quoted 17 lines · Viresh Kumar
Quoted 16 lines · Srinivas Pandruvada
Currently
scaling_available_frequenciesdisplays list of available frequencies which can be used to set max/min or current scaling frequency. But because of configurable thermal design power implementation in several Intel CPUs, this is not a guaranteed frequency or a P state, which user can request. After a limit all frequencies (P states) may be purely in opportunistic performance range. For exampleQuoted 1 line
cat
scaling_available_frequencies2301000 2300000 2200000 2000000 1900000 1800000 1700000 1500000 1400000 1300000 1100000 1000000 900000 800000 600000 500000
Here traditionally it is assumed that only 2301000 is a turbo frequency, anything else user can request. But that is not true. Based on the config TDP level, this turbo (boost) start can be much below. For example it can be 2300000 or any other value.
Quoted 8 lines
Quoted 4 lines
This change adds an optional new attribute called "
base_frequency", which displays the max non-turbo frequency (base frequency). For example:Quoted 1 line
cat
base_frequency2200000
This is something very much acpi-cpufreq driver's specific and I don't really see other platform needing it. So, I would rather add this only for acpi-cpufreq driver, if at all it is required.
I can only add to acpi cpufeq. Once configurable TDP becomes standard feature, I think others will follow.
Thanks,
Srinivas
Viresh Kumar
maintainerQuoted 2 lines · Srinivas pandruvada
I can only add to acpi cpufeq. Once configurable TDP becomes standard feature, I think others will follow.
We will move it to core then :)
Signature · 1 line
viresh