diff options
author | Yi Yang <yi.y.yang@intel.com> | 2008-02-24 19:46:12 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-03-26 00:45:26 -0400 |
commit | 8b78cf602fd3bd97c0080edd22fe8fd5d0fa7832 (patch) | |
tree | e5f8d7f74c0c1dbd03af793e0b7cb8fb1c06ccdf | |
parent | 996520c1fdd2948addb629be56c9febf2967e02b (diff) |
cpuidle: fix cpuidle time and usage overflow
cpuidle C-state sysfs node time and usage are very easy to overflow because
they are all of unsigned int type, time will overflow within about two hours,
usage will take longer time to overflow, but they are increasing for ever.
This patch will convert them to unsigned long long.
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Acked-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r-- | drivers/cpuidle/cpuidle.c | 2 | ||||
-rw-r--r-- | drivers/cpuidle/sysfs.c | 10 | ||||
-rw-r--r-- | include/linux/cpuidle.h | 4 |
3 files changed, 11 insertions, 5 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index d73663a52324..d42deb310ac7 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -67,7 +67,7 @@ static void cpuidle_idle_call(void) | |||
67 | /* enter the state and update stats */ | 67 | /* enter the state and update stats */ |
68 | dev->last_residency = target_state->enter(dev, target_state); | 68 | dev->last_residency = target_state->enter(dev, target_state); |
69 | dev->last_state = target_state; | 69 | dev->last_state = target_state; |
70 | target_state->time += dev->last_residency; | 70 | target_state->time += (unsigned long long)dev->last_residency; |
71 | target_state->usage++; | 71 | target_state->usage++; |
72 | 72 | ||
73 | /* give the governor an opportunity to reflect on the outcome */ | 73 | /* give the governor an opportunity to reflect on the outcome */ |
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 69102ca05685..e949618b9be0 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
@@ -218,6 +218,12 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | |||
218 | return sprintf(buf, "%u\n", state->_name);\ | 218 | return sprintf(buf, "%u\n", state->_name);\ |
219 | } | 219 | } |
220 | 220 | ||
221 | #define define_show_state_ull_function(_name) \ | ||
222 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | ||
223 | { \ | ||
224 | return sprintf(buf, "%llu\n", state->_name);\ | ||
225 | } | ||
226 | |||
221 | #define define_show_state_str_function(_name) \ | 227 | #define define_show_state_str_function(_name) \ |
222 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | 228 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ |
223 | { \ | 229 | { \ |
@@ -228,8 +234,8 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | |||
228 | 234 | ||
229 | define_show_state_function(exit_latency) | 235 | define_show_state_function(exit_latency) |
230 | define_show_state_function(power_usage) | 236 | define_show_state_function(power_usage) |
231 | define_show_state_function(usage) | 237 | define_show_state_ull_function(usage) |
232 | define_show_state_function(time) | 238 | define_show_state_ull_function(time) |
233 | define_show_state_str_function(name) | 239 | define_show_state_str_function(name) |
234 | define_show_state_str_function(desc) | 240 | define_show_state_str_function(desc) |
235 | 241 | ||
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 6b72a4584086..51e6b1e520e6 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h | |||
@@ -38,8 +38,8 @@ struct cpuidle_state { | |||
38 | unsigned int power_usage; /* in mW */ | 38 | unsigned int power_usage; /* in mW */ |
39 | unsigned int target_residency; /* in US */ | 39 | unsigned int target_residency; /* in US */ |
40 | 40 | ||
41 | unsigned int usage; | 41 | unsigned long long usage; |
42 | unsigned int time; /* in US */ | 42 | unsigned long long time; /* in US */ |
43 | 43 | ||
44 | int (*enter) (struct cpuidle_device *dev, | 44 | int (*enter) (struct cpuidle_device *dev, |
45 | struct cpuidle_state *state); | 45 | struct cpuidle_state *state); |