diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2016-03-19 08:30:20 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2017-05-26 17:12:39 -0400 |
commit | 3ad97ff9c220de06e01f97c795fcee49f206595d (patch) | |
tree | c92678a28bf2842917a557e0c0c5d996667546ac | |
parent | 13113c878cbcfdedcf339a20d85c473011937dff (diff) |
hrtimer integration: properly trace late-added timers
When tasks add timers that have already expired (e.g., when preempted
during schedule_hrtimeout), we should not use the expriration time as
the reference time point, but rather the time when the timer was added
(the delay then includes activation of ksoftirqd, etc.).
-rw-r--r-- | include/linux/hrtimer.h | 2 | ||||
-rw-r--r-- | kernel/time/hrtimer.c | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 720063df0ac0..dcbbd65c8af1 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h | |||
@@ -109,7 +109,7 @@ struct hrtimer { | |||
109 | void *start_site; | 109 | void *start_site; |
110 | char start_comm[16]; | 110 | char start_comm[16]; |
111 | #endif | 111 | #endif |
112 | #ifdef CONFIG_REPORT_TIMER_LATENCY | 112 | #if defined(CONFIG_REPORT_TIMER_LATENCY) || defined(CONFIG_SCHED_OVERHEAD_TRACE) |
113 | ktime_t when_added; | 113 | ktime_t when_added; |
114 | #endif | 114 | #endif |
115 | }; | 115 | }; |
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index b4824e1dbc6d..c367854ce1d6 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c | |||
@@ -1491,12 +1491,17 @@ static enum hrtimer_restart hrtimer_wakeup(struct hrtimer *timer) | |||
1491 | t->task = NULL; | 1491 | t->task = NULL; |
1492 | if (task) | 1492 | if (task) |
1493 | { | 1493 | { |
1494 | #ifdef CONFIG_SCHED_OVERHEAD_TRACE | ||
1494 | if (is_realtime(task)) | 1495 | if (is_realtime(task)) |
1495 | { | 1496 | { |
1496 | ktime_t expires = hrtimer_get_expires(timer); | 1497 | ktime_t expires = hrtimer_get_expires(timer); |
1497 | lt_t intended_release = ktime_to_ns(expires); | 1498 | /* Fix up timers that were added past their due date; |
1499 | * that's not really release latency. */ | ||
1500 | lt_t intended_release = max(expires.tv64, | ||
1501 | timer->when_added.tv64); | ||
1498 | TS_RELEASE_LATENCY(intended_release); | 1502 | TS_RELEASE_LATENCY(intended_release); |
1499 | } | 1503 | } |
1504 | #endif | ||
1500 | TS_RELEASE_START; | 1505 | TS_RELEASE_START; |
1501 | wake_up_process(task); | 1506 | wake_up_process(task); |
1502 | TS_RELEASE_END; | 1507 | TS_RELEASE_END; |