Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[CPUFREQ] CPU hotplug, re-create sysfs directory and symlinks

When we discover CPUs that are affected by each other's
frequency/voltage transitions, the first CPU gets a sysfs directory
created, and rest of the siblings get symlinks. Currently, when we
hotplug off only the first CPU, all of the symlinks and the sysfs
directory gets removed. Even though rest of the siblings are still
online and functional, they are orphaned, and no longer governed by
cpufreq.

This patch, given the above scenario, creates a sysfs directory for
the first sibling and symlinks for the rest of the siblings.

Please note the recursive call, it was rather too ugly to roll it
out. And the removal of redundant NULL setting (it is already taken
care of near the top of the function).

Signed-off-by: Jacob Shin <jacob.shin@amd.com>
Acked-by: Mark Langsdorf <mark.langsdorf@amd.com>
Reviewed-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Dave Jones <davej@redhat.com>
Cc: stable@kernel.org

authored by

Jacob Shin and committed by
Dave Jones
27ecddc2 904cc1e6

+18 -2
+18 -2
drivers/cpufreq/cpufreq.c
··· 1208 1208 cpufreq_driver->exit(data); 1209 1209 unlock_policy_rwsem_write(cpu); 1210 1210 1211 + cpufreq_debug_enable_ratelimit(); 1212 + 1213 + #ifdef CONFIG_HOTPLUG_CPU 1214 + /* when the CPU which is the parent of the kobj is hotplugged 1215 + * offline, check for siblings, and create cpufreq sysfs interface 1216 + * and symlinks 1217 + */ 1218 + if (unlikely(cpumask_weight(data->cpus) > 1)) { 1219 + /* first sibling now owns the new sysfs dir */ 1220 + cpumask_clear_cpu(cpu, data->cpus); 1221 + cpufreq_add_dev(get_cpu_sysdev(cpumask_first(data->cpus))); 1222 + 1223 + /* finally remove our own symlink */ 1224 + lock_policy_rwsem_write(cpu); 1225 + __cpufreq_remove_dev(sys_dev); 1226 + } 1227 + #endif 1228 + 1211 1229 free_cpumask_var(data->related_cpus); 1212 1230 free_cpumask_var(data->cpus); 1213 1231 kfree(data); 1214 - per_cpu(cpufreq_cpu_data, cpu) = NULL; 1215 1232 1216 - cpufreq_debug_enable_ratelimit(); 1217 1233 return 0; 1218 1234 } 1219 1235