From: Viresh Kumar <viresh.kumar@linaro.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Rafael Wysocki <rjw@rjwysocki.net>,
Juri Lelli <juri.lelli@arm.com>,
Lists linaro-kernel <linaro-kernel@lists.linaro.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
Saravana Kannan <skannan@codeaurora.org>,
Peter Zijlstra <peterz@infradead.org>,
Michael Turquette <mturquette@baylibre.com>,
Steve Muckle <steve.muckle@linaro.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Morten Rasmussen <morten.rasmussen@arm.com>,
dietmar.eggemann@arm.com,
Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V3 11/13] cpufreq: governor: Keep list of policy_dbs within dbs_data
Date: Mon, 8 Feb 2016 19:00:06 +0530 [thread overview]
Message-ID: <20160208133006.GJ8294@vireshk> (raw)
In-Reply-To: <CAJZ5v0gWhXEcwowPW1O00-7R-Ru4+2DdoRmdYQ-4nLKDf0wyUw@mail.gmail.com>
On 08-02-16, 14:21, Rafael J. Wysocki wrote:
> On Mon, Feb 8, 2016 at 12:39 PM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > An instance of 'struct dbs_data' can support multiple 'struct
> > policy_dbs_info' instances. To traverse all policy_dbs supported by a
> > dbs_data, create a list of policy_dbs within dbs_data.
> >
> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
>
> Good idea overall, I like this.
Thanks.
> > ---
> > drivers/cpufreq/cpufreq_governor.c | 12 ++++++++++++
> > drivers/cpufreq/cpufreq_governor.h | 7 ++++++-
> > 2 files changed, 18 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
> > index ee3c2d92da53..e267acc67067 100644
> > --- a/drivers/cpufreq/cpufreq_governor.c
> > +++ b/drivers/cpufreq/cpufreq_governor.c
> > @@ -489,6 +489,11 @@ static int cpufreq_governor_init(struct cpufreq_policy *policy)
> > dbs_data->usage_count++;
> > policy_dbs->dbs_data = dbs_data;
> > policy->governor_data = policy_dbs;
> > +
> > + mutex_lock(&dbs_data->mutex);
> > + list_add(&policy_dbs->list, &dbs_data->policy_dbs_list);
> > + mutex_unlock(&dbs_data->mutex);
>
> The previous statements should be under the mutex too IMO, at least
> the usage count incrementation in case two instances of this happen at
> the same time.
>
> That can't happen now, but if we want to get rid of dbs_data_mutex
> going forward, having it under the mutex will be actually useful.
I think we should keep it precise for now. Right now, we are only
concerned about the list modification, so just lock around that.
Once we are going to remove dbs_data_mutex, then we can cover more
things under it.
Is there anything that is broken right now ?
> > +
> > return 0;
> > }
> >
> > @@ -500,8 +505,11 @@ static int cpufreq_governor_init(struct cpufreq_policy *policy)
> >
> > dbs_data->usage_count = 1;
> > dbs_data->gov = gov;
> > + INIT_LIST_HEAD(&dbs_data->policy_dbs_list);
> > mutex_init(&dbs_data->mutex);
> >
> > + list_add(&policy_dbs->list, &dbs_data->policy_dbs_list);
>
> That line should go to where policy_dbs->dbs_data is set so it is
> clear that they go together.
Okay.
> And I'd set the usage count to 1 in
> there too for consistency.
I am not sure about including any updates within the lock, which don't
need protection in current state of code.
--
viresh
next prev parent reply other threads:[~2016-02-08 13:30 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-08 11:39 [PATCH V3 00/13] cpufreq: governors: Fix ABBA lockups Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 01/13] cpufreq: governor: Create generic macro for global tuners Viresh Kumar
2016-02-08 16:33 ` Rafael J. Wysocki
2016-02-08 11:39 ` [PATCH V3 02/13] cpufreq: governor: Move common tunables to 'struct dbs_data' Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 03/13] cpufreq: governor: New sysfs show/store callbacks for governor tunables Viresh Kumar
2016-02-08 17:07 ` Viresh Kumar
2016-02-08 21:28 ` Rafael J. Wysocki
2016-02-08 21:36 ` Rafael J. Wysocki
2016-02-09 3:21 ` Viresh Kumar
2016-02-09 20:20 ` Rafael J. Wysocki
2016-02-08 11:39 ` [PATCH V3 04/13] cpufreq: governor: Drop unused macros for creating governor tunable attributes Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 05/13] Revert "cpufreq: Drop rwsem lock around CPUFREQ_GOV_POLICY_EXIT" Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 06/13] cpufreq: Merge cpufreq_offline_prepare/finish routines Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 07/13] cpufreq: Call __cpufreq_governor() with policy->rwsem held Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 08/13] cpufreq: Remove cpufreq_governor_lock Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 09/13] cpufreq: governor: Move common sysfs tunables to cpufreq_governor.c Viresh Kumar
2016-02-08 12:58 ` Rafael J. Wysocki
2016-02-08 13:03 ` Viresh Kumar
2016-02-08 13:24 ` Rafael J. Wysocki
2016-02-08 11:39 ` [PATCH V3 10/13] cpufreq: governor: No need to manage state machine now Viresh Kumar
2016-02-08 11:39 ` [PATCH V3 11/13] cpufreq: governor: Keep list of policy_dbs within dbs_data Viresh Kumar
2016-02-08 13:21 ` Rafael J. Wysocki
2016-02-08 13:30 ` Viresh Kumar [this message]
2016-02-08 13:35 ` Rafael J. Wysocki
2016-02-08 11:39 ` [PATCH V3 12/13] cpufreq: ondemand: Traverse list of policy_dbs in update_sampling_rate() Viresh Kumar
2016-02-08 13:32 ` Rafael J. Wysocki
2016-02-08 13:34 ` Viresh Kumar
2016-02-08 13:37 ` Rafael J. Wysocki
2016-02-08 17:20 ` Viresh Kumar
2016-02-08 22:05 ` Rafael J. Wysocki
2016-02-08 22:08 ` Rafael J. Wysocki
2016-02-08 11:39 ` [PATCH V3 13/13] cpufreq: conservative: Update sample_delay_ns immediately Viresh Kumar
2016-02-08 12:51 ` [PATCH V3 00/13] cpufreq: governors: Fix ABBA lockups Shilpasri G Bhat
2016-02-08 12:54 ` Viresh Kumar
2016-02-08 16:39 ` Juri Lelli
2016-02-08 16:55 ` Viresh Kumar
2016-02-08 21:43 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160208133006.GJ8294@vireshk \
--to=viresh.kumar@linaro.org \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@arm.com \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=morten.rasmussen@arm.com \
--cc=mturquette@baylibre.com \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=rjw@rjwysocki.net \
--cc=shilpa.bhat@linux.vnet.ibm.com \
--cc=skannan@codeaurora.org \
--cc=steve.muckle@linaro.org \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox