linux-cpupower-5.11-rc1

This cpupower update for Linux 5.11-rc1 consists of a change to provide
 online and offline CPU information. This change makes it easier to keep
 track of offline cpus whose cpuidle or cpufreq property aren't changed
 when updates are made to online cpus.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEPZKym/RZuOCGeA/kCwJExA0NQxwFAl/FZOoACgkQCwJExA0N
 QxyxRxAAiXocAy6ZcDTtVzQuvRA48VwydjOi5/WqOzn6PO15aEIOebcMAkXFGTkj
 RkyZIZLgqvx8xZ+j0vocw2+jbXBw+BXhEsXOkUdD2oIe55AhRdaO2Ove83ff5MeF
 B1g1nt6QNT8/usNbQIkghAObRNi7h9QmTiIKjaYb9jvtW+hISxeIvC1STzfbJOJT
 YFm0RP3ZBQlUALZFweB0c5jxKnXtVzL+8riJgodzRGMIX/cAyClZEtiGvIkG8unc
 RV2p1djyCLhPLg0MDu5trhzDS3NiA2NMggFd5HtJYjwwUgYxyH2tBXMnI7BuukVu
 vNMr5U4wY74ldwPO6M8HzKhEYx1yWurWJKnMScow2bmd6UO9SFHaV7wPcCUKYSsi
 gRkGiCLaTmcN/Cz1rgAt8wqkT02HXkYoETrdAR959fVrDmyFaiej1abeLrLP2hm+
 SKbZpVDzmdnfglx//uGv+j7i1fJdei7w53JIfQ3PtGnRJe+AVjk/0UbCtSCsdLoJ
 LgWPwa6jS459TFWU9wGwQFvsehE6ryOOtXIxRmW33YeCAGNFvpyq1Nsorm6CKzw8
 GbClGrdIG8QMYJBTH6oxoLL1hIV07xw0LJj8VOHeTtM/wdOL430wyN++8mPe6hsv
 DWFeCqIZx6913y+kPQ78w03hiKqWf0D4HiFi0o7CD9CPswTO378=
 =yqNn
 -----END PGP SIGNATURE-----

Merge tag 'linux-cpupower-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux

Pull cpupower utility update for v5.11-rc1 from Shuah Khan:

"This consists of a change to provide online and offline CPU information.
 This change makes it easier to keep track of offline cpus whose cpuidle
 or cpufreq property aren't changed when updates are made to online cpus."

* tag 'linux-cpupower-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux:
  cpupower: Provide online and offline CPU information
This commit is contained in:
Rafael J. Wysocki 2020-12-01 17:26:49 +01:00
commit f8edfa6d1e
5 changed files with 92 additions and 1 deletions

View File

@ -315,6 +315,7 @@ int cmd_freq_set(int argc, char **argv)
} }
} }
get_cpustate();
/* loop over CPUs */ /* loop over CPUs */
for (cpu = bitmask_first(cpus_chosen); for (cpu = bitmask_first(cpus_chosen);
@ -332,5 +333,7 @@ int cmd_freq_set(int argc, char **argv)
} }
} }
print_offline_cpus();
return 0; return 0;
} }

View File

@ -95,6 +95,8 @@ int cmd_idle_set(int argc, char **argv)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
get_cpustate();
/* Default is: set all CPUs */ /* Default is: set all CPUs */
if (bitmask_isallclear(cpus_chosen)) if (bitmask_isallclear(cpus_chosen))
bitmask_setall(cpus_chosen); bitmask_setall(cpus_chosen);
@ -181,5 +183,7 @@ int cmd_idle_set(int argc, char **argv)
break; break;
} }
} }
print_offline_cpus();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -34,6 +34,8 @@ int run_as_root;
int base_cpu; int base_cpu;
/* Affected cpus chosen by -c/--cpu param */ /* Affected cpus chosen by -c/--cpu param */
struct bitmask *cpus_chosen; struct bitmask *cpus_chosen;
struct bitmask *online_cpus;
struct bitmask *offline_cpus;
#ifdef DEBUG #ifdef DEBUG
int be_verbose; int be_verbose;
@ -178,6 +180,8 @@ int main(int argc, const char *argv[])
char pathname[32]; char pathname[32];
cpus_chosen = bitmask_alloc(sysconf(_SC_NPROCESSORS_CONF)); cpus_chosen = bitmask_alloc(sysconf(_SC_NPROCESSORS_CONF));
online_cpus = bitmask_alloc(sysconf(_SC_NPROCESSORS_CONF));
offline_cpus = bitmask_alloc(sysconf(_SC_NPROCESSORS_CONF));
argc--; argc--;
argv += 1; argv += 1;
@ -230,6 +234,10 @@ int main(int argc, const char *argv[])
ret = p->main(argc, argv); ret = p->main(argc, argv);
if (cpus_chosen) if (cpus_chosen)
bitmask_free(cpus_chosen); bitmask_free(cpus_chosen);
if (online_cpus)
bitmask_free(online_cpus);
if (offline_cpus)
bitmask_free(offline_cpus);
return ret; return ret;
} }
print_help(); print_help();

