Some CPUs support a functionality to raise the operating frequency of some cores in a multi-core package if certain conditions apply, mostly if the whole chip is not fully utilized and below it’s intended thermal budget. The decision about boost disable/enable is made either at hardware (e.g. x86) or software (e.g ARM). On Intel CPUs this is called “Turbo Boost”, AMD calls it “Turbo-Core”, in technical documentation “Core performance boost”. In Linux we use the term “boost” for convenience.
To allow the user to toggle the boosting functionality, the cpufreq core driver exports a sysfs knob to enable or disable it. There is a file: /sys/devices/system/cpu/cpufreq/boost
ret = cpufreq_register_driver(&acpi_cpufreq_driver); if (ret) { ... }
late_initcall(acpi_cpufreq_init);
acpi drv在注册到core前就定下了。还有一处在core里:
intcpufreq_enable_boost_support(void) { if (!cpufreq_driver) return -EINVAL;
if (cpufreq_boost_supported()) return0;
cpufreq_driver->set_boost = cpufreq_boost_set_sw; //tj: here
/* This will get removed on driver unregister */ return create_boost_sysfs_file(); } EXPORT_SYMBOL_GPL(cpufreq_enable_boost_support);
cpufreq-dt.c会call:
staticintcpufreq_init(struct cpufreq_policy *policy) { ... /* Support turbo/boost mode */ if (policy_has_boost_freq(policy)) { /* This gets disabled by core on driver unregister */ ret = cpufreq_enable_boost_support(); if (ret)
/kernel/msm-4.9/drivers/base/power/opp/ H A D cpu.c 85 freq_table[i].flags = CPUFREQ_BOOST_FREQ;
opp是啥?和pm有关:
/** * dev_pm_opp_init_cpufreq_table() - create a cpufreq table for a device ... int dev_pm_opp_init_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table) { ... /* Is Boost/turbo opp ? */ if (dev_pm_opp_is_turbo(opp)) freq_table[i].flags = CPUFREQ_BOOST_FREQ; }
/** * show_scaling_available_frequencies - show available normal frequencies for * the specified CPU */ staticssize_tscaling_available_frequencies_show(struct cpufreq_policy *policy, char *buf) { return show_available_freqs(policy, buf, false); } cpufreq_attr_available_freq(scaling_available); EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs);
scaling_boost是show boost freq:
/** * show_available_boost_freqs - show available boost frequencies for * the specified CPU */ staticssize_tscaling_boost_frequencies_show(struct cpufreq_policy *policy, char *buf) { return show_available_freqs(policy, buf, true); } cpufreq_attr_available_freq(scaling_boost);