From patchwork Tue Jan 12 11:21:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 59605 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2674374lbb; Tue, 12 Jan 2016 03:21:09 -0800 (PST) X-Received: by 10.66.136.101 with SMTP id pz5mr58887321pab.91.1452597669730; Tue, 12 Jan 2016 03:21:09 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q21si99410pfq.156.2016.01.12.03.21.09; Tue, 12 Jan 2016 03:21:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752759AbcALLVI (ORCPT + 11 others); Tue, 12 Jan 2016 06:21:08 -0500 Received: from foss.arm.com ([217.140.101.70]:33497 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbcALLVH (ORCPT ); Tue, 12 Jan 2016 06:21:07 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EDAD24A7; Tue, 12 Jan 2016 03:20:31 -0800 (PST) Received: from e106622-lin (e106622-lin.cambridge.arm.com [10.1.208.152]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5861A3F246; Tue, 12 Jan 2016 03:21:05 -0800 (PST) Date: Tue, 12 Jan 2016 11:21:25 +0000 From: Juri Lelli To: Viresh Kumar Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rjw@rjwysocki.net, mturquette@baylibre.com, steve.muckle@linaro.org, vincent.guittot@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com Subject: Re: [RFC PATCH 04/19] cpufreq: bring data structures close to their locks Message-ID: <20160112112125.GA7015@e106622-lin> References: <1452533760-13787-1-git-send-email-juri.lelli@arm.com> <1452533760-13787-5-git-send-email-juri.lelli@arm.com> <20160111220708.GK6344@twins.programming.kicks-ass.net> <20160112092752.GV1084@ubuntu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160112092752.GV1084@ubuntu> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Hi, On 12/01/16 14:57, Viresh Kumar wrote: > On 11-01-16, 23:07, Peter Zijlstra wrote: > > On Mon, Jan 11, 2016 at 05:35:45PM +0000, Juri Lelli wrote: > > > +/** > > > + * Iterate over governors > > > + * > > > + * cpufreq_governor_list is protected by cpufreq_governor_mutex. > > > + */ > > > +static LIST_HEAD(cpufreq_governor_list); > > > +static DEFINE_MUTEX(cpufreq_governor_mutex); > > > +#define for_each_governor(__governor) \ > > > + list_for_each_entry(__governor, &cpufreq_governor_list, governor_list) > > > > So you could stuff the lockdep_assert_held() you later add intididually > > into the for_each_governor macro, impossible to forget that way. > > How exactly? I couldn't see how it can be done in a neat and clean > way. > I tried to see if something like for_each_domain() can be done, but here we use list_for_each_entry() macro. Peter, do you mean something like the following? Since for_each_governor() is not used in if conditions that should be fine? Thanks, - Juri -- 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.c b/drivers/cpufreq/cpufreq.c index 78b1e2f..1a847a6 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -39,6 +39,7 @@ static LIST_HEAD(cpufreq_governor_list); static DEFINE_MUTEX(cpufreq_governor_mutex); #define for_each_governor(__governor) \ + lockdep_assert_held(&cpufreq_governor_mutex); \ list_for_each_entry(__governor, &cpufreq_governor_list, governor_list) /** @@ -508,7 +509,6 @@ static struct cpufreq_governor *find_governor(const char *str_governor) { struct cpufreq_governor *t; - lockdep_assert_held(&cpufreq_governor_mutex); for_each_governor(t) if (!strncasecmp(str_governor, t->name, CPUFREQ_NAME_LEN)) return t;