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"
19 static struct option set_opts
[] = {
20 { .name
= "perf-bias", .has_arg
= optional_argument
, .flag
= NULL
, .val
= 'b'},
21 { .name
= "sched-mc", .has_arg
= optional_argument
, .flag
= NULL
, .val
= 'm'},
22 { .name
= "sched-smt", .has_arg
= optional_argument
, .flag
= NULL
, .val
= 's'},
26 static void print_wrong_arg_exit(void)
28 printf(_("invalid or unknown argument\n"));
32 int cmd_info(int argc
, char **argv
)
35 extern int optind
, opterr
, optopt
;
48 setlocale(LC_ALL
, "");
51 /* parameter parsing */
52 while ((ret
= getopt_long(argc
, argv
, "msb", set_opts
, NULL
)) != -1) {
56 print_wrong_arg_exit();
61 print_wrong_arg_exit();
66 print_wrong_arg_exit();
70 print_wrong_arg_exit();
77 /* Default is: show output of CPU 0 only */
78 if (bitmask_isallclear(cpus_chosen
))
79 bitmask_setbit(cpus_chosen
, 0);
81 if (params
.sched_mc
) {
82 ret
= sysfs_get_sched("mc");
83 printf(_("System's multi core scheduler setting: "));
85 /* if sysfs file is missing it's: errno == ENOENT */
86 printf(_("not supported\n"));
90 if (params
.sched_smt
) {
91 ret
= sysfs_get_sched("smt");
92 printf(_("System's thread sibling scheduler setting: "));
94 /* if sysfs file is missing it's: errno == ENOENT */
95 printf(_("not supported\n"));
100 /* Add more per cpu options here */
101 if (!params
.perf_bias
)
104 if (params
.perf_bias
) {
106 params
.perf_bias
= 0;
107 printf(_("Intel's performance bias setting needs root privileges\n"));
108 } else if (!(cpupower_cpu_info
.caps
& CPUPOWER_CAP_PERF_BIAS
)) {
109 printf(_("System does not support Intel's performance"
111 params
.perf_bias
= 0;
116 for (cpu
= bitmask_first(cpus_chosen
);
117 cpu
<= bitmask_last(cpus_chosen
); cpu
++) {
119 if (!bitmask_isbitset(cpus_chosen
, cpu
) ||
120 cpufreq_cpu_exists(cpu
))
123 printf(_("analyzing CPU %d:\n"), cpu
);
125 if (params
.perf_bias
) {
126 ret
= msr_intel_get_perf_bias(cpu
);
128 printf(_("Could not read perf-bias value\n"));
131 printf(_("perf-bias: %d\n"), ret
);