Skip to contentSkip to conversation

cpupower : frequency-set -r option misses the last cpu in related cpu list

PATCH Applied Abhishek Goel 4 participants 4 messages May 29, 2019 – Jun 4, 2019 CPU power monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpupower : frequency-set -r option misses the last cpu in related cpu list

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.

---
 tools/power/cpupower/utils/cpufreq-set.c | 2 ++
 1 file changed, 2 insertions(+)
tools/power/cpupower/utils/cpufreq-set.c +2 -0
index 1eef0aed6..08a405593 100644
@@ -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);
 		}
 	}
Signature · 1 line
2.17.1
#1 lore raw

Hi Abhishek,

Quoted 20 lines · 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.

---
 tools/power/cpupower/utils/cpufreq-set.c | 2 ++
 1 file changed, 2 insertions(+)
tools/power/cpupower/utils/cpufreq-set.c +0 -0
index 1eef0aed6..08a405593 100644

tools/power/cpupower/utils/cpufreq-set.c int cmd_freq_set(int argc, char **argv) · line 310

Quoted 5 lines
tools/power/cpupower/utils/cpufreq-set.c +2 -0
@@ -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.

Quoted 6 lines
tools/power/cpupower/utils/cpufreq-set.c +0 -1
                        cpufreq_put_related_cpus(cpus);
                }
        }
--

2.17.1

Signature · 2 lines
Thanks and Regards
gautham.
Reviewed-by
#2 lore raw

Hi,

Quoted 3 lines · CEST Gautham R Shenoy

Hi Abhishek,

On Wed, May 29, 2019 at 3:02 PM Abhishek Goel

...

Quoted 11 lines

tools/power/cpupower/utils/cpufreq-set.c int cmd_freq_set(int argc, char **argv) · line 310

Quoted 7 lines
                                bitmask_setbit(cpus_chosen, cpus->cpu);
                                cpus = cpus->next;
                        
                        }
tools/power/cpupower/utils/cpufreq-set.c +2 -0
+                       /* 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:

Thanks!

Thomas

maintainer Applied
#3 lore raw
Quoted 21 lines · Thomas Renninger

Hi,

Quoted 3 lines · CEST Gautham R Shenoy

Hi Abhishek,

On Wed, May 29, 2019 at 3:02 PM Abhishek Goel

...

Quoted 11 lines

tools/power/cpupower/utils/cpufreq-set.c int cmd_freq_set(int argc, char **argv) · line 310

Quoted 7 lines
                                 bitmask_setbit(cpus_chosen, cpus->cpu);
                                 cpus = cpus->next;
                         
                         }
tools/power/cpupower/utils/cpufreq-set.c +2 -0
+                       /* 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.

Quoted 9 lines

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:

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

thanks,
-- Shuah