1 // SPDX-License-Identifier: GPL-2.0-only
3 * (C) 2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
14 #include "helpers/helpers.h"
15 #include "helpers/sysfs.h"
16 #include "helpers/bitmask.h"
18 static struct option set_opts[] = {
19 {"perf-bias", required_argument, NULL, 'b'},
23 static void print_wrong_arg_exit(void)
25 printf(_("invalid or unknown argument\n"));
29 int cmd_set(int argc, char **argv)
32 extern int optind, opterr, optopt;
44 setlocale(LC_ALL, "");
48 /* parameter parsing */
49 while ((ret = getopt_long(argc, argv, "b:",
50 set_opts, NULL)) != -1) {
54 print_wrong_arg_exit();
55 perf_bias = atoi(optarg);
56 if (perf_bias < 0 || perf_bias > 15) {
57 printf(_("--perf-bias param out "
58 "of range [0-%d]\n"), 15);
59 print_wrong_arg_exit();
64 print_wrong_arg_exit();
69 print_wrong_arg_exit();
71 /* Default is: set all CPUs */
72 if (bitmask_isallclear(cpus_chosen))
73 bitmask_setall(cpus_chosen);
76 for (cpu = bitmask_first(cpus_chosen);
77 cpu <= bitmask_last(cpus_chosen); cpu++) {
79 if (!bitmask_isbitset(cpus_chosen, cpu))
82 if (sysfs_is_cpu_online(cpu) != 1){
83 fprintf(stderr, _("Cannot set values on CPU %d:"), cpu);
84 fprintf(stderr, _(" *is offline\n"));
88 if (params.perf_bias) {
89 ret = msr_intel_set_perf_bias(cpu, perf_bias);
91 fprintf(stderr, _("Error setting perf-bias "
92 "value on CPU %d\n"), cpu);