• Frederic Weisbecker's avatar
    sched/fair: Correctly handle nohz ticks CPU load accounting · 1f41906a
    Frederic Weisbecker authored
    Ticks can happen while the CPU is in dynticks-idle or dynticks-singletask
    mode. In fact "nohz" or "dynticks" only mean that we exit the periodic
    mode and we try to minimize the ticks as much as possible. The nohz
    subsystem uses a confusing terminology with the internal state
    "ts->tick_stopped" which is also available through its public interface
    with tick_nohz_tick_stopped(). This is a misnomer as the tick is instead
    reduced with the best effort rather than stopped. In the best case the
    tick can indeed be actually stopped but there is no guarantee about that.
    If a timer needs to fire one second later, a tick will fire while the
    CPU is in nohz mode and this is a very common scenario.
    
    Now this confusion happens to be a problem with CPU load updates:
    cpu_load_update_active() doesn't handle nohz ticks correctly because it
    assumes that ticks are completely stopped in nohz mode and that
    cpu_load_update_active() can't be called in dynticks mode. When that
    happens, the whole previous tickless load is ignored and the function
    just records the load for the current tick, ignoring potentially long
    idle periods behind.
    
    In order to solve this, we could account the current load for the
    previous nohz time but there is a risk that we account the load of a
    task that got freshly enqueued for the whole nohz period.
    
    So instead, lets record the dynticks load on nohz frame entry so we know
    what to record in case of nohz ticks, then use this record to account
    the tickless load on nohz ticks and nohz frame end.
    Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Byungchul Park <byungchul.park@lge.com>
    Cc: Chris Metcalf <cmetcalf@ezchip.com>
    Cc: Christoph Lameter <cl@linux.com>
    Cc: Luiz Capitulino <lcapitulino@redhat.com>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Paul E . McKenney <paulmck@linux.vnet.ibm.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Rik van Riel <riel@redhat.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/1460555812-25375-3-git-send-email-fweisbec@gmail.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    1f41906a
fair.c 227 KB