From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1948340AbcBSC1j (ORCPT ); Thu, 18 Feb 2016 21:27:39 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:36715 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946891AbcBSC1h (ORCPT ); Thu, 18 Feb 2016 21:27:37 -0500 Date: Fri, 19 Feb 2016 07:57:21 +0530 From: Viresh Kumar To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Linux PM list , Linux Kernel Mailing List Subject: Re: [PATCH 1/12] cpufreq: governor: Close dbs_data update race condition Message-ID: <20160219022721.GA16983@vireshk-i7> References: <2938006.67J0esUvOA@vostro.rjw.lan> <1592265.QLnTJA45ZD@vostro.rjw.lan> <20160218052409.GG2610@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18-02-16, 17:20, Rafael J. Wysocki wrote: > On Thu, Feb 18, 2016 at 6:24 AM, Viresh Kumar wrote: > > On 18-02-16, 02:19, Rafael J. Wysocki wrote: > >> @@ -112,7 +112,7 @@ static ssize_t governor_store(struct kob > >> > >> mutex_lock(&dbs_data->mutex); > >> > >> - if (gattr->store) > >> + if (dbs_data->usage_count && gattr->store) > > > > That's not gonna be enough. The above lock doesn't guarantee > > protection with any such races. Oops, I completely misread it. Really sorry about that. But now that I have read the code again, I wonder why we need this protection at all. The first thing we do after decrementing the usage_count counter, is we put the kobject. Which will ensure that the sysfs files are all gone. So, what is the race we are trying to fix then? > Yeah, they are quite useless. But not in this patch. Sure. -- viresh