cpupower : frequency-set -r option misses the last cpu in related cpu list [Linux 4.9.187]

This Linux kernel change "cpupower : frequency-set -r option misses the last cpu in related cpu list" is included in the Linux 4.9.187 release. This change is authored by Abhishek Goel <huntbag [at] linux.vnet.ibm.com> on Wed May 29 04:30:33 2019 -0500. The commit for this change in Linux stable tree is 5e32f6d (patch) which is from upstream commit 04507c0. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 04507c0.

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

[ Upstream commit 04507c0a9385cc8280f794a36bfff567c8cc1042 ]

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 <[email protected]>
Reviewed-by: Thomas Renninger <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 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 1eef0ae..08a4055 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);
        }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *