diff mbox

cpufreq: Use list_is_last() to check last entry of the policy list

Message ID 1453715167-26165-1-git-send-email-ego@linux.vnet.ibm.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Gautham R Shenoy Jan. 25, 2016, 9:46 a.m. UTC
Currently next_policy() explicitly checks if a policy is the last
policy in the cpufreq_policy_list. Use the standard list_is_last
primitive instead.

Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
---
 drivers/cpufreq/cpufreq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Viresh Kumar Jan. 25, 2016, 9:50 a.m. UTC | #1
On 25-01-16, 15:16, Gautham R. Shenoy wrote:
> Currently next_policy() explicitly checks if a policy is the last
> policy in the cpufreq_policy_list. Use the standard list_is_last
> primitive instead.
> 
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> ---
>  drivers/cpufreq/cpufreq.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 78b1e2f..b3059a3 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -67,11 +67,11 @@ static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy,
>  {
>  	lockdep_assert_held(&cpufreq_driver_lock);
>  	do {
> -		policy = list_next_entry(policy, policy_list);
> -
>  		/* No more policies in the list */
> -		if (&policy->policy_list == &cpufreq_policy_list)
> +		if (list_is_last(&policy->policy_list, &cpufreq_policy_list))
>  			return NULL;
> +
> +		policy = list_next_entry(policy, policy_list);
>  	} while (!suitable_policy(policy, active));
>  
>  	return policy;

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Juri Lelli Jan. 25, 2016, 11:18 a.m. UTC | #2
Hi,

On 25/01/16 15:20, Viresh Kumar wrote:
> On 25-01-16, 15:16, Gautham R. Shenoy wrote:
> > Currently next_policy() explicitly checks if a policy is the last
> > policy in the cpufreq_policy_list. Use the standard list_is_last
> > primitive instead.
> > 
> > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> > ---
> >  drivers/cpufreq/cpufreq.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > index 78b1e2f..b3059a3 100644
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -67,11 +67,11 @@ static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy,
> >  {
> >  	lockdep_assert_held(&cpufreq_driver_lock);

Which branch is this patch based on?

Thanks,

- Juri

> >  	do {
> > -		policy = list_next_entry(policy, policy_list);
> > -
> >  		/* No more policies in the list */
> > -		if (&policy->policy_list == &cpufreq_policy_list)
> > +		if (list_is_last(&policy->policy_list, &cpufreq_policy_list))
> >  			return NULL;
> > +
> > +		policy = list_next_entry(policy, policy_list);
> >  	} while (!suitable_policy(policy, active));
> >  
> >  	return policy;
> 
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> 
> -- 
> viresh
> 
--
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
Viresh Kumar Jan. 25, 2016, 11:22 a.m. UTC | #3
On 25-01-16, 11:18, Juri Lelli wrote:
> Hi,
> 
> On 25/01/16 15:20, Viresh Kumar wrote:
> > On 25-01-16, 15:16, Gautham R. Shenoy wrote:
> > > Currently next_policy() explicitly checks if a policy is the last
> > > policy in the cpufreq_policy_list. Use the standard list_is_last
> > > primitive instead.
> > > 
> > > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > > Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> > > ---
> > >  drivers/cpufreq/cpufreq.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > index 78b1e2f..b3059a3 100644
> > > --- a/drivers/cpufreq/cpufreq.c
> > > +++ b/drivers/cpufreq/cpufreq.c
> > > @@ -67,11 +67,11 @@ static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy,
> > >  {
> > >  	lockdep_assert_held(&cpufreq_driver_lock);
> 
> Which branch is this patch based on?

Dude, what's going on here? How come you rebased on Juri's patches ?
:)
Gautham R Shenoy Jan. 27, 2016, 5:57 a.m. UTC | #4
On Mon, Jan 25, 2016 at 04:52:15PM +0530, Viresh Kumar wrote:
> On 25-01-16, 11:18, Juri Lelli wrote:
> > Hi,
> > 
> > On 25/01/16 15:20, Viresh Kumar wrote:
> > > On 25-01-16, 15:16, Gautham R. Shenoy wrote:
> > > > Currently next_policy() explicitly checks if a policy is the last
> > > > policy in the cpufreq_policy_list. Use the standard list_is_last
> > > > primitive instead.
> > > > 
> > > > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > > > Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> > > > ---
> > > >  drivers/cpufreq/cpufreq.c | 6 +++---
> > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > > index 78b1e2f..b3059a3 100644
> > > > --- a/drivers/cpufreq/cpufreq.c
> > > > +++ b/drivers/cpufreq/cpufreq.c
> > > > @@ -67,11 +67,11 @@ static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy,
> > > >  {
> > > >  	lockdep_assert_held(&cpufreq_driver_lock);
> > 
> > Which branch is this patch based on?
> 
> Dude, what's going on here? How come you rebased on Juri's patches ?
> :)

Ah right! I found this issue while reviewing Juri's patches from the
cpufreq-cleanups branch and didn't switch back to pm-next before
making this change. Shall resend the patch.

> 
> -- 
> viresh
> 

--
Thanks and Regards
gautham.

--
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
Gautham R Shenoy Jan. 27, 2016, 6:09 a.m. UTC | #5
On Mon, Jan 25, 2016 at 11:18:24AM +0000, Juri Lelli wrote:
> Hi,
> 
> On 25/01/16 15:20, Viresh Kumar wrote:
> > On 25-01-16, 15:16, Gautham R. Shenoy wrote:
> > > Currently next_policy() explicitly checks if a policy is the last
> > > policy in the cpufreq_policy_list. Use the standard list_is_last
> > > primitive instead.
> > > 
> > > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > > Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> > > ---
> > >  drivers/cpufreq/cpufreq.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > index 78b1e2f..b3059a3 100644
> > > --- a/drivers/cpufreq/cpufreq.c
> > > +++ b/drivers/cpufreq/cpufreq.c
> > > @@ -67,11 +67,11 @@ static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy,
> > >  {
> > >  	lockdep_assert_held(&cpufreq_driver_lock);
> 
> Which branch is this patch based on?

My bad! This is based on your branch  git://linux-arm.org/linux-jl.git
upstream/cpufreq_cleanups. I found this issue while reviewing your
cleanup patches.


> 
> Thanks,
> 
> - Juri

--
Thanks and Regards
gautham.

--
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
Juri Lelli Jan. 27, 2016, 10:10 a.m. UTC | #6
On 27/01/16 11:39, Gautham R Shenoy wrote:
> On Mon, Jan 25, 2016 at 11:18:24AM +0000, Juri Lelli wrote:
> > Hi,
> > 
> > On 25/01/16 15:20, Viresh Kumar wrote:
> > > On 25-01-16, 15:16, Gautham R. Shenoy wrote:
> > > > Currently next_policy() explicitly checks if a policy is the last
> > > > policy in the cpufreq_policy_list. Use the standard list_is_last
> > > > primitive instead.
> > > > 
> > > > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > > > Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> > > > ---
> > > >  drivers/cpufreq/cpufreq.c | 6 +++---
> > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > > index 78b1e2f..b3059a3 100644
> > > > --- a/drivers/cpufreq/cpufreq.c
> > > > +++ b/drivers/cpufreq/cpufreq.c
> > > > @@ -67,11 +67,11 @@ static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy,
> > > >  {
> > > >  	lockdep_assert_held(&cpufreq_driver_lock);
> > 
> > Which branch is this patch based on?
> 
> My bad! This is based on your branch  git://linux-arm.org/linux-jl.git
> upstream/cpufreq_cleanups. I found this issue while reviewing your
> cleanup patches.
> 

No problem, and thanks for reviewing those! Any feedback? :)

Best,

- 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
Gautham R Shenoy Jan. 27, 2016, 11:12 a.m. UTC | #7
On Wed, Jan 27, 2016 at 10:10:20AM +0000, Juri Lelli wrote:
> On 27/01/16 11:39, Gautham R Shenoy wrote:
> > On Mon, Jan 25, 2016 at 11:18:24AM +0000, Juri Lelli wrote:
> > > Hi,
> > > 
> > > On 25/01/16 15:20, Viresh Kumar wrote:
> > > > On 25-01-16, 15:16, Gautham R. Shenoy wrote:
> > > > > Currently next_policy() explicitly checks if a policy is the last
> > > > > policy in the cpufreq_policy_list. Use the standard list_is_last
> > > > > primitive instead.
> > > > > 
> > > > > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > > > > Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> > > > > ---
> > > > >  drivers/cpufreq/cpufreq.c | 6 +++---
> > > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > > > index 78b1e2f..b3059a3 100644
> > > > > --- a/drivers/cpufreq/cpufreq.c
> > > > > +++ b/drivers/cpufreq/cpufreq.c
> > > > > @@ -67,11 +67,11 @@ static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy,
> > > > >  {
> > > > >  	lockdep_assert_held(&cpufreq_driver_lock);
> > > 
> > > Which branch is this patch based on?
> > 
> > My bad! This is based on your branch  git://linux-arm.org/linux-jl.git
> > upstream/cpufreq_cleanups. I found this issue while reviewing your
> > cleanup patches.
> > 
> 
> No problem, and thanks for reviewing those! Any feedback? :)

It's a timely patchset! 

Off late on POWER systems we've been observing a lot of jitters due to
the on-demand worker thread periodically interrupting a running task
to monitor (not necessarily change if the task!) frequency. We would
very much like to see the frequency monitoring/change happen from an
the timer-context instead of waking up a separate worker thread,
something similar to CPUFREQ_DRIVER_FAST in sched_governor.  However,
that approach required a careful audit of all the locks that are
currently taken in cpufreq core and this patch set is a good attempt
in this direction.

Barring the issues raised by Viresh with respect to the locking
conventions around CPUFREQ_GOV_POLICY_EXIT, I didn't have any
particular issues with it.


> 
> Best,
> 
> - Juri
> 

--
Thanks and Regards
gautham.

--
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 mbox

Patch

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 78b1e2f..b3059a3 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -67,11 +67,11 @@  static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy,
 {
 	lockdep_assert_held(&cpufreq_driver_lock);
 	do {
-		policy = list_next_entry(policy, policy_list);
-
 		/* No more policies in the list */
-		if (&policy->policy_list == &cpufreq_policy_list)
+		if (list_is_last(&policy->policy_list, &cpufreq_policy_list))
 			return NULL;
+
+		policy = list_next_entry(policy, policy_list);
 	} while (!suitable_policy(policy, active));
 
 	return policy;