2 * (C) 2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
4 * Licensed under the terms of the GNU GPL License version 2.
15 #include "helpers/helpers.h"
16 #include "helpers/sysfs.h"
17 #include "helpers/bitmask.h"
19 static struct option set_opts[] = {
20 {"perf-bias", required_argument, NULL, 'b'},
24 static void print_wrong_arg_exit(void)
26 printf(_("invalid or unknown argument\n"));
30 int cmd_set(int argc, char **argv)
33 extern int optind, opterr, optopt;
45 setlocale(LC_ALL, "");
49 /* parameter parsing */
50 while ((ret = getopt_long(argc, argv, "b:",
51 set_opts, NULL)) != -1) {
55 print_wrong_arg_exit();
56 perf_bias = atoi(optarg);
57 if (perf_bias < 0 || perf_bias > 15) {
58 printf(_("--perf-bias param out "
59 "of range [0-%d]\n"), 15);
60 print_wrong_arg_exit();
65 print_wrong_arg_exit();
70 print_wrong_arg_exit();
72 /* Default is: set all CPUs */
73 if (bitmask_isallclear(cpus_chosen))
74 bitmask_setall(cpus_chosen);
77 for (cpu = bitmask_first(cpus_chosen);
78 cpu <= bitmask_last(cpus_chosen); cpu++) {
80 if (!bitmask_isbitset(cpus_chosen, cpu))
83 if (sysfs_is_cpu_online(cpu) != 1){
84 fprintf(stderr, _("Cannot set values on CPU %d:"), cpu);
85 fprintf(stderr, _(" *is offline\n"));
89 if (params.perf_bias) {
90 ret = msr_intel_set_perf_bias(cpu, perf_bias);
92 fprintf(stderr, _("Error setting perf-bias "
93 "value on CPU %d\n"), cpu);