]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
cpufreq: schedutil: Fix sugov_start() versus sugov_update_shared() race
authorVikram Mulukutla <markivx@codeaurora.org>
Thu, 6 Jul 2017 17:53:20 +0000 (10:53 -0700)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 12 Jul 2017 12:47:48 +0000 (14:47 +0200)
commitab2f7cf141aa6734c4ca7525132d8cc236efee77
tree6a2e41128c88d4843b795f566c69c3d572708871
parent6f7da290413ba713f0cdd9ff1a2a9bb129ef4f6c
cpufreq: schedutil: Fix sugov_start() versus sugov_update_shared() race

With a shared policy in place, when one of the CPUs in the policy is
hotplugged out and then brought back online, sugov_stop() and
sugov_start() are called in order.

sugov_stop() removes utilization hooks for each CPU in the policy and
does nothing else in the for_each_cpu() loop. sugov_start() on the
other hand iterates through the CPUs in the policy and re-initializes
the per-cpu structure _and_ adds the utilization hook.  This implies
that the scheduler is allowed to invoke a CPU's utilization update
hook when the rest of the per-cpu structures have yet to be
re-inited.

Apart from some strange values in tracepoints this doesn't cause a
problem, but if we do end up accessing a pointer from the per-cpu
sugov_cpu structure somewhere in the sugov_update_shared() path,
we will likely see crashes since the memset for another CPU in the
policy is free to race with sugov_update_shared from the CPU that is
ready to go.  So let's fix this now to first init all per-cpu
structures, and then add the per-cpu utilization update hooks all at
once.

Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
kernel/sched/cpufreq_schedutil.c