2 * (C) 2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
4 * Licensed under the terms of the GNU GPL License version 2.
16 #include "helpers/helpers.h"
17 #include "helpers/sysfs.h"
21 printf(_("Usage: cpupower info [ -b ] [ -m ] [ -s ]\n"));
22 printf(_("Options:\n"));
23 printf(_(" -b, --perf-bias Gets CPU's power vs performance policy on some\n"
24 " Intel models [0-15], see manpage for details\n"));
25 printf(_(" -m, --sched-mc Gets the kernel's multi core scheduler policy.\n"));
26 printf(_(" -s, --sched-smt Gets the kernel's thread sibling scheduler policy.\n"));
27 printf(_(" -h, --help Prints out this screen\n"));
28 printf(_("\nPassing no option will show all info, by default only on core 0\n"));
32 static struct option set_opts
[] = {
33 { .name
= "perf-bias", .has_arg
= optional_argument
, .flag
= NULL
, .val
= 'b'},
34 { .name
= "sched-mc", .has_arg
= optional_argument
, .flag
= NULL
, .val
= 'm'},
35 { .name
= "sched-smt", .has_arg
= optional_argument
, .flag
= NULL
, .val
= 's'},
36 { .name
= "help", .has_arg
= no_argument
, .flag
= NULL
, .val
= 'h'},
40 static void print_wrong_arg_exit(void)
42 printf(_("invalid or unknown argument\n"));
47 int cmd_info(int argc
, char **argv
)
50 extern int optind
, opterr
, optopt
;
63 setlocale(LC_ALL
, "");
66 /* parameter parsing */
67 while ((ret
= getopt_long(argc
, argv
, "msbh", set_opts
, NULL
)) != -1) {
74 print_wrong_arg_exit();
79 print_wrong_arg_exit();
84 print_wrong_arg_exit();
88 print_wrong_arg_exit();
95 /* Default is: show output of CPU 0 only */
96 if (bitmask_isallclear(cpus_chosen
))
97 bitmask_setbit(cpus_chosen
, 0);
99 if (params
.sched_mc
) {
100 ret
= sysfs_get_sched("mc");
101 printf(_("System's multi core scheduler setting: "));
103 /* if sysfs file is missing it's: errno == ENOENT */
104 printf(_("not supported\n"));
108 if (params
.sched_smt
) {
109 ret
= sysfs_get_sched("smt");
110 printf(_("System's thread sibling scheduler setting: "));
112 /* if sysfs file is missing it's: errno == ENOENT */
113 printf(_("not supported\n"));
118 /* Add more per cpu options here */
119 if (!params
.perf_bias
)
122 if (params
.perf_bias
) {
124 params
.perf_bias
= 0;
125 printf(_("Intel's performance bias setting needs root privileges\n"));
126 } else if (!(cpupower_cpu_info
.caps
& CPUPOWER_CAP_PERF_BIAS
)) {
127 printf(_("System does not support Intel's performance"
129 params
.perf_bias
= 0;
134 for (cpu
= bitmask_first(cpus_chosen
);
135 cpu
<= bitmask_last(cpus_chosen
); cpu
++) {
137 if (!bitmask_isbitset(cpus_chosen
, cpu
) ||
138 cpufreq_cpu_exists(cpu
))
141 printf(_("analyzing CPU %d:\n"), cpu
);
143 if (params
.perf_bias
) {
144 ret
= msr_intel_get_perf_bias(cpu
);
146 printf(_("Could not read perf-bias value\n"));
149 printf(_("perf-bias: %d\n"), ret
);