From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752393AbbLEEKs (ORCPT ); Fri, 4 Dec 2015 23:10:48 -0500 Received: from mail-pf0-f174.google.com ([209.85.192.174]:34809 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752006AbbLEEKq (ORCPT ); Fri, 4 Dec 2015 23:10:46 -0500 Date: Sat, 5 Dec 2015 09:40:42 +0530 From: Viresh Kumar To: "Rafael J. Wysocki" Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, ashwin.chaugule@linaro.org, "Rafael J. Wysocki" , open list Subject: Re: [PATCH V2 5/6] cpufreq: governor: replace per-cpu delayed work with timers Message-ID: <20151205041042.GU3430@ubuntu> References: <10439879.00aCyM9quW@vostro.rjw.lan> <20151204061101.GA3430@ubuntu> <2132445.kEr4nQIvso@vostro.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2132445.kEr4nQIvso@vostro.rjw.lan> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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