* [RFC PATCH 1/3] cpufreq: Add new attribute "base_frequency"
@ 2015-09-04 17:19 Srinivas Pandruvada
2015-09-04 17:19 ` [RFC PATCH 2/3] cpufreq: user_guide: update for base_frequency Srinivas Pandruvada
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2015-09-04 17:19 UTC (permalink / raw)
To: rafael.j.wysocki, viresh.kumar; +Cc: linux-pm, Srinivas Pandruvada
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
>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:
>cat base_frequency
2200000
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/cpufreq/cpufreq.c | 26 ++++++++++++++++++++++++++
include/linux/cpufreq.h | 2 ++
2 files changed, 28 insertions(+)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 7a3c30c..f4ff667 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -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);
}
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index bde1e56..f95a61e 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -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);
--
2.4.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [RFC PATCH 2/3] cpufreq: user_guide: update for base_frequency
2015-09-04 17:19 [RFC PATCH 1/3] cpufreq: Add new attribute "base_frequency" Srinivas Pandruvada
@ 2015-09-04 17:19 ` Srinivas Pandruvada
2015-09-04 17:19 ` [RFC PATCH 3/3] cpufreq: acpi_cpufreq: Support base_frequency Srinivas Pandruvada
2015-09-07 6:06 ` [RFC PATCH 1/3] cpufreq: Add new attribute "base_frequency" Viresh Kumar
2 siblings, 0 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2015-09-04 17:19 UTC (permalink / raw)
To: rafael.j.wysocki, viresh.kumar; +Cc: linux-pm, Srinivas Pandruvada
Updated documentation for cpufreq attributes.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
Documentation/cpu-freq/user-guide.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/cpu-freq/user-guide.txt b/Documentation/cpu-freq/user-guide.txt
index 109e97b..0326a8c 100644
--- a/Documentation/cpu-freq/user-guide.txt
+++ b/Documentation/cpu-freq/user-guide.txt
@@ -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
--
2.4.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFC PATCH 3/3] cpufreq: acpi_cpufreq: Support base_frequency
2015-09-04 17:19 [RFC PATCH 1/3] cpufreq: Add new attribute "base_frequency" Srinivas Pandruvada
2015-09-04 17:19 ` [RFC PATCH 2/3] cpufreq: user_guide: update for base_frequency Srinivas Pandruvada
@ 2015-09-04 17:19 ` Srinivas Pandruvada
2015-09-07 6:06 ` [RFC PATCH 1/3] cpufreq: Add new attribute "base_frequency" Viresh Kumar
2 siblings, 0 replies; 6+ messages in thread
From: Srinivas Pandruvada @ 2015-09-04 17:19 UTC (permalink / raw)
To: rafael.j.wysocki, viresh.kumar; +Cc: linux-pm, Srinivas Pandruvada
Using new cpufreq base_frequency, displaying the correct base frequency.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/cpufreq/acpi-cpufreq.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 0136dfc..4350809 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -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;
+ }
+
}
}
--
2.4.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [RFC PATCH 1/3] cpufreq: Add new attribute "base_frequency"
2015-09-04 17:19 [RFC PATCH 1/3] cpufreq: Add new attribute "base_frequency" Srinivas Pandruvada
2015-09-04 17:19 ` [RFC PATCH 2/3] cpufreq: user_guide: update for base_frequency Srinivas Pandruvada
2015-09-04 17:19 ` [RFC PATCH 3/3] cpufreq: acpi_cpufreq: Support base_frequency Srinivas Pandruvada
@ 2015-09-07 6:06 ` Viresh Kumar
2015-09-07 15:17 ` Srinivas pandruvada
2 siblings, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2015-09-07 6:06 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: rafael.j.wysocki, linux-pm
On 04-09-15, 10:19, Srinivas Pandruvada wrote:
> 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
>
> >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:
> >cat base_frequency
> 2200000
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.
--
viresh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH 1/3] cpufreq: Add new attribute "base_frequency"
2015-09-07 6:06 ` [RFC PATCH 1/3] cpufreq: Add new attribute "base_frequency" Viresh Kumar
@ 2015-09-07 15:17 ` Srinivas pandruvada
2015-09-07 15:31 ` Viresh Kumar
0 siblings, 1 reply; 6+ messages in thread
From: Srinivas pandruvada @ 2015-09-07 15:17 UTC (permalink / raw)
To: Viresh Kumar; +Cc: rafael.j.wysocki, linux-pm
On 09/06/2015 11:06 PM, Viresh Kumar wrote:
> On 04-09-15, 10:19, Srinivas Pandruvada wrote:
>> 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
>>
>>> 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:
>>> cat base_frequency
>> 2200000
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-09-07 15:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-04 17:19 [RFC PATCH 1/3] cpufreq: Add new attribute "base_frequency" Srinivas Pandruvada
2015-09-04 17:19 ` [RFC PATCH 2/3] cpufreq: user_guide: update for base_frequency Srinivas Pandruvada
2015-09-04 17:19 ` [RFC PATCH 3/3] cpufreq: acpi_cpufreq: Support base_frequency Srinivas Pandruvada
2015-09-07 6:06 ` [RFC PATCH 1/3] cpufreq: Add new attribute "base_frequency" Viresh Kumar
2015-09-07 15:17 ` Srinivas pandruvada
2015-09-07 15:31 ` Viresh Kumar
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).