diff options
author | Thomas Renninger <trenn@suse.de> | 2014-05-13 06:41:41 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-05-16 18:36:36 -0400 |
commit | 69cd502dd8432dcca24026efdd04192ec0e0c54e (patch) | |
tree | 1d7bbfed45f398e158a8848a807136c0a81c1702 /tools | |
parent | 706f4c1100e7131f2e8aa9552daba52fbf6b97cb (diff) |
cpupower: Introduce idle state disable-by-latency and enable-all
Signed-off-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/power/cpupower/man/cpupower-idle-set.1 | 10 | ||||
-rw-r--r-- | tools/power/cpupower/utils/cpuidle-set.c | 75 |
2 files changed, 77 insertions, 8 deletions
diff --git a/tools/power/cpupower/man/cpupower-idle-set.1 b/tools/power/cpupower/man/cpupower-idle-set.1 index 6b1607272a5b..3e6799d7a79f 100644 --- a/tools/power/cpupower/man/cpupower-idle-set.1 +++ b/tools/power/cpupower/man/cpupower-idle-set.1 | |||
@@ -13,11 +13,17 @@ sleep states. This can be handy for power vs performance tuning. | |||
13 | .SH "OPTIONS" | 13 | .SH "OPTIONS" |
14 | .LP | 14 | .LP |
15 | .TP | 15 | .TP |
16 | \fB\-d\fR \fB\-\-disable\fR | 16 | \fB\-d\fR \fB\-\-disable\fR <STATE_NO> |
17 | Disable a specific processor sleep state. | 17 | Disable a specific processor sleep state. |
18 | .TP | 18 | .TP |
19 | \fB\-e\fR \fB\-\-enable\fR | 19 | \fB\-e\fR \fB\-\-enable\fR <STATE_NO> |
20 | Enable a specific processor sleep state. | 20 | Enable a specific processor sleep state. |
21 | .TP | ||
22 | \fB\-D\fR \fB\-\-disable-by-latency\fR <LATENCY> | ||
23 | Disable all idle states with a equal or higher latency than <LATENCY> | ||
24 | .TP | ||
25 | \fB\-E\fR \fB\-\-enable-all\fR | ||
26 | Enable all idle states if not enabled already. | ||
21 | 27 | ||
22 | .SH "REMARKS" | 28 | .SH "REMARKS" |
23 | .LP | 29 | .LP |
diff --git a/tools/power/cpupower/utils/cpuidle-set.c b/tools/power/cpupower/utils/cpuidle-set.c index c78141c5dfac..d45d8d775c02 100644 --- a/tools/power/cpupower/utils/cpuidle-set.c +++ b/tools/power/cpupower/utils/cpuidle-set.c | |||
@@ -13,8 +13,14 @@ | |||
13 | #include "helpers/sysfs.h" | 13 | #include "helpers/sysfs.h" |
14 | 14 | ||
15 | static struct option info_opts[] = { | 15 | static struct option info_opts[] = { |
16 | { .name = "disable", .has_arg = required_argument, .flag = NULL, .val = 'd'}, | 16 | { .name = "disable", |
17 | { .name = "enable", .has_arg = required_argument, .flag = NULL, .val = 'e'}, | 17 | .has_arg = required_argument, .flag = NULL, .val = 'd'}, |
18 | { .name = "enable", | ||
19 | .has_arg = required_argument, .flag = NULL, .val = 'e'}, | ||
20 | { .name = "disable-by-latency", | ||
21 | .has_arg = required_argument, .flag = NULL, .val = 'D'}, | ||
22 | { .name = "enable-all", | ||
23 | .has_arg = no_argument, .flag = NULL, .val = 'E'}, | ||
18 | { }, | 24 | { }, |
19 | }; | 25 | }; |
20 | 26 | ||
@@ -23,11 +29,13 @@ int cmd_idle_set(int argc, char **argv) | |||
23 | { | 29 | { |
24 | extern char *optarg; | 30 | extern char *optarg; |
25 | extern int optind, opterr, optopt; | 31 | extern int optind, opterr, optopt; |
26 | int ret = 0, cont = 1, param = 0, idlestate = 0; | 32 | int ret = 0, cont = 1, param = 0, disabled; |
27 | unsigned int cpu = 0; | 33 | unsigned long long latency = 0, state_latency; |
34 | unsigned int cpu = 0, idlestate = 0, idlestates = 0; | ||
35 | char *endptr; | ||
28 | 36 | ||
29 | do { | 37 | do { |
30 | ret = getopt_long(argc, argv, "d:e:", info_opts, NULL); | 38 | ret = getopt_long(argc, argv, "d:e:ED:", info_opts, NULL); |
31 | if (ret == -1) | 39 | if (ret == -1) |
32 | break; | 40 | break; |
33 | switch (ret) { | 41 | switch (ret) { |
@@ -53,6 +61,27 @@ int cmd_idle_set(int argc, char **argv) | |||
53 | param = ret; | 61 | param = ret; |
54 | idlestate = atoi(optarg); | 62 | idlestate = atoi(optarg); |
55 | break; | 63 | break; |
64 | case 'D': | ||
65 | if (param) { | ||
66 | param = -1; | ||
67 | cont = 0; | ||
68 | break; | ||
69 | } | ||
70 | param = ret; | ||
71 | latency = strtoull(optarg, &endptr, 10); | ||
72 | if (*endptr != '\0') { | ||
73 | printf(_("Bad latency value: %s\n"), optarg); | ||
74 | exit(EXIT_FAILURE); | ||
75 | } | ||
76 | break; | ||
77 | case 'E': | ||
78 | if (param) { | ||
79 | param = -1; | ||
80 | cont = 0; | ||
81 | break; | ||
82 | } | ||
83 | param = ret; | ||
84 | break; | ||
56 | case -1: | 85 | case -1: |
57 | cont = 0; | 86 | cont = 0; |
58 | break; | 87 | break; |
@@ -79,8 +108,14 @@ int cmd_idle_set(int argc, char **argv) | |||
79 | if (!bitmask_isbitset(cpus_chosen, cpu)) | 108 | if (!bitmask_isbitset(cpus_chosen, cpu)) |
80 | continue; | 109 | continue; |
81 | 110 | ||
82 | switch (param) { | 111 | if (sysfs_is_cpu_online(cpu) != 1) |
112 | continue; | ||
113 | |||
114 | idlestates = sysfs_get_idlestate_count(cpu); | ||
115 | if (idlestates <= 0) | ||
116 | continue; | ||
83 | 117 | ||
118 | switch (param) { | ||
84 | case 'd': | 119 | case 'd': |
85 | ret = sysfs_idlestate_disable(cpu, idlestate, 1); | 120 | ret = sysfs_idlestate_disable(cpu, idlestate, 1); |
86 | if (ret == 0) | 121 | if (ret == 0) |
@@ -107,6 +142,34 @@ int cmd_idle_set(int argc, char **argv) | |||
107 | printf(_("Idlestate %u not enabled on CPU %u\n"), | 142 | printf(_("Idlestate %u not enabled on CPU %u\n"), |
108 | idlestate, cpu); | 143 | idlestate, cpu); |
109 | break; | 144 | break; |
145 | case 'D': | ||
146 | for (idlestate = 0; idlestate < idlestates; idlestate++) { | ||
147 | disabled = sysfs_is_idlestate_disabled | ||
148 | (cpu, idlestate); | ||
149 | state_latency = sysfs_get_idlestate_latency | ||
150 | (cpu, idlestate); | ||
151 | printf("CPU: %u - idlestate %u - state_latency: %llu - latency: %llu\n", | ||
152 | cpu, idlestate, state_latency, latency); | ||
153 | if (disabled == 1 || latency > state_latency) | ||
154 | continue; | ||
155 | ret = sysfs_idlestate_disable | ||
156 | (cpu, idlestate, 1); | ||
157 | if (ret == 0) | ||
158 | printf(_("Idlestate %u disabled on CPU %u\n"), idlestate, cpu); | ||
159 | } | ||
160 | break; | ||
161 | case 'E': | ||
162 | for (idlestate = 0; idlestate < idlestates; idlestate++) { | ||
163 | disabled = sysfs_is_idlestate_disabled | ||
164 | (cpu, idlestate); | ||
165 | if (disabled == 1) { | ||
166 | ret = sysfs_idlestate_disable | ||
167 | (cpu, idlestate, 0); | ||
168 | if (ret == 0) | ||
169 | printf(_("Idlestate %u enabled on CPU %u\n"), idlestate, cpu); | ||
170 | } | ||
171 | } | ||
172 | break; | ||
110 | default: | 173 | default: |
111 | /* Not reachable with proper args checking */ | 174 | /* Not reachable with proper args checking */ |
112 | printf(_("Invalid or unknown argument\n")); | 175 | printf(_("Invalid or unknown argument\n")); |