Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1339484

Re: [PATCH v2 1/2] cpufreq: governor: Fix race in dbs_update_util_handler()

From Viresh Kumar <viresh.kumar@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2 1/2] cpufreq: governor: Fix race in dbs_update_util_handler()
Date 2016-02-22 14:50 +0100
Message-ID <r4Z2b-6yP-27@gated-at.bofh.it> (permalink)
References <r4rMR-799-3@gated-at.bofh.it> <r4rMR-799-1@gated-at.bofh.it> <r4Yz8-6mO-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 22-02-16, 14:14, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> There is a scenario that may lead to undesired results in
> dbs_update_util_handler().  Namely, if two CPUs sharing a policy
> enter the funtion at the same time, pass the sample delay check
> and then one of them is stalled until dbs_work_handler() (queued
> up by the other CPU) clears the work counter, it may update the
> work counter and queue up another work item prematurely.
> 
> To prevent that from happening, use the observation that the CPU
> queuing up a work item in dbs_update_util_handler() updates the
> last sample time.  This means that if another CPU was stalling after
> passing the sample delay check and now successfully updated the work
> counter as a result of the race described above, it will see the new
> value of the last sample time which is different from what it used in
> the sample delay check before.  If that happens, the sample delay
> check passed previously is not valid any more, so the CPU should not
> continue.
> 
> Fixes: f17cbb53783c (cpufreq: governor: Avoid atomic operations in hot paths)
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> 
> Changes from v1:
> - Typo in the changelog fixed.
> - READ_ONCE() used instead of ACCESS_ONCE().
> - If the race is detected, return instead of looping.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] cpufreq: governor: Fix race in dbs_update_util_handler() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-21 03:20 +0100
  Re: [PATCH 1/2] cpufreq: governor: Fix race in  dbs_update_util_handler() Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-22 06:30 +0100
    Re: [PATCH 1/2] cpufreq: governor: Fix race in dbs_update_util_handler() "Rafael J. Wysocki" <rafael@kernel.org> - 2016-02-22 13:30 +0100
      Re: [PATCH 1/2] cpufreq: governor: Fix race in  dbs_update_util_handler() Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-22 14:10 +0100
        Re: [PATCH 1/2] cpufreq: governor: Fix race in dbs_update_util_handler() "Rafael J. Wysocki" <rafael@kernel.org> - 2016-02-22 14:40 +0100
  [PATCH v2 1/2] cpufreq: governor: Fix race in dbs_update_util_handler() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-22 14:20 +0100
    Re: [PATCH v2 1/2] cpufreq: governor: Fix race in  dbs_update_util_handler() Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-22 14:50 +0100

csiph-web