• Steven Rostedt's avatar
    sched/rt: Kick RT bandwidth timer immediately on start up · c3a990dc
    Steven Rostedt authored
    I've been debugging why deadline tasks can cause the RT scheduler to
    throttle, even when the deadline tasks are only taking up 50% of the
    CPU and RT tasks are not even using 1% of the CPU. Here's what I found.
    
    In order to keep a CPU from being hogged by RT tasks, the deadline
    scheduler adds its run time (delta_exec) to the rt_time of the RT
    bandwidth. That way, if the two use more than 95% of the CPU within one
    second (default settings), the RT tasks are throttled to allow non RT
    tasks to run.
    
    Although the deadline tasks add their run time to the RT bandwidth, it
    lets the RT tasks do the accounting. This is where the problem lies. If
    a deadline task runs for a bit, and no RT tasks are running, then it
    will continually add to the RT rt_time that is used to calculate how
    much CPU the RT tasks use. But no RT period is in play, and this
    accumulation of the runtime never gets reset.
    
    When an RT task finally gets to run, and the watchdog goes off, it can
    see that the RT task has used more than it should of, because the
    deadline task added all this runtime to its rt_time. Then the RT task
    that just woke up gets throttled for no good reason.
    
    I also noticed that when an RT task is queued, it starts the timer to
    account for overload and such. But that timer goes off one period
    later, which may be too late and the extra rt_time will trigger a
    throttle.
    
    This is a quick work around to the problem. When a new RT task is
    queued, the bandwidth timer is set to go off immediately. Then the
    timer can clear out the extra time added to the rt_time while there was
    no RT task running. This stops my tests from triggering the throttle,
    and it will still throttle if an RT task runs too much, even while a
    deadline task is running.
    
    A better solution may be to subtract the bandwidth that the deadline
    task uses from the rt_runtime, and add it back when its finished. Then
    there wont be a need for runtime tracking of the time used by deadline
    tasks.
    
    I may play with that solution tomorrow.
    Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: <juri.lelli@gmail.com>
    Cc: <williams@redhat.com>
    Cc: Clark Williams
    Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Juri Lelli
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/20160216183746.349ec98b@gandalf.local.homeSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    c3a990dc
rt.c 53.6 KB