OSDN Git Service

hrtimer: Determine hard/soft expiry mode for hrtimer sleepers on RT
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Fri, 26 Jul 2019 18:30:58 +0000 (20:30 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 1 Aug 2019 18:51:22 +0000 (20:51 +0200)
commit1842f5a427f5323f5c19ab99b55d09b3ab5172a5
tree273a4d23da40d208ed187f09ae9c9a0007b2b35e
parentf5c2f0215e36d76fbb9605283dd7535af09f5770
hrtimer: Determine hard/soft expiry mode for hrtimer sleepers on RT

On PREEMPT_RT enabled kernels hrtimers which are not explicitely marked for
hard interrupt expiry mode are moved into soft interrupt context either for
latency reasons or because the hrtimer callback takes regular spinlocks or
invokes other functions which are not suitable for hard interrupt context
on PREEMPT_RT.

The hrtimer_sleeper callback is RT compatible in hard interrupt context,
but there is a latency concern: Untrusted userspace can spawn many threads
which arm timers for the same expiry time on the same CPU. On expiry that
causes a latency spike due to the wakeup of a gazillion threads.

OTOH, priviledged real-time user space applications rely on the low latency
of hard interrupt wakeups. These syscall related wakeups are all based on
hrtimer sleepers.

If the current task is in a real-time scheduling class, mark the mode for
hard interrupt expiry.

[ tglx: Split out of a larger combo patch. Added changelog ]

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20190726185753.645792403@linutronix.de
kernel/time/hrtimer.c