• Frederic Weisbecker's avatar
    rcu/nocb: (De-)offload callbacks on offline CPUs only · 4e26ce42
    Frederic Weisbecker authored
    Currently callbacks can be (de-)offloaded only on online CPUs. This
    involves an overly elaborated state machine in order to make sure that
    callbacks are always handled during the process while ensuring
    synchronization between rcu_core and NOCB kthreads.
    
    The only potential user of NOCB (de-)offloading appears to be a
    nohz_full toggling interface through cpusets. And the general agreement
    is now to work toward toggling the nohz_full state on offline CPUs to
    simplify the whole picture.
    
    Therefore, convert the (de-)offloading to only support offline CPUs.
    This involves the following changes:
    
    * Call rcu_barrier() before deoffloading. An offline offloaded CPU may
      still carry callbacks in its queue ignored by
      rcutree_migrate_callbacks(). Those callbacks must all be flushed
      before switching to a regular queue because no more kthreads will
      handle those before the CPU ever gets re-onlined.
    
      This means that further calls to rcu_barrier() will find an empty
      queue until the CPU goes through rcutree_report_cpu_starting(). As a
      result it is guaranteed that further rcu_barrier() won't try to lock
      the nocb_lock for that target and thus won't risk an imbalance.
    
      Therefore barrier_mutex doesn't need to be locked anymore upon
      deoffloading.
    
    * Assume the queue is empty before offloading, as
      rcutree_migrate_callbacks() took care of everything.
    
      This means that further calls to rcu_barrier() will find an empty
      queue until the CPU goes through rcutree_report_cpu_starting(). As a
      result it is guaranteed that further rcu_barrier() won't risk a
      nocb_lock imbalance.
    
      Therefore barrier_mutex doesn't need to be locked anymore upon
      offloading.
    
    * No need to flush bypass anymore.
    
    Further simplifications will follow in upcoming patches.
    Signed-off-by: default avatarFrederic Weisbecker <frederic@kernel.org>
    Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    Reviewed-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    Signed-off-by: default avatarNeeraj Upadhyay <neeraj.upadhyay@kernel.org>
    4e26ce42
tree_nocb.h 50.9 KB