From bbef912ffe78f50d2df598939c0aee2bcfb663d9 Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Wed, 20 Jul 2016 17:37:41 +0200 Subject: LITMUS^RT core: hook into hrtimer_nanosleep() To intercept absolute-timed nanosleeps relative to CLOCK_MONOTONIC, which are likely related to periodic job arrivals. --- kernel/time/hrtimer.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'kernel/time') diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index a6d5b061ee67..0cc8ab474d4a 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1622,6 +1622,19 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp, if (dl_task(current) || rt_task(current) || is_realtime(current)) slack = 0; + if (is_realtime(current) + && clockid == CLOCK_MONOTONIC + && mode == HRTIMER_MODE_ABS) { + /* special handling: to handle periodic activations + * correctly despite timer interrupt jitter and overheads, + * the plugin might need to know the time at which the + * task intends to wake up + */ + tsk_rt(current)->doing_abs_nanosleep = 1; + tsk_rt(current)->nanosleep_wakeup = + ktime_to_ns(timespec_to_ktime(*rqtp)); + } + hrtimer_init_on_stack(&t.timer, clockid, mode); hrtimer_set_expires_range_ns(&t.timer, timespec_to_ktime(*rqtp), slack); if (do_nanosleep(&t, mode)) @@ -1648,6 +1661,9 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp, ret = -ERESTART_RESTARTBLOCK; out: destroy_hrtimer_on_stack(&t.timer); + + tsk_rt(current)->doing_abs_nanosleep = 0; + return ret; } -- cgit v1.2.2