On 05/08/2019 07:11, Martin Kepplinger wrote: > --- [ ... ]
>> +static s64 cpuidle_cooling_runtime(struct cpuidle_cooling_device *idle_cdev) >> +{ >> + s64 next_wakeup; >> + unsigned long state = idle_cdev->state; >> + >> + /* >> + * The function should not be called when there is no >> + * mitigation because: >> + * - that does not make sense >> + * - we end up with a division by zero >> + */ >> + if (!state) >> + return 0; >> + >> + next_wakeup = (s64)((idle_cdev->idle_cycle * 100) / state) - >> + idle_cdev->idle_cycle; >> + >> + return next_wakeup * NSEC_PER_USEC; >> +} >> + > > There is a bug in your calculation formula here when "state" becomes 100. > You return 0 for the injection rate, which is the same as "rate" being 0, > which is dangerous. You stop cooling when it's most necessary :) Right, thanks for spotting this. > I'm not sure how much sense really being 100% idle makes, so I, when testing > this, just say if (state == 100) { state = 99 }. Anyways, just don't return 0. > > Daniel, thanks a lot for these additions! Could you send an update of this? Yes, I'm working on a new version. > btw, that's what I'm referring to: > https://lore.kernel.org/linux-pm/1522945005-7165-1-git-send-email-daniel.lezc...@linaro.org/ > I know it's a little old already, but it seems like there hasn't been any > equivalent solution in the meantime, has it? > > Using cpuidle for cooling is way more effective than cpufreq (which often > hardly is). On which platform that happens? -- <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog