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;
64 setlocale(LC_ALL, "");
67 /* parameter parsing */
68 while ((ret = getopt_long(argc, argv, "msbh", set_opts, NULL)) != -1) {
75 print_wrong_arg_exit();
80 print_wrong_arg_exit();
85 print_wrong_arg_exit();
89 print_wrong_arg_exit();
96 /* Default is: show output of CPU 0 only */
97 if (bitmask_isallclear(cpus_chosen))
98 bitmask_setbit(cpus_chosen, 0);
100 if (params.sched_mc) {
101 ret = sysfs_get_sched("mc");
102 printf(_("System's multi core scheduler setting: "));
104 /* if sysfs file is missing it's: errno == ENOENT */
105 printf(_("not supported\n"));
109 if (params.sched_smt) {
110 ret = sysfs_get_sched("smt");
111 printf(_("System's thread sibling scheduler setting: "));
113 /* if sysfs file is missing it's: errno == ENOENT */
114 printf(_("not supported\n"));
119 /* Add more per cpu options here */
120 if (!params.perf_bias)
123 if (params.perf_bias) {
125 params.perf_bias = 0;
126 printf (_("Intel's performance bias setting needs root privileges\n"));
127 } else if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_PERF_BIAS)) {
128 printf(_("System does not support Intel's performance"
130 params.perf_bias = 0;
135 for (cpu = bitmask_first(cpus_chosen);
136 cpu <= bitmask_last(cpus_chosen); cpu++) {
138 if (!bitmask_isbitset(cpus_chosen, cpu) ||
139 cpufreq_cpu_exists(cpu))
142 printf(_("analyzing CPU %d:\n"), cpu);
144 if (params.perf_bias) {
145 ret = msr_intel_get_perf_bias(cpu);
147 printf(_("Could not read perf-bias value\n"));
150 printf(_("perf-bias: %d\n"), ret);