Message ID | 20151204061101.GA3430@ubuntu |
---|---|
State | New |
Headers | show |
On 05-12-15, 03:14, Rafael J. Wysocki wrote: > Well, almost, but not quite yet, because now the question is what prevents > gov_cancel_work() from racing with dbs_work_handler(). > > If you can guarantee that they'll never run in parallel with each other, They can run in parallel and that's how we fix it now: - raising skip_work to 2 makes sure that no new timer-handler can queue a new work. - After raising the value of skip_work to 2, we do cancel_work_sync(). Which will make sure that the work-handler has finished after cancel_work_sync() has returned. - At this point of time we are sure that the works and their handlers are completely killed. - All that is left is to kill all timer-handler (which might have gotten queued from the work handler, before it finished). - And we do that with gov_cancel_timers(). - And then we are in safe state, where we are guaranteed that there are no leftovers. > you probably don't need the whole counter dance. Otherwise, dbs_work_handler() > should decrement the counter under the spinlock after all I suppose. Its not required because we don't have any race around that decrement operation. -- viresh -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index a3f9bc9b98e9..c9e420bd0eec 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -265,11 +265,9 @@ static void dbs_timer_handler(unsigned long data) { struct cpu_dbs_info *cdbs = (struct cpu_dbs_info *)data; struct cpu_common_dbs_info *shared = cdbs->shared; - struct cpufreq_policy *policy; unsigned long flags; spin_lock_irqsave(&shared->timer_lock, flags); - policy = shared->policy; /* * Timer handler isn't allowed to queue work at the moment, because: @@ -277,13 +275,11 @@ static void dbs_timer_handler(unsigned long data) * - We are stopping the governor * - Or we are updating the sampling rate of ondemand governor */ - if (shared->skip_work) - goto unlock; - - shared->skip_work++; - queue_work(system_wq, &shared->work); + if (!shared->skip_work) { + shared->skip_work++; + queue_work(system_wq, &shared->work); + } -unlock: spin_unlock_irqrestore(&shared->timer_lock, flags); }