Skip to content

cpufreq/schedutil: Fix null pointer dereference in sugov_update_single_freq

Wyes Karny linux-pm lkml stable 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 5 repliesIn review
  2. v12 patches 3 repliesSuperseded

Changes in v2 from the cover letter

- Remove fast_switch_enabled flag dependency for adjust_perf callback

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2cpufreq/schedutil: Remove fast_switch_possible flag if driver doesn't set fast_switchdrivers/cpufreq/amd-pstate.c drivers/cpufreq/cpufreq.c drivers/cpufreq/intel_pstate.c +2 more+29 -75 replies
2/2amd_pstate: Add ->fast_switch() callbackdrivers/cpufreq/amd-pstate.c+32 -80 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] cpufreq/schedutil: Fix null pointer dereference in sugov_update_single_freq

Currently, amd_pstate only uses adjust_perf and target callback functions to get the frequency/effective utilization data from scaling governors. Schedutil generally avoids calling target and fast_switch functions if adjust_perf function pointer is set for the driver. But in some rare cases, schedutil tries to call fast_switch function even the function pointer is not set. This happens when frequency invariance is turned off. When frequency invariance is turned off schedutil falls back to sugov_update_single_freq which currently relies on the fast_switch callback.

Currently, frequency invariance is turned off when any anomaly is detected with aperf/mperf readings. Which triggers this problem.

Fix this by disabling fast_switch_enabled flag if fast_switch callback is not set and removing fast_switch_enabled flag dependency for adjust_perf callback. But this will force schedutil to take a slower path to update frequency. Therefore to fix this add fast_switch function on amd_pstate to take advantage of fast frequency update.

Changelog:
v1 -> v2
- Remove fast_switch_enabled flag dependency for adjust_perf callback

v1: https://lore.kernel.org/linux-pm/[email protected]/

Gautham R. Shenoy (1):
amd_pstate: Add ->fast_switch() callback

Wyes Karny (1):
cpufreq/schedutil: Remove fast_switch_possible flag if driver doesn't
set fast_switch

 drivers/cpufreq/amd-pstate.c     | 46 +++++++++++++++++++++++++-------
 drivers/cpufreq/cpufreq.c        | 20 +++++++++++++-
 drivers/cpufreq/intel_pstate.c   |  3 +--
 include/linux/cpufreq.h          |  1 +
 kernel/sched/cpufreq_schedutil.c |  2 +-
 5 files changed, 59 insertions(+), 13 deletions(-)
Signature · 1 line
2.34.1