mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 04:31:50 +00:00
fcd7af917a
There are several problems with cpufreq stats in the way it handles cpufreq_unregister_driver() and suspend/resume.. - We must not lose data collected so far when suspend/resume happens and so stats directories must not be removed/allocated during these operations, which is done currently. - cpufreq_stat has registered notifiers with both cpufreq and hotplug. It adds sysfs stats directory with a cpufreq notifier: CPUFREQ_NOTIFY and removes this directory with a notifier from hotplug core. In case cpufreq_unregister_driver() is called (on rmmod cpufreq driver), stats directories per cpu aren't removed as CPUs are still online. The only call cpufreq_stats gets is cpufreq_stats_update_policy_cpu() for all CPUs except the last of each policy. And pointer to stat information is stored in the entry for last CPU in the per-cpu cpufreq_stats_table. But policy structure would be freed inside cpufreq core and so that will result in memory leak inside cpufreq stats (as we are never freeing memory for stats). Now if we again insert the module cpufreq_register_driver() will be called and we will again allocate stats data and put it on for first CPU of every policy. In case we only have a single CPU per policy, we will return with a error from cpufreq_stats_create_table() due to this code: if (per_cpu(cpufreq_stats_table, cpu)) return -EBUSY; And so probably cpufreq stats directory would not show up anymore (as it was added inside last policies->kobj which doesn't exist anymore). I haven't tested it, though. Also the values in stats files wouldn't be refreshed as we are using the earlier stats structure. - CPUFREQ_NOTIFY is called from cpufreq_set_policy() which is called for scenarios where we don't really want cpufreq_stat_notifier_policy() to get called. For example whenever we are changing anything related to a policy: min/max/current freq, etc. cpufreq_set_policy() is called and so cpufreq stats is notified. Where we don't do any useful stuff other than simply returning with -EBUSY from cpufreq_stats_create_table(). And so this isn't the right notifier that cpufreq stats.. Due to all above reasons this patch does following changes: - Add new notifiers CPUFREQ_CREATE_POLICY and CPUFREQ_REMOVE_POLICY, which are only called when policy is created/destroyed. They aren't called for suspend/resume paths.. - Use these notifiers in cpufreq_stat_notifier_policy() to create/destory stats sysfs entries. And so cpufreq_unregister_driver() or suspend/resume shouldn't be a problem for cpufreq_stats. - Return early from cpufreq_stat_cpu_callback() for suspend/resume sequence, so that we don't free stats structure. Acked-by: Nicolas Pitre <nico@linaro.org> Tested-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> |
||
---|---|---|
.. | ||
acpi-cpufreq.c | ||
amd_freq_sensitivity.c | ||
arm_big_little_dt.c | ||
arm_big_little.c | ||
arm_big_little.h | ||
at32ap-cpufreq.c | ||
blackfin-cpufreq.c | ||
cpufreq_conservative.c | ||
cpufreq_governor.c | ||
cpufreq_governor.h | ||
cpufreq_ondemand.c | ||
cpufreq_performance.c | ||
cpufreq_powersave.c | ||
cpufreq_stats.c | ||
cpufreq_userspace.c | ||
cpufreq-cpu0.c | ||
cpufreq-nforce2.c | ||
cpufreq.c | ||
cris-artpec3-cpufreq.c | ||
cris-etraxfs-cpufreq.c | ||
davinci-cpufreq.c | ||
dbx500-cpufreq.c | ||
e_powersaver.c | ||
elanfreq.c | ||
exynos4x12-cpufreq.c | ||
exynos4210-cpufreq.c | ||
exynos5250-cpufreq.c | ||
exynos5440-cpufreq.c | ||
exynos-cpufreq.c | ||
exynos-cpufreq.h | ||
freq_table.c | ||
gx-suspmod.c | ||
highbank-cpufreq.c | ||
ia64-acpi-cpufreq.c | ||
imx6q-cpufreq.c | ||
integrator-cpufreq.c | ||
intel_pstate.c | ||
Kconfig | ||
Kconfig.arm | ||
Kconfig.powerpc | ||
Kconfig.x86 | ||
kirkwood-cpufreq.c | ||
longhaul.c | ||
longhaul.h | ||
longrun.c | ||
loongson2_cpufreq.c | ||
Makefile | ||
maple-cpufreq.c | ||
omap-cpufreq.c | ||
p4-clockmod.c | ||
pasemi-cpufreq.c | ||
pcc-cpufreq.c | ||
pmac32-cpufreq.c | ||
pmac64-cpufreq.c | ||
powernow-k6.c | ||
powernow-k7.c | ||
powernow-k7.h | ||
powernow-k8.c | ||
powernow-k8.h | ||
ppc_cbe_cpufreq_pervasive.c | ||
ppc_cbe_cpufreq_pmi.c | ||
ppc_cbe_cpufreq.c | ||
ppc_cbe_cpufreq.h | ||
ppc-corenet-cpufreq.c | ||
pxa2xx-cpufreq.c | ||
pxa3xx-cpufreq.c | ||
s3c24xx-cpufreq-debugfs.c | ||
s3c24xx-cpufreq.c | ||
s3c64xx-cpufreq.c | ||
s3c2410-cpufreq.c | ||
s3c2412-cpufreq.c | ||
s3c2416-cpufreq.c | ||
s3c2440-cpufreq.c | ||
s5pv210-cpufreq.c | ||
sa1100-cpufreq.c | ||
sa1110-cpufreq.c | ||
sc520_freq.c | ||
sh-cpufreq.c | ||
sparc-us2e-cpufreq.c | ||
sparc-us3-cpufreq.c | ||
spear-cpufreq.c | ||
speedstep-centrino.c | ||
speedstep-ich.c | ||
speedstep-lib.c | ||
speedstep-lib.h | ||
speedstep-smi.c | ||
tegra-cpufreq.c | ||
unicore2-cpufreq.c | ||
vexpress-spc-cpufreq.c |