aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/time/tick-sched.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 59d8762c7e1d..f15d18d82c18 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -161,6 +161,7 @@ static void update_ts_time_stats(struct tick_sched *ts, ktime_t now)
161 if (ts->idle_active) { 161 if (ts->idle_active) {
162 delta = ktime_sub(now, ts->idle_entrytime); 162 delta = ktime_sub(now, ts->idle_entrytime);
163 ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta); 163 ts->idle_sleeptime = ktime_add(ts->idle_sleeptime, delta);
164 ts->idle_entrytime = now;
164 } 165 }
165} 166}
166 167
@@ -205,14 +206,18 @@ static ktime_t tick_nohz_start_idle(struct tick_sched *ts)
205u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time) 206u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time)
206{ 207{
207 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); 208 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
209 ktime_t now;
208 210
209 if (!tick_nohz_enabled) 211 if (!tick_nohz_enabled)
210 return -1; 212 return -1;
211 213
214 now = ktime_get();
215 update_ts_time_stats(ts, now);
216
212 if (ts->idle_active) 217 if (ts->idle_active)
213 *last_update_time = ktime_to_us(ts->idle_lastupdate); 218 *last_update_time = ktime_to_us(ts->idle_lastupdate);
214 else 219 else
215 *last_update_time = ktime_to_us(ktime_get()); 220 *last_update_time = ktime_to_us(now);
216 221
217 return ktime_to_us(ts->idle_sleeptime); 222 return ktime_to_us(ts->idle_sleeptime);
218} 223}