diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2016-03-18 13:07:39 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2016-03-20 14:30:30 -0400 |
commit | e9b22ab48acccba501490f05a367647fcb9902c2 (patch) | |
tree | 6f3ad6a2434730b1fc18a14db019ee53369b74f0 /kernel/time | |
parent | 8d35f992ca1e538bac1b5ff6a48297d369641671 (diff) |
Hook into hrtimer to report large latencies
Diffstat (limited to 'kernel/time')
-rw-r--r-- | kernel/time/hrtimer.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 2997ca85313c..70aebc72dfb8 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c | |||
@@ -965,6 +965,10 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, | |||
965 | #endif | 965 | #endif |
966 | } | 966 | } |
967 | 967 | ||
968 | #ifdef CONFIG_REPORT_TIMER_LATENCY | ||
969 | timer->when_added = base->get_time(); | ||
970 | #endif | ||
971 | |||
968 | hrtimer_set_expires_range_ns(timer, tim, delta_ns); | 972 | hrtimer_set_expires_range_ns(timer, tim, delta_ns); |
969 | 973 | ||
970 | /* Switch the timer base, if necessary: */ | 974 | /* Switch the timer base, if necessary: */ |
@@ -1252,6 +1256,9 @@ void hrtimer_interrupt(struct clock_event_device *dev) | |||
1252 | struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases); | 1256 | struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases); |
1253 | ktime_t expires_next, now, entry_time, delta; | 1257 | ktime_t expires_next, now, entry_time, delta; |
1254 | int i, retries = 0; | 1258 | int i, retries = 0; |
1259 | #ifdef CONFIG_REPORT_TIMER_LATENCY | ||
1260 | ktime_t was_exp_nxt; | ||
1261 | #endif | ||
1255 | 1262 | ||
1256 | BUG_ON(!cpu_base->hres_active); | 1263 | BUG_ON(!cpu_base->hres_active); |
1257 | cpu_base->nr_events++; | 1264 | cpu_base->nr_events++; |
@@ -1261,6 +1268,9 @@ void hrtimer_interrupt(struct clock_event_device *dev) | |||
1261 | entry_time = now = hrtimer_update_base(cpu_base); | 1268 | entry_time = now = hrtimer_update_base(cpu_base); |
1262 | retry: | 1269 | retry: |
1263 | cpu_base->in_hrtirq = 1; | 1270 | cpu_base->in_hrtirq = 1; |
1271 | #ifdef CONFIG_REPORT_TIMER_LATENCY | ||
1272 | was_exp_nxt = cpu_base->expires_next; | ||
1273 | #endif | ||
1264 | /* | 1274 | /* |
1265 | * We set expires_next to KTIME_MAX here with cpu_base->lock | 1275 | * We set expires_next to KTIME_MAX here with cpu_base->lock |
1266 | * held to prevent that a timer is enqueued in our queue via | 1276 | * held to prevent that a timer is enqueued in our queue via |
@@ -1301,6 +1311,30 @@ retry: | |||
1301 | if (basenow.tv64 < hrtimer_get_softexpires_tv64(timer)) | 1311 | if (basenow.tv64 < hrtimer_get_softexpires_tv64(timer)) |
1302 | break; | 1312 | break; |
1303 | 1313 | ||
1314 | #ifdef CONFIG_REPORT_TIMER_LATENCY | ||
1315 | if (cpu_base->hres_active && | ||
1316 | (basenow.tv64 >= | ||
1317 | hrtimer_get_expires_tv64(timer) + | ||
1318 | ((s64) CONFIG_REPORT_TIMER_LATENCY_THRESHOLD))) { | ||
1319 | printk_ratelimited(KERN_WARNING | ||
1320 | "WARNING: P%d timer latency:%lld now:%lld " | ||
1321 | "basenow:%lld exp:%lld soft-exp:%lld " | ||
1322 | "nxt:%lld added:%lld " | ||
1323 | "retries:%d " | ||
1324 | "timer:%p fn:%p" | ||
1325 | "\n", | ||
1326 | smp_processor_id(), | ||
1327 | basenow.tv64 - hrtimer_get_expires_tv64(timer), | ||
1328 | now.tv64, basenow.tv64, | ||
1329 | hrtimer_get_expires_tv64(timer), | ||
1330 | hrtimer_get_softexpires_tv64(timer), | ||
1331 | was_exp_nxt.tv64, | ||
1332 | timer->when_added.tv64, | ||
1333 | retries, | ||
1334 | timer, timer->function); | ||
1335 | } | ||
1336 | #endif | ||
1337 | |||
1304 | __run_hrtimer(timer, &basenow); | 1338 | __run_hrtimer(timer, &basenow); |
1305 | } | 1339 | } |
1306 | } | 1340 | } |