diff options
author | Deepthi Dharwar <deepthi@linux.vnet.ibm.com> | 2011-10-28 06:50:33 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2011-11-06 21:13:49 -0500 |
commit | 4202735e8ab6ecfb0381631a0d0b58fefe0bd4e2 (patch) | |
tree | 189e5aab466995128c5a9d5a2a4075a5db530674 /drivers/cpuidle | |
parent | b25edc42bfb9602f0503474b2c94701d5536ce60 (diff) |
cpuidle: Split cpuidle_state structure and move per-cpu statistics fields
This is the first step towards global registration of cpuidle
states. The statistics used primarily by the governor are per-cpu
and have to be split from rest of the fields inside cpuidle_state,
which would be made global i.e. single copy. The driver_data field
is also per-cpu and moved.
Signed-off-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Signed-off-by: Trinabh Gupta <g.trinabh@gmail.com>
Tested-by: Jean Pihet <j-pihet@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
Acked-by: Arjan van de Ven <arjan@linux.intel.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r-- | drivers/cpuidle/cpuidle.c | 11 | ||||
-rw-r--r-- | drivers/cpuidle/sysfs.c | 19 |
2 files changed, 19 insertions, 11 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index f66bcf9bfe93..7127e92fa8a1 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -105,9 +105,9 @@ int cpuidle_idle_call(void) | |||
105 | /* This can be moved to within driver enter routine | 105 | /* This can be moved to within driver enter routine |
106 | * but that results in multiple copies of same code. | 106 | * but that results in multiple copies of same code. |
107 | */ | 107 | */ |
108 | dev->states[entered_state].time += | 108 | dev->states_usage[entered_state].time += |
109 | (unsigned long long)dev->last_residency; | 109 | (unsigned long long)dev->last_residency; |
110 | dev->states[entered_state].usage++; | 110 | dev->states_usage[entered_state].usage++; |
111 | } | 111 | } |
112 | 112 | ||
113 | /* give the governor an opportunity to reflect on the outcome */ | 113 | /* give the governor an opportunity to reflect on the outcome */ |
@@ -186,8 +186,9 @@ static int poll_idle(struct cpuidle_device *dev, int index) | |||
186 | static void poll_idle_init(struct cpuidle_device *dev) | 186 | static void poll_idle_init(struct cpuidle_device *dev) |
187 | { | 187 | { |
188 | struct cpuidle_state *state = &dev->states[0]; | 188 | struct cpuidle_state *state = &dev->states[0]; |
189 | struct cpuidle_state_usage *state_usage = &dev->states_usage[0]; | ||
189 | 190 | ||
190 | cpuidle_set_statedata(state, NULL); | 191 | cpuidle_set_statedata(state_usage, NULL); |
191 | 192 | ||
192 | snprintf(state->name, CPUIDLE_NAME_LEN, "POLL"); | 193 | snprintf(state->name, CPUIDLE_NAME_LEN, "POLL"); |
193 | snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE"); | 194 | snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE"); |
@@ -235,8 +236,8 @@ int cpuidle_enable_device(struct cpuidle_device *dev) | |||
235 | goto fail_sysfs; | 236 | goto fail_sysfs; |
236 | 237 | ||
237 | for (i = 0; i < dev->state_count; i++) { | 238 | for (i = 0; i < dev->state_count; i++) { |
238 | dev->states[i].usage = 0; | 239 | dev->states_usage[i].usage = 0; |
239 | dev->states[i].time = 0; | 240 | dev->states_usage[i].time = 0; |
240 | } | 241 | } |
241 | dev->last_residency = 0; | 242 | dev->last_residency = 0; |
242 | 243 | ||
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index be7917ec40c9..8a1ace104476 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
@@ -216,7 +216,8 @@ static struct kobj_type ktype_cpuidle = { | |||
216 | 216 | ||
217 | struct cpuidle_state_attr { | 217 | struct cpuidle_state_attr { |
218 | struct attribute attr; | 218 | struct attribute attr; |
219 | ssize_t (*show)(struct cpuidle_state *, char *); | 219 | ssize_t (*show)(struct cpuidle_state *, \ |
220 | struct cpuidle_state_usage *, char *); | ||
220 | ssize_t (*store)(struct cpuidle_state *, const char *, size_t); | 221 | ssize_t (*store)(struct cpuidle_state *, const char *, size_t); |
221 | }; | 222 | }; |
222 | 223 | ||
@@ -224,19 +225,22 @@ struct cpuidle_state_attr { | |||
224 | static struct cpuidle_state_attr attr_##_name = __ATTR(_name, 0444, show, NULL) | 225 | static struct cpuidle_state_attr attr_##_name = __ATTR(_name, 0444, show, NULL) |
225 | 226 | ||
226 | #define define_show_state_function(_name) \ | 227 | #define define_show_state_function(_name) \ |
227 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | 228 | static ssize_t show_state_##_name(struct cpuidle_state *state, \ |
229 | struct cpuidle_state_usage *state_usage, char *buf) \ | ||
228 | { \ | 230 | { \ |
229 | return sprintf(buf, "%u\n", state->_name);\ | 231 | return sprintf(buf, "%u\n", state->_name);\ |
230 | } | 232 | } |
231 | 233 | ||
232 | #define define_show_state_ull_function(_name) \ | 234 | #define define_show_state_ull_function(_name) \ |
233 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | 235 | static ssize_t show_state_##_name(struct cpuidle_state *state, \ |
236 | struct cpuidle_state_usage *state_usage, char *buf) \ | ||
234 | { \ | 237 | { \ |
235 | return sprintf(buf, "%llu\n", state->_name);\ | 238 | return sprintf(buf, "%llu\n", state_usage->_name);\ |
236 | } | 239 | } |
237 | 240 | ||
238 | #define define_show_state_str_function(_name) \ | 241 | #define define_show_state_str_function(_name) \ |
239 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | 242 | static ssize_t show_state_##_name(struct cpuidle_state *state, \ |
243 | struct cpuidle_state_usage *state_usage, char *buf) \ | ||
240 | { \ | 244 | { \ |
241 | if (state->_name[0] == '\0')\ | 245 | if (state->_name[0] == '\0')\ |
242 | return sprintf(buf, "<null>\n");\ | 246 | return sprintf(buf, "<null>\n");\ |
@@ -269,16 +273,18 @@ static struct attribute *cpuidle_state_default_attrs[] = { | |||
269 | 273 | ||
270 | #define kobj_to_state_obj(k) container_of(k, struct cpuidle_state_kobj, kobj) | 274 | #define kobj_to_state_obj(k) container_of(k, struct cpuidle_state_kobj, kobj) |
271 | #define kobj_to_state(k) (kobj_to_state_obj(k)->state) | 275 | #define kobj_to_state(k) (kobj_to_state_obj(k)->state) |
276 | #define kobj_to_state_usage(k) (kobj_to_state_obj(k)->state_usage) | ||
272 | #define attr_to_stateattr(a) container_of(a, struct cpuidle_state_attr, attr) | 277 | #define attr_to_stateattr(a) container_of(a, struct cpuidle_state_attr, attr) |
273 | static ssize_t cpuidle_state_show(struct kobject * kobj, | 278 | static ssize_t cpuidle_state_show(struct kobject * kobj, |
274 | struct attribute * attr ,char * buf) | 279 | struct attribute * attr ,char * buf) |
275 | { | 280 | { |
276 | int ret = -EIO; | 281 | int ret = -EIO; |
277 | struct cpuidle_state *state = kobj_to_state(kobj); | 282 | struct cpuidle_state *state = kobj_to_state(kobj); |
283 | struct cpuidle_state_usage *state_usage = kobj_to_state_usage(kobj); | ||
278 | struct cpuidle_state_attr * cattr = attr_to_stateattr(attr); | 284 | struct cpuidle_state_attr * cattr = attr_to_stateattr(attr); |
279 | 285 | ||
280 | if (cattr->show) | 286 | if (cattr->show) |
281 | ret = cattr->show(state, buf); | 287 | ret = cattr->show(state, state_usage, buf); |
282 | 288 | ||
283 | return ret; | 289 | return ret; |
284 | } | 290 | } |
@@ -323,6 +329,7 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device) | |||
323 | if (!kobj) | 329 | if (!kobj) |
324 | goto error_state; | 330 | goto error_state; |
325 | kobj->state = &device->states[i]; | 331 | kobj->state = &device->states[i]; |
332 | kobj->state_usage = &device->states_usage[i]; | ||
326 | init_completion(&kobj->kobj_unregister); | 333 | init_completion(&kobj->kobj_unregister); |
327 | 334 | ||
328 | ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj, | 335 | ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj, |