diff options
Diffstat (limited to 'kernel/time/tick-sched.c')
-rw-r--r-- | kernel/time/tick-sched.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index f15d18d82c18..e86e1c6674d1 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c | |||
@@ -153,7 +153,8 @@ static void tick_nohz_update_jiffies(ktime_t now) | |||
153 | /* | 153 | /* |
154 | * Updates the per cpu time idle statistics counters | 154 | * Updates the per cpu time idle statistics counters |
155 | */ | 155 | */ |
156 | static void update_ts_time_stats(struct tick_sched *ts, ktime_t now) | 156 | static void |
157 | update_ts_time_stats(struct tick_sched *ts, ktime_t now, u64 *last_update_time) | ||
157 | { | 158 | { |
158 | ktime_t delta; | 159 | ktime_t delta; |
159 | 160 | ||
@@ -163,13 +164,19 @@ static void update_ts_time_stats(struct tick_sched *ts, ktime_t now) | |||
163 | ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta); | 164 | ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta); |
164 | ts->idle_entrytime = now; | 165 | ts->idle_entrytime = now; |
165 | } | 166 | } |
167 | |||
168 | if (ts->idle_active && last_update_time) | ||
169 | *last_update_time = ktime_to_us(ts->idle_lastupdate); | ||
170 | else | ||
171 | *last_update_time = ktime_to_us(now); | ||
172 | |||
166 | } | 173 | } |
167 | 174 | ||
168 | static void tick_nohz_stop_idle(int cpu, ktime_t now) | 175 | static void tick_nohz_stop_idle(int cpu, ktime_t now) |
169 | { | 176 | { |
170 | struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); | 177 | struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); |
171 | 178 | ||
172 | update_ts_time_stats(ts, now); | 179 | update_ts_time_stats(ts, now, NULL); |
173 | ts->idle_active = 0; | 180 | ts->idle_active = 0; |
174 | 181 | ||
175 | sched_clock_idle_wakeup_event(0); | 182 | sched_clock_idle_wakeup_event(0); |
@@ -181,7 +188,7 @@ static ktime_t tick_nohz_start_idle(struct tick_sched *ts) | |||
181 | 188 | ||
182 | now = ktime_get(); | 189 | now = ktime_get(); |
183 | 190 | ||
184 | update_ts_time_stats(ts, now); | 191 | update_ts_time_stats(ts, now, NULL); |
185 | 192 | ||
186 | ts->idle_entrytime = now; | 193 | ts->idle_entrytime = now; |
187 | ts->idle_active = 1; | 194 | ts->idle_active = 1; |
@@ -206,18 +213,11 @@ static ktime_t tick_nohz_start_idle(struct tick_sched *ts) | |||
206 | u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time) | 213 | u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time) |
207 | { | 214 | { |
208 | struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); | 215 | struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); |
209 | ktime_t now; | ||
210 | 216 | ||
211 | if (!tick_nohz_enabled) | 217 | if (!tick_nohz_enabled) |
212 | return -1; | 218 | return -1; |
213 | 219 | ||
214 | now = ktime_get(); | 220 | update_ts_time_stats(ts, ktime_get(), last_update_time); |
215 | update_ts_time_stats(ts, now); | ||
216 | |||
217 | if (ts->idle_active) | ||
218 | *last_update_time = ktime_to_us(ts->idle_lastupdate); | ||
219 | else | ||
220 | *last_update_time = ktime_to_us(now); | ||
221 | 221 | ||
222 | return ktime_to_us(ts->idle_sleeptime); | 222 | return ktime_to_us(ts->idle_sleeptime); |
223 | } | 223 | } |