20 static struct option set_opts[] = {
21 { .name =
"perf-bias", .has_arg = optional_argument, .flag =
NULL, .val =
'b'},
22 { .name =
"sched-mc", .has_arg = optional_argument, .flag =
NULL, .val =
'm'},
23 { .name =
"sched-smt", .has_arg = optional_argument, .flag =
NULL, .val =
's'},
27 static void print_wrong_arg_exit(
void)
29 printf(
_(
"invalid or unknown argument\n"));
36 extern int optind, opterr, optopt;
47 int sched_mc = 0, sched_smt = 0, perf_bias = 0;
50 setlocale(LC_ALL,
"");
55 while ((ret = getopt_long(argc, argv,
"m:s:b:",
56 set_opts,
NULL)) != -1) {
60 print_wrong_arg_exit();
61 perf_bias = atoi(optarg);
62 if (perf_bias < 0 || perf_bias > 15) {
63 printf(
_(
"--perf-bias param out "
64 "of range [0-%d]\n"), 15);
65 print_wrong_arg_exit();
71 print_wrong_arg_exit();
72 sched_mc = atoi(optarg);
73 if (sched_mc < 0 || sched_mc > 2) {
74 printf(
_(
"--sched-mc param out "
75 "of range [0-%d]\n"), 2);
76 print_wrong_arg_exit();
82 print_wrong_arg_exit();
83 sched_smt = atoi(optarg);
84 if (sched_smt < 0 || sched_smt > 2) {
85 printf(
_(
"--sched-smt param out "
86 "of range [0-%d]\n"), 2);
87 print_wrong_arg_exit();
92 print_wrong_arg_exit();
97 print_wrong_arg_exit();
102 fprintf(stderr,
_(
"Error setting sched-mc %s\n"),
103 (ret == -
ENODEV) ?
"not supported" :
"");
108 fprintf(stderr,
_(
"Error setting sched-smt %s\n"),
109 (ret == -
ENODEV) ?
"not supported" :
"");
125 ret = msr_intel_set_perf_bias(cpu, perf_bias);
127 fprintf(stderr,
_(
"Error setting perf-bias "
128 "value on CPU %d\n"), cpu);