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"
18 #include "helpers/bitmask.h"
20 static struct option set_opts
[] = {
21 {"perf-bias", required_argument
, NULL
, 'b'},
25 static void print_wrong_arg_exit(void)
27 printf(_("invalid or unknown argument\n"));
31 int cmd_set(int argc
, char **argv
)
34 extern int optind
, opterr
, optopt
;
46 setlocale(LC_ALL
, "");
50 /* parameter parsing */
51 while ((ret
= getopt_long(argc
, argv
, "b:",
52 set_opts
, NULL
)) != -1) {
56 print_wrong_arg_exit();
57 perf_bias
= atoi(optarg
);
58 if (perf_bias
< 0 || perf_bias
> 15) {
59 printf(_("--perf-bias param out "
60 "of range [0-%d]\n"), 15);
61 print_wrong_arg_exit();
66 print_wrong_arg_exit();
71 print_wrong_arg_exit();
73 /* Default is: set all CPUs */
74 if (bitmask_isallclear(cpus_chosen
))
75 bitmask_setall(cpus_chosen
);
78 for (cpu
= bitmask_first(cpus_chosen
);
79 cpu
<= bitmask_last(cpus_chosen
); cpu
++) {
81 if (!bitmask_isbitset(cpus_chosen
, cpu
) ||
82 cpufreq_cpu_exists(cpu
))
85 if (params
.perf_bias
) {
86 ret
= msr_intel_set_perf_bias(cpu
, perf_bias
);
88 fprintf(stderr
, _("Error setting perf-bias "
89 "value on CPU %d\n"), cpu
);