View File

@ -94,6 +94,8 @@ struct cpupower_cpu_info {
*/ */
extern int get_cpu_info(struct cpupower_cpu_info *cpu_info); extern int get_cpu_info(struct cpupower_cpu_info *cpu_info);
extern struct cpupower_cpu_info cpupower_cpu_info; extern struct cpupower_cpu_info cpupower_cpu_info;
/* cpuid and cpuinfo helpers **************************/ /* cpuid and cpuinfo helpers **************************/
/* X86 ONLY ****************************************/ /* X86 ONLY ****************************************/
@ -171,4 +173,14 @@ static inline unsigned int cpuid_ecx(unsigned int op) { return 0; };
static inline unsigned int cpuid_edx(unsigned int op) { return 0; }; static inline unsigned int cpuid_edx(unsigned int op) { return 0; };
#endif /* defined(__i386__) || defined(__x86_64__) */ #endif /* defined(__i386__) || defined(__x86_64__) */
/*
* CPU State related functions
*/
extern struct bitmask *online_cpus;
extern struct bitmask *offline_cpus;
void get_cpustate(void);
void print_online_cpus(void);
void print_offline_cpus(void);
#endif /* __CPUPOWERUTILS_HELPERS__ */ #endif /* __CPUPOWERUTILS_HELPERS__ */

View File

@ -1,8 +1,12 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#if defined(__i386__) || defined(__x86_64__)
#include <stdio.h>
#include <stdlib.h>
#include "helpers/helpers.h" #include "helpers/helpers.h"
#if defined(__i386__) || defined(__x86_64__)
#define MSR_AMD_HWCR 0xc0010015 #define MSR_AMD_HWCR 0xc0010015
int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active, int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active,
@ -41,3 +45,63 @@ int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active,
return 0; return 0;
} }
#endif /* #if defined(__i386__) || defined(__x86_64__) */ #endif /* #if defined(__i386__) || defined(__x86_64__) */
/* get_cpustate
*
* Gather the information of all online CPUs into bitmask struct
*/
void get_cpustate(void)
{
unsigned int cpu = 0;
bitmask_clearall(online_cpus);
bitmask_clearall(offline_cpus);
for (cpu = bitmask_first(cpus_chosen);
cpu <= bitmask_last(cpus_chosen); cpu++) {
if (cpupower_is_cpu_online(cpu) == 1)
bitmask_setbit(online_cpus, cpu);
else
bitmask_setbit(offline_cpus, cpu);
continue;
}
}
/* print_online_cpus
*
* Print the CPU numbers of all CPUs that are online currently
*/
void print_online_cpus(void)
{
int str_len = 0;
char *online_cpus_str = NULL;
str_len = online_cpus->size * 5;
online_cpus_str = (void *)malloc(sizeof(char) * str_len);
if (!bitmask_isallclear(online_cpus)) {
bitmask_displaylist(online_cpus_str, str_len, online_cpus);
printf(_("Following CPUs are online:\n%s\n"), online_cpus_str);
}
}
/* print_offline_cpus
*
* Print the CPU numbers of all CPUs that are offline currently
*/
void print_offline_cpus(void)
{
int str_len = 0;
char *offline_cpus_str = NULL;
str_len = offline_cpus->size * 5;
offline_cpus_str = (void *)malloc(sizeof(char) * str_len);
if (!bitmask_isallclear(offline_cpus)) {
bitmask_displaylist(offline_cpus_str, str_len, offline_cpus);
printf(_("Following CPUs are offline:\n%s\n"), offline_cpus_str);
printf(_("cpupower set operation was not performed on them\n"));
}
}