cpufreq: ondemand: add AMD specific powersave bias
Subsystems (3)
v4 cover cpufreq: ondemand: add AMD specific powersave bias
This patchset adds AMD specific powersave bias function to the ondemand governor; which can be used to help ondemand governor make more power conscious frequency change decisions based on feedback from hardware (availble on AMD Family 16h and above).
Hardware feedback tells software how "sensitive" to frequency changes the workloads are. CPU-bound workloads will be more sensitive -- they will perform better as frequency increases. Memory/IO-bound workloads will be less sensitive -- they will not necessarily perform better as frequnecy increases.
This patchset was compared against ondemand governor without powersave bias and did not show any performance degradation on CPU-bound workloads such as kernbench and unixbench. While saving power on Memory-bound workloads such as stream.
V4:
* Added proper documentation to Documentation/cpu-freq/
* Revised so that when this driver loads, the feature is enabled by default with a sane tunable value.
V3:
* Added to CPUID bit to cpufeature.h
* Added MODULE_DEVICE_TABLE to autoload this driver.
* Other small changes per feedback from:
https://lkml.org/lkml/2013/4/2/349
V2:
* Added proper include files to amd_freq_sensitivity.c
* Only register powersave_bias_target function pointer and not the entire od_ops.
Jacob Shin (2):
cpufreq: ondemand: allow custom powersave_bias_target handler to be
registered
cpufreq: AMD "frequency sensitivity feedback" powersave bias for
ondemand governor
Documentation/cpu-freq/governors.txt | 21 +++++ arch/x86/include/asm/cpufeature.h | 1 + arch/x86/kernel/cpu/scattered.c | 3 +- drivers/cpufreq/Kconfig.x86 | 17 ++++ drivers/cpufreq/Makefile | 1 + drivers/cpufreq/amd_freq_sensitivity.c | 148 ++++++++++++++++++++++++++++++++ drivers/cpufreq/cpufreq_governor.h | 4 + drivers/cpufreq/cpufreq_ondemand.c | 56 ++++++++++-- 8 files changed, 242 insertions(+), 9 deletions(-) create mode 100644 drivers/cpufreq/amd_freq_sensitivity.c
Signature · 1 line
1.7.9.5
PATCH v4 1/2 cpufreq: ondemand: allow custom powersave_bias_target handler to be registered
This allows for another [arch specific] driver to hook into existing powersave bias function of the ondemand governor. i.e. This allows AMD specific powersave bias function (in a separate AMD specific driver) to aid ondemand governor's frequency transition decisions.
--- drivers/cpufreq/cpufreq_governor.h | 4 +++ drivers/cpufreq/cpufreq_ondemand.c | 56 ++++++++++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 8 deletions(-)
drivers/cpufreq/cpufreq_governor.h +4 -0
@@ -263,4 +263,8 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, struct common_dbs_data *cdata, unsigned int event);void gov_queue_work (struct dbs_data *dbs_data,struct cpufreq_policy *policy,unsigned int delay,bool all_cpus); +void od_register_powersave_bias_handler (unsigned int (*f) + (struct cpufreq_policy *,unsigned int ,unsigned int ), +unsigned int powersave_bias); +void od_unregister_powersave_bias_handler (void );#endif /* _CPUFREQ_GOVERNOR_H */
drivers/cpufreq/cpufreq_ondemand.c +48 -8
93 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v4 2/2 cpufreq: AMD "frequency sensitivity feedback" powersave bias for ondemand governor
In reply to Jacob ShinFuture AMD processors, starting with Family 16h, can provide software with feedback on how the workload may respond to frequency change -- memory-bound workloads will not benefit from higher frequency, where as compute-bound workloads will. This patch enables this "frequency sensitivity feedback" to aid the ondemand governor to make better frequency change decisions by hooking into the powersave bias.
--- Documentation/cpu-freq/governors.txt | 21 +++++ arch/x86/include/asm/cpufeature.h | 1 + arch/x86/kernel/cpu/scattered.c | 3 +- drivers/cpufreq/Kconfig.x86 | 17 ++++ drivers/cpufreq/Makefile | 1 + drivers/cpufreq/amd_freq_sensitivity.c | 148 ++++++++++++++++++++++++++++++++ 6 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 drivers/cpufreq/amd_freq_sensitivity.c
Documentation/cpu-freq/governors.txt +21 -0
@@ -167,6 +167,27 @@ of load evaluation and helping the CPU stay at its top speed when truly busy, rather than shifting back and forth in speed. This tunable has no effect on behavior at lower speeds/lower CPU loads. +powersave_bias: this parameter takes a value between 0 to 1000. It +defines the percentage (times 10) value of the target frequency that +will be shaved off of the target. For example, when set to 100 -- 10%, +when ondemand governor would have targeted 1000 MHz, it will target +1000 MHz - (10% of 1000 MHz) = 900 MHz instead. This is set to 0 +(disabled) by default. +When AMD frequency sensitivity powersave bias driver -- +drivers/cpufreq/amd_freq_sensitivity.c is loaded, this parameter +defines the workload frequency sensitivity threshold in which a lower +frequency is chosen instead of ondemand governor's original target. +The frequency sensitivity is a hardware reported (on AMD Family 16h +Processors and above) value between 0 to 100% that tells software how +the performance of the workload running on a CPU will change when +frequency changes. A workload with sensitivity of 0% (memory/IO-bound) +will not perform any better on higher core frequency, whereas a +workload with sensitivity of 100% (CPU-bound) will perform better +higher the frequency. When the driver is loaded, this is set to 400 +by default -- for CPUs running workloads with sensitivity value below +40%, a lower frequency is chosen. Unloading the driver or writing 0 +will disable this feature. + 2.5 Conservative ----------------
arch/x86/include/asm/cpufeature.h +1 -0
@@ -182,6 +182,7 @@#define X86_FEATURE_PTS (7*32+ 6)/* Intel Package Thermal Status */ #define X86_FEATURE_DTHERM (7*32+ 7)/* Digital Thermal Sensor */ #define X86_FEATURE_HW_PSTATE (7*32+ 8)/* AMD HW-PState */ +#define X86_FEATURE_PROC_FEEDBACK (7*32+ 9)/* AMD ProcFeedbackInterface */ /* Virtualization flags: Linux defined, word 8 */ #define X86_FEATURE_TPR_SHADOW (8*32+ 0)/* Intel TPR Shadow */
arch/x86/kernel/cpu/scattered.c +2 -1
@@ -39,8 +39,9 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) { X86_FEATURE_APERFMPERF, CR_ECX, 0, 0x00000006, 0 }, { X86_FEATURE_EPB, CR_ECX, 3, 0x00000006, 0 }, { X86_FEATURE_XSAVEOPT, CR_EAX, 0, 0x0000000d, 1 }, - { X86_FEATURE_CPB, CR_EDX, 9, 0x80000007, 0 }, { X86_FEATURE_HW_PSTATE, CR_EDX, 7, 0x80000007, 0 }, + { X86_FEATURE_CPB, CR_EDX, 9, 0x80000007, 0 }, + { X86_FEATURE_PROC_FEEDBACK, CR_EDX,11, 0x80000007, 0 }, { X86_FEATURE_NPT, CR_EDX, 0, 0x8000000a, 0 }, { X86_FEATURE_LBRV, CR_EDX, 1, 0x8000000a, 0 }, { X86_FEATURE_SVML, CR_EDX, 2, 0x8000000a, 0 },
drivers/cpufreq/Kconfig.x86 +17 -0
@@ -129,6 +129,23 @@ config X86_POWERNOW_K8 For details, take a look at <file:Documentation/cpu-freq/>. +config X86_AMD_FREQ_SENSITIVITY + tristate "AMD frequency sensitivity feedback powersave bias" + depends on CPU_FREQ_GOV_ONDEMAND && X86_ACPI_CPUFREQ && CPU_SUP_AMD + help + This adds AMD-specific powersave bias function to the ondemand + governor, which allows it to make more power-conscious frequency + change decisions based on feedback from hardware (availble on AMD + Family 16h and above). + + Hardware feedback tells software how "sensitive" to frequency changes + the CPUs' workloads are. CPU-bound workloads will be more sensitive + -- they will perform better as frequency increases. Memory/IO-bound + workloads will be less sensitive -- they will not necessarily perform + better as frequency increases. + + If in doubt, say N. + config X86_GX_SUSPMOD tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation" depends on X86_32 && PCI
drivers/cpufreq/Makefile +1 -0
@@ -41,6 +41,7 @@ obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o obj-$(CONFIG_X86_INTEL_PSTATE) += intel_pstate.o +obj-$(CONFIG_X86_AMD_FREQ_SENSITIVITY) += amd_freq_sensitivity.o ################################################################################## # ARM SoC drivers
drivers/cpufreq/amd_freq_sensitivity.c new file +148 -0
148 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Viresh Kumar
maintainerRe: [PATCH V4 1/2] cpufreq: ondemand: allow custom powersave_bias_target handler to be registered
In reply to Jacob ShinQuoted 11 lines · Jacob Shin
drivers/cpufreq/cpufreq_ondemand.c +9
-0+static void od_set_powersave_bias (unsigned int powersave_bias) +{ +unsigned int cpu; +struct od_dbs_tuners *od_tuners; + +if (!have_governor_per_policy ()) { + od_tuners = od_dbs_cdata.gdbs_data->tuners; + od_tuners->powersave_bias = powersave_bias; +return ;
drivers/cpufreq/cpufreq_ondemand.c static struct common_dbs_data od_dbs_cdata = { · line 598
Quoted 10 lines
drivers/cpufreq/cpufreq_ondemand.c +10
-0+ } + +for_each_online_cpu (cpu) { +struct cpufreq_policy *policy; +struct dbs_data *dbs_data; + policy =per_cpu (od_cpu_dbs_info, cpu).cdbs.cur_policy; + dbs_data = policy->governor_data; + od_tuners = dbs_data->tuners; + od_tuners->powersave_bias = powersave_bias; + }
You can keep only the for_each_online_cpu() loop and remove the other one. And in that one also, you don't have to do this for every cpu...
something like this will help you...
cpus_processed = NULL;
for_each_online_cpu(cpu) {
if cpu-is-present-in cpus_processed
continue;
cpu-set-mask(cpus_processed, policy->cpus);}
Syntax is poor, please choose the correct one.
Quoted 1 line
+}
Quoted 4 lines · Jacob Shin
This patchset adds AMD specific powersave bias function to the ondemand governor; which can be used to help ondemand governor make more power conscious frequency change decisions based on feedback from hardware (availble on AMD Family 16h and above).
Either the one way:
1) Documenting powersave_bias and add the stuff there, best with a default set so that the stuff gets used
or
2) Marking powersave_bias deprecated and embed things into ondemand directly
should be fine.
As you give this some usefulness now and it's going to get used (automatically) and the stuff is even documented, I cannot suggest anything anymore how to integrate that better.
Re: [PATCH V4 1/2] cpufreq: ondemand: allow custom powersave_bias_target handler to be registered
In reply to Viresh KumarQuoted 36 lines · Viresh Kumar
Quoted 11 lines · Jacob Shin
drivers/cpufreq/cpufreq_ondemand.c +9
-0+static void od_set_powersave_bias (unsigned int powersave_bias) +{ +unsigned int cpu; +struct od_dbs_tuners *od_tuners; + +if (!have_governor_per_policy ()) { + od_tuners = od_dbs_cdata.gdbs_data->tuners; + od_tuners->powersave_bias = powersave_bias; +return ;drivers/cpufreq/cpufreq_ondemand.c
Quoted 10 lines
drivers/cpufreq/cpufreq_ondemand.c +10
-0+ } + +for_each_online_cpu (cpu) { +struct cpufreq_policy *policy; +struct dbs_data *dbs_data; + policy =per_cpu (od_cpu_dbs_info, cpu).cdbs.cur_policy; + dbs_data = policy->governor_data; + od_tuners = dbs_data->tuners; + od_tuners->powersave_bias = powersave_bias; + }You can keep only the
for_each_online_cpu()loop and remove the other one. And in that one also, you don't have to do this for every cpu...something like this will help you...
cpus_processed= NULL;for_each_online_cpu(cpu) { if cpu-is-present-in cpus_processed continue; cpu-set-mask(cpus_processed, policy->cpus);
Quoted 3 lines
}
Syntax is poor, please choose the correct one.
Ah okay, thanks for the hint, here:
From 59728d09d0dc5403c9bb0238336ecb367c04694f Mon Sep 17 00:00:00 2001
From: Jacob Shin <[email protected]>
Date: Tue, 2 Apr 2013 09:56:56 -0500
Subject: [PATCH 1/2] cpufreq: ondemand: allow custom powersave_bias_target
handler to be registered
This allows for another [arch specific] driver to hook into existing powersave bias function of the ondemand governor. i.e. This allows AMD specific powersave bias function (in a separate AMD specific driver) to aid ondemand governor's frequency transition decisions.
--- drivers/cpufreq/cpufreq_governor.h | 4 +++ drivers/cpufreq/cpufreq_ondemand.c | 58 +++++++++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 8 deletions(-)
drivers/cpufreq/cpufreq_governor.h +4 -0
@@ -263,4 +263,8 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, struct common_dbs_data *cdata, unsigned int event);void gov_queue_work (struct dbs_data *dbs_data,struct cpufreq_policy *policy,unsigned int delay,bool all_cpus); +void od_register_powersave_bias_handler (unsigned int (*f) + (struct cpufreq_policy *,unsigned int ,unsigned int ), +unsigned int powersave_bias); +void od_unregister_powersave_bias_handler (void );#endif /* _CPUFREQ_GOVERNOR_H */
drivers/cpufreq/cpufreq_ondemand.c +50 -8
95 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Borislav Petkov
maintainerRe: [PATCH V4 1/2] cpufreq: ondemand: allow custom powersave_bias_target handler to be registered
Quoted 4 lines · Jacob Shin
drivers/cpufreq/cpufreq_ondemand.c +0
-0@@ -574,6 +577,45 @@ static struct common_dbs_data od_dbs_cdata = { .exit = od_exit, };
drivers/cpufreq/cpufreq_ondemand.c static struct common_dbs_data od_dbs_cdata = { · line 589
Quoted 10 lines
drivers/cpufreq/cpufreq_ondemand.c +10
-0+static void od_set_powersave_bias (unsigned int powersave_bias) +{ +struct cpufreq_policy *policy; +struct dbs_data *dbs_data; +struct od_dbs_tuners *od_tuners; +unsigned int cpu; +cpumask_t done; + +cpumask_clear (&done); +
get_online_cpus();
drivers/cpufreq/cpufreq_ondemand.c static struct common_dbs_data od_dbs_cdata = { · line 600
Quoted 11 lines
drivers/cpufreq/cpufreq_ondemand.c +11
-0+for_each_online_cpu (cpu) { +if (cpumask_test_cpu (cpu, &done)) +continue ; + + policy =per_cpu (od_cpu_dbs_info, cpu).cdbs.cur_policy; + dbs_data = policy->governor_data; + od_tuners = dbs_data->tuners; + od_tuners->powersave_bias = powersave_bias; + +cpumask_or (&done, &done, policy->cpus); + }
put_online_cpus();
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH V4 2/2] cpufreq: AMD "frequency sensitivity feedback" powersave bias for ondemand governor
In reply to Jacob ShinQuoted 8 lines · Jacob Shin
Future AMD processors, starting with Family 16h, can provide software with feedback on how the workload may respond to frequency change -- memory-bound workloads will not benefit from higher frequency, where as compute-bound workloads will. This patch enables this "frequency sensitivity feedback" to aid the ondemand governor to make better frequency change decisions by hooking into the powersave bias.
Signed-off-by Jacob Shin <[email protected]>
Looks good to me.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH V4 1/2] cpufreq: ondemand: allow custom powersave_bias_target handler to be registered
In reply to Borislav PetkovQuoted 18 lines · Borislav Petkov
Quoted 4 lines · Jacob Shin
(quoted diff) +0
-0@@ -574,6 +577,45 @@ static struct common_dbs_data od_dbs_cdata = { .exit = od_exit, };Review static struct common_dbs_data od_dbs_cdata = { · line 589
Quoted 10 lines
(quoted diff) +10
-0+static void od_set_powersave_bias(unsigned int powersave_bias) +{ + struct cpufreq_policy *policy; + struct dbs_data *dbs_data; + struct od_dbs_tuners *od_tuners; + unsigned int cpu; + cpumask_t done; + + cpumask_clear(&done); +
get_online_cpus();
Quoted 17 lines
Review static struct common_dbs_data od_dbs_cdata = { · line 600
Quoted 11 lines
(quoted diff) +11
-0+ for_each_online_cpu(cpu) { + if (cpumask_test_cpu(cpu, &done)) + continue; + + policy = per_cpu(od_cpu_dbs_info, cpu).cdbs.cur_policy; + dbs_data = policy->governor_data; + od_tuners = dbs_data->tuners; + od_tuners->powersave_bias = powersave_bias; + + cpumask_or(&done, &done, policy->cpus); + }
put_online_cpus();Signature · 2 lines
Regards/Gruss, Boris.
Ah, okay .. here is the fixup:
From 7236287faa1a499686c9aac1d3f3f224516a7bbf Mon Sep 17 00:00:00 2001
From: Jacob Shin <[email protected]>
Date: Tue, 2 Apr 2013 09:56:56 -0500
Subject: [PATCH 1/2] cpufreq: ondemand: allow custom powersave_bias_target
handler to be registered
This allows for another [arch specific] driver to hook into existing powersave bias function of the ondemand governor. i.e. This allows AMD specific powersave bias function (in a separate AMD specific driver) to aid ondemand governor's frequency transition decisions.
--- drivers/cpufreq/cpufreq_governor.h | 4 +++ drivers/cpufreq/cpufreq_ondemand.c | 61 +++++++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 8 deletions(-)
drivers/cpufreq/cpufreq_governor.h +4 -0
@@ -263,4 +263,8 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, struct common_dbs_data *cdata, unsigned int event);void gov_queue_work (struct dbs_data *dbs_data,struct cpufreq_policy *policy,unsigned int delay,bool all_cpus); +void od_register_powersave_bias_handler (unsigned int (*f) + (struct cpufreq_policy *,unsigned int ,unsigned int ), +unsigned int powersave_bias); +void od_unregister_powersave_bias_handler (void );#endif /* _CPUFREQ_GOVERNOR_H */
drivers/cpufreq/cpufreq_ondemand.c +53 -8
104 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH V4 2/2] cpufreq: AMD "frequency sensitivity feedback" powersave bias for ondemand governor
In reply to Borislav PetkovQuoted 8 lines · Borislav Petkov
Quoted 7 lines · Jacob Shin
Future AMD processors, starting with Family 16h, can provide software with feedback on how the workload may respond to frequency change -- memory-bound workloads will not benefit from higher frequency, where as compute-bound workloads will. This patch enables this "frequency sensitivity feedback" to aid the ondemand governor to make better frequency change decisions by hooking into the powersave bias.
Quoted 5 lines
Quoted 1 line
Signed-off-by Jacob Shin <[email protected]>Looks good to me.
Acked-by Borislav Petkov <[email protected]>
Rafael, got acks from both Boris and Thomas. Please commit to linux-next when you get the chance.
Thanks,
-Jacob
Quoted 8 lines
Signature · 6 lines
-- Regards/Gruss, Boris. Sent from a fat crate under my desk. Formatting is fine. --
Re: [PATCH V4 1/2] cpufreq: ondemand: allow custom powersave_bias_target handler to be registered
In reply to Jacob ShinQuoted 8 lines · Jacob Shin
Ah, okay .. here is the fixup:
From
7236287faa1a499686c9aac1d3f3f224516a7bbfMon Sep 17 00:00:00 2001
From: Jacob Shin <[email protected]>
Date: Tue, 2 Apr 2013 09:56:56 -0500
Subject: [PATCH 1/2] cpufreq: ondemand: allow custompowersave_bias_target
handler to be registered
Quoted 6 lines
This allows for another [arch specific] driver to hook into existing powersave bias function of the ondemand governor. i.e. This allows AMD specific powersave bias function (in a separate AMD specific driver) to aid ondemand governor's frequency transition decisions.
Signed-off-by Jacob Shin <[email protected]>
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 37 lines · Jacob Shin
This patchset adds AMD specific powersave bias function to the ondemand governor; which can be used to help ondemand governor make more power conscious frequency change decisions based on feedback from hardware (availble on AMD Family 16h and above).
Hardware feedback tells software how "sensitive" to frequency changes the workloads are. CPU-bound workloads will be more sensitive -- they will perform better as frequency increases. Memory/IO-bound workloads will be less sensitive -- they will not necessarily perform better as frequnecy increases.
This patchset was compared against ondemand governor without powersave bias and did not show any performance degradation on CPU-bound workloads such as kernbench and unixbench. While saving power on Memory-bound workloads such as stream.
V4:
* Added proper documentation toDocumentation/cpu-freq/
* Revised so that when this driver loads, the feature is enabled by default with a sane tunable value.V3:
* Added to CPUID bit tocpufeature.h
* AddedMODULE_DEVICE_TABLEto autoload this driver.
* Other small changes per feedback from:
https://lkml.org/lkml/2013/4/2/349V2:
* Added proper include files toamd_freq_sensitivity.c
* Only registerpowersave_bias_targetfunction pointer and not the entireod_ops.Jacob Shin (2):
cpufreq: ondemand: allow custompowersave_bias_targethandler to be
registered
cpufreq: AMD "frequency sensitivity feedback" powersave bias for
ondemand governor
Quoted 10 lines
Documentation/cpu-freq/governors.txt | 21 +++++ arch/x86/include/asm/cpufeature.h | 1 + arch/x86/kernel/cpu/scattered.c | 3 +- drivers/cpufreq/Kconfig.x86 | 17 ++++ drivers/cpufreq/Makefile | 1 + drivers/cpufreq/amd_freq_sensitivity.c | 148 ++++++++++++++++++++++++++++++++ drivers/cpufreq/cpufreq_governor.h | 4 + drivers/cpufreq/cpufreq_ondemand.c | 56 ++++++++++-- 8 files changed, 242 insertions(+), 9 deletions(-) create mode 100644 drivers/cpufreq/amd_freq_sensitivity.c
For the latest versions sent by you (including {get|put}_online_cpus()):
Viresh Kumar
maintainerQuoted 3 lines · Viresh Kumar
For the latest versions sent by you (including {get|put}_online_cpus()):
Acked-by Viresh Kumar <[email protected]>
Hi Rafael,
I see that you have applied this patchset to bleeding-edge, but in wrong order. You have applied 2/2 first and then 1/2, which is wrong as after 2/2 we will have a compilation failure.
Quoted 10 lines · Viresh Kumar
Quoted 3 lines · Viresh Kumar
For the latest versions sent by you (including {get|put}_online_cpus()):
Acked-by Viresh Kumar <[email protected]>Hi Rafael,
I see that you have applied this patchset to bleeding-edge, but in wrong order. You have applied 2/2 first and then 1/2, which is wrong as after 2/2 we will have a compilation failure.
Ah, good catch. I didn't notice that patchwork changed the ordering when creating a bundle.
Should be fixed now.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.