cpufreq: ondemand: Use cpumask_var_t for on-stack cpu mask
PATCH 1/1 cpufreq: ondemand: Use cpumask_var_t for on-stack cpu mask
A cpumask structure on the stack can cause a warning with CONFIG_NR_CPUS=8192 (e.g. Ubuntu 22.04 uses this):
drivers/cpufreq/cpufreq_ondemand.c: In function 'od_set_powersave_bias':drivers/cpufreq/cpufreq_ondemand.c:449:1: warning: the frame size of
1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
449 | }
| ^
CONFIG_CPUMASK_OFFSTACK=y is enabled by default for most distros, and hence we can work around the warning by using cpumask_var_t.
--- drivers/cpufreq/cpufreq_ondemand.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/cpufreq/cpufreq_ondemand.c +9 -4
@@ -416,10 +416,13 @@ static struct dbs_governor od_dbs_gov = {static void od_set_powersave_bias (unsigned int powersave_bias) {unsigned int cpu; -cpumask_t done; +cpumask_var_t done; + +if (!alloc_cpumask_var (&done,GFP_KERNEL )) +return ; default_powersave_bias = powersave_bias; -cpumask_clear (&done); +cpumask_clear (done);cpus_read_lock ();for_each_online_cpu (cpu) {
@@ -428,7 +431,7 @@ static void od_set_powersave_bias(unsigned int powersave_bias)struct dbs_data *dbs_data;struct od_dbs_tuners *od_tuners; -if (cpumask_test_cpu (cpu, &done)) +if (cpumask_test_cpu (cpu, done))continue ; policy =cpufreq_cpu_get_raw (cpu);
@@ -439,13 +442,15 @@ static void od_set_powersave_bias(unsigned int powersave_bias)if (!policy_dbs)continue ; -cpumask_or (&done, &done, policy->cpus); +cpumask_or (done, done, policy->cpus); dbs_data = policy_dbs->dbs_data; od_tuners = dbs_data->tuners; od_tuners->powersave_bias = default_powersave_bias; }cpus_read_unlock (); + +free_cpumask_var (done); } void od_register_powersave_bias_handler(unsigned int (*f)
Signature · 1 line
2.34.1
Quoted 53 lines · Zhao Liu
A cpumask structure on the stack can cause a warning with
CONFIG_NR_CPUS=8192(e.g. Ubuntu 22.04 uses this):
drivers/cpufreq/cpufreq_ondemand.c: In function 'od_set_powersave_bias':drivers/cpufreq/cpufreq_ondemand.c:449:1: warning: the frame size of
1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
449 | }| ^
CONFIG_CPUMASK_OFFSTACK=yis enabled by default for most distros, and hence we can work around the warning by usingcpumask_var_t.Signed-off-by Zhao Liu <[email protected]>--- drivers/cpufreq/cpufreq_ondemand.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/cpufreq/cpufreq_ondemand.c +7
-4@@ -416,10 +416,13 @@ static struct dbs_governor od_dbs_gov = {static void od_set_powersave_bias (unsigned int powersave_bias) {unsigned int cpu; -cpumask_t done; +cpumask_var_t done; + +if (!alloc_cpumask_var (&done,GFP_KERNEL )) +return ; default_powersave_bias = powersave_bias; -cpumask_clear (&done); +cpumask_clear (done);cpus_read_lock ();for_each_online_cpu (cpu) {@@ -428,7 +431,7 @@ static void od_set_powersave_bias(unsigned int powersave_bias)struct dbs_data *dbs_data;struct od_dbs_tuners *od_tuners; -if (cpumask_test_cpu (cpu, &done)) +if (cpumask_test_cpu (cpu, done))continue ; policy =cpufreq_cpu_get_raw (cpu);@@ -439,13 +442,15 @@ static void od_set_powersave_bias(unsigned int powersave_bias)if (!policy_dbs)continue ; -cpumask_or (&done, &done, policy->cpus); +cpumask_or (done, done, policy->cpus);
drivers/cpufreq/cpufreq_ondemand.c static void od_set_powersave_bias(unsigned int powersave_bias) · line 456
Quoted 10 lines
drivers/cpufreq/cpufreq_ondemand.c +2
-0dbs_data = policy_dbs->dbs_data; od_tuners = dbs_data->tuners; od_tuners->powersave_bias = default_powersave_bias; }cpus_read_unlock (); + +free_cpumask_var (done); } void od_register_powersave_bias_handler(unsigned int (*f)
Signature · 1 line
viresh
Quoted 64 lines · Viresh Kumar
Quoted 62 lines · Zhao Liu
A cpumask structure on the stack can cause a warning with
CONFIG_NR_CPUS=8192(e.g. Ubuntu 22.04 uses this):
drivers/cpufreq/cpufreq_ondemand.c: In function 'od_set_powersave_bias':drivers/cpufreq/cpufreq_ondemand.c:449:1: warning: the frame size of
1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
449 | }| ^
CONFIG_CPUMASK_OFFSTACK=yis enabled by default for most distros, and hence we can work around the warning by usingcpumask_var_t.Signed-off-by Zhao Liu <[email protected]>--- drivers/cpufreq/cpufreq_ondemand.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/cpufreq/cpufreq_ondemand.c +9
-4@@ -416,10 +416,13 @@ static struct dbs_governor od_dbs_gov = {static void od_set_powersave_bias (unsigned int powersave_bias) {unsigned int cpu; -cpumask_t done; +cpumask_var_t done; + +if (!alloc_cpumask_var (&done,GFP_KERNEL )) +return ; default_powersave_bias = powersave_bias; -cpumask_clear (&done); +cpumask_clear (done);cpus_read_lock ();for_each_online_cpu (cpu) {@@ -428,7 +431,7 @@ static void od_set_powersave_bias(unsigned int powersave_bias)struct dbs_data *dbs_data;struct od_dbs_tuners *od_tuners; -if (cpumask_test_cpu (cpu, &done)) +if (cpumask_test_cpu (cpu, done))continue ; policy =cpufreq_cpu_get_raw (cpu);@@ -439,13 +442,15 @@ static void od_set_powersave_bias(unsigned int powersave_bias)if (!policy_dbs)continue ; -cpumask_or (&done, &done, policy->cpus); +cpumask_or (done, done, policy->cpus); dbs_data = policy_dbs->dbs_data; od_tuners = dbs_data->tuners; od_tuners->powersave_bias = default_powersave_bias; }cpus_read_unlock (); + +free_cpumask_var (done); }
Quoted 3 lines
drivers/cpufreq/cpufreq_ondemand.c static void od_set_powersave_bias(unsigned int powersave_bias) · line 456
Quoted 1 line
drivers/cpufreq/cpufreq_ondemand.c +0
-0void od_register_powersave_bias_handler(unsigned int (*f)Acked-by Viresh Kumar <[email protected]>
Applied as 5.20 material, thanks!