LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] cpupower : frequency-set -r option misses the last cpu in related cpu list
@ 2019-05-29  9:30 Abhishek Goel
  2019-05-29 12:12 ` Gautham R Shenoy
  0 siblings, 1 reply; 4+ messages in thread
From: Abhishek Goel @ 2019-05-29  9:30 UTC (permalink / raw)
  To: trenn, shuah, linux-pm, linux-kernel; +Cc: Abhishek Goel

To set frequency on specific cpus using cpupower, following syntax can
be used :
cpupower -c #i frequency-set -f #f -r

While setting frequency using cpupower frequency-set command, if we use
'-r' option, it is expected to set frequency for all cpus related to
cpu #i. But it is observed to be missing the last cpu in related cpu
list. This patch fixes the problem.

Signed-off-by: Abhishek Goel <huntbag@linux.vnet.ibm.com>
---
 tools/power/cpupower/utils/cpufreq-set.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
index 1eef0aed6..08a405593 100644
--- a/tools/power/cpupower/utils/cpufreq-set.c
+++ b/tools/power/cpupower/utils/cpufreq-set.c
@@ -306,6 +306,8 @@ int cmd_freq_set(int argc, char **argv)
 				bitmask_setbit(cpus_chosen, cpus->cpu);
 				cpus = cpus->next;
 			}
+			/* Set the last cpu in related cpus list */
+			bitmask_setbit(cpus_chosen, cpus->cpu);
 			cpufreq_put_related_cpus(cpus);
 		}
 	}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpupower : frequency-set -r option misses the last cpu in related cpu list
  2019-05-29  9:30 [PATCH] cpupower : frequency-set -r option misses the last cpu in related cpu list Abhishek Goel
@ 2019-05-29 12:12 ` Gautham R Shenoy
  2019-05-29 14:21   ` Thomas Renninger
  0 siblings, 1 reply; 4+ messages in thread
From: Gautham R Shenoy @ 2019-05-29 12:12 UTC (permalink / raw)
  To: Abhishek Goel; +Cc: trenn, shuah, Linux PM list, LKML

Hi Abhishek,

On Wed, May 29, 2019 at 3:02 PM Abhishek Goel
<huntbag@linux.vnet.ibm.com> wrote:
>
> To set frequency on specific cpus using cpupower, following syntax can
> be used :
> cpupower -c #i frequency-set -f #f -r
>
> While setting frequency using cpupower frequency-set command, if we use
> '-r' option, it is expected to set frequency for all cpus related to
> cpu #i. But it is observed to be missing the last cpu in related cpu
> list. This patch fixes the problem.
>
> Signed-off-by: Abhishek Goel <huntbag@linux.vnet.ibm.com>
> ---
>  tools/power/cpupower/utils/cpufreq-set.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
> index 1eef0aed6..08a405593 100644
> --- a/tools/power/cpupower/utils/cpufreq-set.c
> +++ b/tools/power/cpupower/utils/cpufreq-set.c
> @@ -306,6 +306,8 @@ int cmd_freq_set(int argc, char **argv)
>                                 bitmask_setbit(cpus_chosen, cpus->cpu);
>                                 cpus = cpus->next;
>                         }
> +                       /* Set the last cpu in related cpus list */
> +                       bitmask_setbit(cpus_chosen, cpus->cpu);

Perhaps you could convert the while() loop to a do ..  while(). That
should will ensure
that we terminate the loop after setting the last valid CPU.


>                         cpufreq_put_related_cpus(cpus);
>                 }
>         }
> --
> 2.17.1
>


-- 
Thanks and Regards
gautham.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpupower : frequency-set -r option misses the last cpu in related cpu list
  2019-05-29 12:12 ` Gautham R Shenoy
@ 2019-05-29 14:21   ` Thomas Renninger
  2019-06-04 15:16     ` shuah
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Renninger @ 2019-05-29 14:21 UTC (permalink / raw)
  To: ego; +Cc: Abhishek Goel, shuah, LKML, Linux PM list

Hi,

On Wednesday, May 29, 2019 2:12:34 PM CEST Gautham R Shenoy wrote:
> Hi Abhishek,
> 
> On Wed, May 29, 2019 at 3:02 PM Abhishek Goel

...
 
> >                                 bitmask_setbit(cpus_chosen, cpus->cpu);
> >                                 cpus = cpus->next;
> >                         
> >                         }
> > 
> > +                       /* Set the last cpu in related cpus list */
> > +                       bitmask_setbit(cpus_chosen, cpus->cpu);
> 
> Perhaps you could convert the while() loop to a do ..  while(). That
> should will ensure
> that we terminate the loop after setting the last valid CPU.

It would do exactly the same, right?
IMHO it's not worth the extra hassle of resubmitting. Setting the last value 
outside a while loop is rather common.

I do not have a CPU with related cores at hand.
If you tested this it would be nice to see this pushed:

Reviewed-by: Thomas Renninger <trenn@suse.de>

Thanks!

   Thomas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cpupower : frequency-set -r option misses the last cpu in related cpu list
  2019-05-29 14:21   ` Thomas Renninger
@ 2019-06-04 15:16     ` shuah
  0 siblings, 0 replies; 4+ messages in thread
From: shuah @ 2019-06-04 15:16 UTC (permalink / raw)
  To: Thomas Renninger, ego; +Cc: Abhishek Goel, LKML, Linux PM list, shuah

On 5/29/19 8:21 AM, Thomas Renninger wrote:
> Hi,
> 
> On Wednesday, May 29, 2019 2:12:34 PM CEST Gautham R Shenoy wrote:
>> Hi Abhishek,
>>
>> On Wed, May 29, 2019 at 3:02 PM Abhishek Goel
> 
> ...
>   
>>>                                  bitmask_setbit(cpus_chosen, cpus->cpu);
>>>                                  cpus = cpus->next;
>>>                          
>>>                          }
>>>
>>> +                       /* Set the last cpu in related cpus list */
>>> +                       bitmask_setbit(cpus_chosen, cpus->cpu);
>>
>> Perhaps you could convert the while() loop to a do ..  while(). That
>> should will ensure
>> that we terminate the loop after setting the last valid CPU.
> 
> It would do exactly the same, right?
> IMHO it's not worth the extra hassle of resubmitting. Setting the last value
> outside a while loop is rather common.
> 
> I do not have a CPU with related cores at hand.
> If you tested this it would be nice to see this pushed:
> 
> Reviewed-by: Thomas Renninger <trenn@suse.de>
> 

Applied to 
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux.git/ 
cpupower branch.

thanks,
-- Shuah


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-04 15:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-29  9:30 [PATCH] cpupower : frequency-set -r option misses the last cpu in related cpu list Abhishek Goel
2019-05-29 12:12 ` Gautham R Shenoy
2019-05-29 14:21   ` Thomas Renninger
2019-06-04 15:16     ` shuah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).