From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752869AbcBEW6J (ORCPT ); Fri, 5 Feb 2016 17:58:09 -0500 Received: from v094114.home.net.pl ([79.96.170.134]:51249 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751733AbcBEW6F (ORCPT ); Fri, 5 Feb 2016 17:58:05 -0500 From: "Rafael J. Wysocki" To: Viresh Kumar Cc: Linux PM list , Linux Kernel Mailing List , Srinivas Pandruvada , Juri Lelli , Steve Muckle , Saravana Kannan Subject: Re: [PATCH v2 2/10] cpufreq: governor: Use common mutex for dbs_data protection Date: Fri, 05 Feb 2016 23:59:11 +0100 Message-ID: <4787292.dQnn9ZTm9B@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/4.5.0-rc1+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20160205065341.GE21792@vireshk> References: <3705929.bslqXH980s@vostro.rjw.lan> <76588769.1gWBaNHTiQ@vostro.rjw.lan> <20160205065341.GE21792@vireshk> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday, February 05, 2016 12:23:41 PM Viresh Kumar wrote: > On 05-02-16, 03:14, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > Every governor relying on the common code in cpufreq_governor.c > > has to provide its own mutex in struct common_dbs_data. However, > > there actually is no need to have a separate mutex per governor > > for this purpose, they may be using the same global mutex just > > fine. Accordingly, introduce a single common mutex for that and > > drop the mutex field from struct common_dbs_data. > > > > That at least will ensure that the mutex is always present and > > initialized regardless of what the particular governors do. > > > > Another benefit is that the common code does not need a pointer to > > a governor-related structure to get to the mutex which sometimes > > helps. > > > > Finally, it makes the code generally easier to follow. > > > > Signed-off-by: Rafael J. Wysocki > > Acked-by: Saravana Kannan > > Acked-by: Viresh Kumar Thanks! One more observation here. If we are able to eliminate dbs_data_mutex from update_sampling_rate(), then cpufreq_governor_dbs() becomes the only user of that lock. Further, if we can guarantee that the governor's ->governor callback will always be invoked under policy->rwsem, dbs_data_mutex becomes unnecessary and may be dropped. Thanks, Rafael