From 3ad97ff9c220de06e01f97c795fcee49f206595d Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Sat, 19 Mar 2016 13:30:20 +0100 Subject: 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.). --- include/linux/hrtimer.h | 2 +- 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 { void *start_site; char start_comm[16]; #endif -#ifdef CONFIG_REPORT_TIMER_LATENCY +#if defined(CONFIG_REPORT_TIMER_LATENCY) || defined(CONFIG_SCHED_OVERHEAD_TRACE) ktime_t when_added; #endif }; 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) t->task = NULL; if (task) { +#ifdef CONFIG_SCHED_OVERHEAD_TRACE if (is_realtime(task)) { ktime_t expires = hrtimer_get_expires(timer); - lt_t intended_release = ktime_to_ns(expires); + /* Fix up timers that were added past their due date; + * that's not really release latency. */ + lt_t intended_release = max(expires.tv64, + timer->when_added.tv64); TS_RELEASE_LATENCY(intended_release); } +#endif TS_RELEASE_START; wake_up_process(task); TS_RELEASE_END; -- cgit v1.2.2