提交 d9cc34a6 编写于 作者: A Arnd Bergmann 提交者: Zhang Rui

thermal: use cpumask_var_t for on-stack cpu masks

Putting a bare cpumask structure on the stack produces a warning on
large SMP configurations:

drivers/thermal/cpu_cooling.c: In function 'cpufreq_state2power':
drivers/thermal/cpu_cooling.c:644:1: warning: the frame size of 1056 bytes is larger than 1024 bytes [-Wframe-larger-than=]
drivers/thermal/cpu_cooling.c: In function '__cpufreq_cooling_register':
drivers/thermal/cpu_cooling.c:898:1: warning: the frame size of 1104 bytes is larger than 1024 bytes [-Wframe-larger-than=]

The recommended workaround is to use cpumask_var_t, which behaves just like
a normal cpu mask in most cases, but turns into a dynamic allocation
when CONFIG_CPUMASK_OFFSTACK is set.
Signed-off-by: NArnd Bergmann <arnd@arndb.de>
Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: NZhang Rui <rui.zhang@intel.com>
上级 d5adbfcd
...@@ -652,31 +652,39 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev, ...@@ -652,31 +652,39 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev,
unsigned long state, u32 *power) unsigned long state, u32 *power)
{ {
unsigned int freq, num_cpus; unsigned int freq, num_cpus;
cpumask_t cpumask; cpumask_var_t cpumask;
u32 static_power, dynamic_power; u32 static_power, dynamic_power;
int ret; int ret;
struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
cpumask_and(&cpumask, &cpufreq_device->allowed_cpus, cpu_online_mask); if (!alloc_cpumask_var(&cpumask, GFP_KERNEL))
num_cpus = cpumask_weight(&cpumask); return -ENOMEM;
cpumask_and(cpumask, &cpufreq_device->allowed_cpus, cpu_online_mask);
num_cpus = cpumask_weight(cpumask);
/* None of our cpus are online, so no power */ /* None of our cpus are online, so no power */
if (num_cpus == 0) { if (num_cpus == 0) {
*power = 0; *power = 0;
return 0; ret = 0;
goto out;
} }
freq = cpufreq_device->freq_table[state]; freq = cpufreq_device->freq_table[state];
if (!freq) if (!freq) {
return -EINVAL; ret = -EINVAL;
goto out;
}
dynamic_power = cpu_freq_to_power(cpufreq_device, freq) * num_cpus; dynamic_power = cpu_freq_to_power(cpufreq_device, freq) * num_cpus;
ret = get_static_power(cpufreq_device, tz, freq, &static_power); ret = get_static_power(cpufreq_device, tz, freq, &static_power);
if (ret) if (ret)
return ret; goto out;
*power = static_power + dynamic_power; *power = static_power + dynamic_power;
return 0; out:
free_cpumask_var(cpumask);
return ret;
} }
/** /**
...@@ -802,16 +810,20 @@ __cpufreq_cooling_register(struct device_node *np, ...@@ -802,16 +810,20 @@ __cpufreq_cooling_register(struct device_node *np,
struct cpufreq_cooling_device *cpufreq_dev; struct cpufreq_cooling_device *cpufreq_dev;
char dev_name[THERMAL_NAME_LENGTH]; char dev_name[THERMAL_NAME_LENGTH];
struct cpufreq_frequency_table *pos, *table; struct cpufreq_frequency_table *pos, *table;
struct cpumask temp_mask; cpumask_var_t temp_mask;
unsigned int freq, i, num_cpus; unsigned int freq, i, num_cpus;
int ret; int ret;
struct thermal_cooling_device_ops *cooling_ops; struct thermal_cooling_device_ops *cooling_ops;
cpumask_and(&temp_mask, clip_cpus, cpu_online_mask); if (!alloc_cpumask_var(&temp_mask, GFP_KERNEL))
policy = cpufreq_cpu_get(cpumask_first(&temp_mask)); return ERR_PTR(-ENOMEM);
cpumask_and(temp_mask, clip_cpus, cpu_online_mask);
policy = cpufreq_cpu_get(cpumask_first(temp_mask));
if (!policy) { if (!policy) {
pr_debug("%s: CPUFreq policy not found\n", __func__); pr_debug("%s: CPUFreq policy not found\n", __func__);
return ERR_PTR(-EPROBE_DEFER); cool_dev = ERR_PTR(-EPROBE_DEFER);
goto free_cpumask;
} }
table = policy->freq_table; table = policy->freq_table;
...@@ -931,7 +943,8 @@ __cpufreq_cooling_register(struct device_node *np, ...@@ -931,7 +943,8 @@ __cpufreq_cooling_register(struct device_node *np,
kfree(cpufreq_dev); kfree(cpufreq_dev);
put_policy: put_policy:
cpufreq_cpu_put(policy); cpufreq_cpu_put(policy);
free_cpumask:
free_cpumask_var(temp_mask);
return cool_dev; return cool_dev;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册