25 Jul, 2017

1 commit

  • Other than lockdep support, Tiny RCU has no need for the
    scheduler status. However, Tiny SRCU will need this to control
    boot-time behavior independent of lockdep. Therefore, this commit
    moves rcu_scheduler_starting() from kernel/rcu/tiny_plugin.h to
    kernel/rcu/srcutiny.c. This in turn allows the complete removal of
    kernel/rcu/tiny_plugin.h.

    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     

09 Jun, 2017

7 commits

  • This commit removes a #ifdef and saves a few lines of code by moving
    the rcu_end_inkernel_boot() function from include/linux/rcupdate.h to
    include/linux/rcutiny.h (for TINY_RCU) and to include/linux/rcutree.h
    (for TREE_RCU).

    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     
  • The list of #includes from include/linux/rcupdate.h has grown quite
    a bit, so it is time to trim it. This commit moves the #include
    of include/linux/ktime.h to include/linux/rcutiny.h, along with the
    Tiny-RCU-only function that was the only thing needing ktimem.h. It then
    reconstructs the files included into include/linux/ktime.h based on what
    is actually needed, with significant help from the 0day Test Robot.

    This single change reduces the .i file footprint from rcupdate.h from
    9018 lines to 7101 lines.

    Reported-by: Ingo Molnar
    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     
  • This commit saves a few lines in include/linux/rcutiny.h by moving
    to single-line definitions for empty functions, instead of the old
    style where the two curly braces each get their own line.

    Reported-by: Ingo Molnar
    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     
  • The rcu_request_urgent_qs_task() function is used only within RCU,
    so there is no point in exporting it to the rest of the kernel from
    nclude/linux/rcutiny.h and include/linux/rcutree.h. This commit therefore
    moves this function to kernel/rcu/rcu.h.

    Reported-by: Ingo Molnar
    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     
  • The various functions similar to rcu_batches_started(), the
    function show_rcu_gp_kthreads(), the various functions similar to
    rcu_force_quiescent_state(), and the variables rcutorture_testseq and
    rcutorture_vernum are used only within RCU. There is therefore no point
    in exporting them to the kernel at large from include/linux/rcutiny.h
    and include/linux/rcutree.h. This commit therefore moves all of these
    to kernel/rcu/rcu.h.

    Reported-by: Ingo Molnar
    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     
  • The __rcu_is_watching() function is currently not used, aside from
    to implement the rcu_is_watching() function. This commit therefore
    eliminates __rcu_is_watching(), which has the beneficial side-effect
    of shrinking include/linux/rcupdate.h a bit.

    Reported-by: Ingo Molnar
    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     
  • The include/linux/rcupdate.h file contains a number of definitions that
    are used only to communicate between rcutorture, rcuperf, and the RCU code
    itself. There is no point in having these definitions exposed globally
    throughout the kernel, so this commit moves them to kernel/rcu/rcu.h.
    This change has the added benefit of shrinking rcupdate.h.

    Reported-by: Ingo Molnar
    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     

21 Apr, 2017

1 commit

  • Currently, a call to schedule() acts as a Tasks RCU quiescent state
    only if a context switch actually takes place. However, just the
    call to schedule() guarantees that the calling task has moved off of
    whatever tracing trampoline that it might have been one previously.
    This commit therefore plumbs schedule()'s "preempt" parameter into
    rcu_note_context_switch(), which then records the Tasks RCU quiescent
    state, but only if this call to schedule() was -not- due to a preemption.

    To avoid adding overhead to the common-case context-switch path,
    this commit hides the rcu_note_context_switch() check under an existing
    non-common-case check.

    Suggested-by: Steven Rostedt
    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     

19 Apr, 2017

2 commits

  • This is primarily a code-movement commit in preparation for allowing
    SRCU to handle early-boot SRCU grace periods.

    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     
  • Currently, IPIs are used to force other CPUs to invalidate their TLBs
    in response to a kernel virtual-memory mapping change. This works, but
    degrades both battery lifetime (for idle CPUs) and real-time response
    (for nohz_full CPUs), and in addition results in unnecessary IPIs due to
    the fact that CPUs executing in usermode are unaffected by stale kernel
    mappings. It would be better to cause a CPU executing in usermode to
    wait until it is entering kernel mode to do the flush, first to avoid
    interrupting usemode tasks and second to handle multiple flush requests
    with a single flush in the case of a long-running user task.

    This commit therefore reserves a bit at the bottom of the ->dynticks
    counter, which is checked upon exit from extended quiescent states.
    If it is set, it is cleared and then a new rcu_eqs_special_exit() macro is
    invoked, which, if not supplied, is an empty single-pass do-while loop.
    If this bottom bit is set on -entry- to an extended quiescent state,
    then a WARN_ON_ONCE() triggers.

    This bottom bit may be set using a new rcu_eqs_special_set() function,
    which returns true if the bit was set, or false if the CPU turned
    out to not be in an extended quiescent state. Please note that this
    function refuses to set the bit for a non-nohz_full CPU when that CPU
    is executing in usermode because usermode execution is tracked by RCU
    as a dyntick-idle extended quiescent state only for nohz_full CPUs.

    Reported-by: Andy Lutomirski
    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     

02 Mar, 2017

1 commit

  • So rcupdate.h is a pretty complex header, in particular it includes
    which includes - creating a
    dependency that includes in ,
    which prevents the isolation of from the derived
    header.

    Solve part of the problem by decoupling rcupdate.h from completions:
    this can be done by separating out the rcu_synchronize types and APIs,
    and updating their usage sites.

    Since this is a mostly RCU-internal types this will not just simplify
    's dependencies, but will make all the hundreds of
    .c files that include rcupdate.h but not completions or wait.h build
    faster.

    ( For rcutiny this means that two dependent APIs have to be uninlined,
    but that shouldn't be much of a problem as they are rare variants. )

    Acked-by: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

24 Jan, 2017

1 commit

  • This commit is the fourth step towards full abstraction of all accesses
    to the ->dynticks counter, implementing previously open-coded checks and
    comparisons in new rcu_dynticks_in_eqs() and rcu_dynticks_in_eqs_since()
    functions. This abstraction will ease changes to the ->dynticks counter
    operation.

    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     

15 Jul, 2016

1 commit

  • Straight forward conversion to the state machine. Though the question arises
    whether this needs really all these state transitions to work.

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Anna-Maria Gleixner
    Reviewed-by: Sebastian Andrzej Siewior
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: rt@linutronix.de
    Link: http://lkml.kernel.org/r/20160713153337.982013161@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     

01 Apr, 2016

1 commit

  • This commit provides rcu_exp_batches_completed() and
    rcu_exp_batches_completed_sched() functions to allow torture-test modules
    to check how many expedited grace period batches have completed.
    These are analogous to the existing rcu_batches_completed(),
    rcu_batches_completed_bh(), and rcu_batches_completed_sched() functions.

    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     

08 Dec, 2015

1 commit

  • This commit replaces a local_irq_save()/local_irq_restore() pair with
    a lockdep assertion that interrupts are already disabled. This should
    remove the corresponding overhead from the interrupt entry/exit fastpaths.

    This change was inspired by the fact that Iftekhar Ahmed's mutation
    testing showed that removing rcu_irq_enter()'s call to local_ird_restore()
    had no effect, which might indicate that interrupts were always enabled
    anyway.

    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     

07 Oct, 2015

2 commits

  • Because preempt_disable() maps to barrier() for non-debug builds,
    it forces the compiler to spill and reload registers. Because Tree
    RCU and Tiny RCU now only appear in CONFIG_PREEMPT=n builds, these
    barrier() instances generate needless extra code for each instance of
    rcu_read_lock() and rcu_read_unlock(). This extra code slows down Tree
    RCU and bloats Tiny RCU.

    This commit therefore removes the preempt_disable() and preempt_enable()
    from the non-preemptible implementations of __rcu_read_lock() and
    __rcu_read_unlock(), respectively. However, for debug purposes,
    preempt_disable() and preempt_enable() are still invoked if
    CONFIG_PREEMPT_COUNT=y, because this allows detection of sleeping inside
    atomic sections in non-preemptible kernels.

    However, Tiny and Tree RCU operates by coalescing all RCU read-side
    critical sections on a given CPU that lie between successive quiescent
    states. It is therefore necessary to compensate for removing barriers
    from __rcu_read_lock() and __rcu_read_unlock() by adding them to a
    couple of the RCU functions invoked during quiescent states, namely to
    rcu_all_qs() and rcu_note_context_switch(). However, note that the latter
    is more paranoia than necessity, at least until link-time optimizations
    become more aggressive.

    This is based on an earlier patch by Paul E. McKenney, fixing
    a bug encountered in kernels built with CONFIG_PREEMPT=n and
    CONFIG_PREEMPT_COUNT=y.

    Signed-off-by: Boqun Feng
    Signed-off-by: Paul E. McKenney

    Boqun Feng
     
  • As we now have rcu_callback_t typedefs as the type of rcu callbacks, we
    should use it in call_rcu*() and friends as the type of parameters. This
    could save us a few lines of code and make it clear which function
    requires an rcu callbacks rather than other callbacks as its argument.

    Besides, this can also help cscope to generate a better database for
    code reading.

    Signed-off-by: Boqun Feng
    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Boqun Feng
     

23 Jul, 2015

1 commit

  • The get_state_synchronize_rcu() and cond_synchronize_rcu() functions
    allow polling for grace-period completion, with an actual wait for a
    grace period occurring only when cond_synchronize_rcu() is called too
    soon after the corresponding get_state_synchronize_rcu(). However,
    these functions work only for vanilla RCU. This commit adds the
    get_state_synchronize_sched() and cond_synchronize_sched(), which provide
    the same capability for RCU-sched.

    Reported-by: Peter Zijlstra (Intel)
    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     

28 May, 2015

1 commit

  • The Tiny RCU counterparts to rcu_idle_enter(), rcu_idle_exit(),
    rcu_irq_enter(), and rcu_irq_exit() are empty functions, but each has
    EXPORT_SYMBOL_GPL(), which needlessly consumes extra memory, especially
    in kernels built with module support. This commit therefore moves these
    functions to static inlines in rcutiny.h, removing the need for exports.

    This won't affect the size of the tiniest kernels, which are likely
    built without module support, but might help semi-tiny kernels that
    might include module support.

    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     

16 Jan, 2015

2 commits

  • …rcu.2015.01.06a', 'stall.2015.01.16a' and 'torture.2015.01.11a' into HEAD

    doc.2015.01.07a: Documentation updates.
    fixes.2015.01.15a: Miscellaneous fixes.
    preempt.2015.01.06a: Changes to handling of lists of preempted tasks.
    srcu.2015.01.06a: SRCU updates.
    stall.2015.01.16a: RCU CPU stall-warning updates and fixes.
    torture.2015.01.11a: RCU torture-test updates and fixes.

    Paul E. McKenney
     
  • Although cond_resched_rcu_qs() only applies to TASKS_RCU, it is used
    in places where it would be useful for it to apply to the normal RCU
    flavors, rcu_preempt, rcu_sched, and rcu_bh. This is especially the
    case for workloads that aggressively overload the system, particularly
    those that generate large numbers of RCU updates on systems running
    NO_HZ_FULL CPUs. This commit therefore communicates quiescent states
    from cond_resched_rcu_qs() to the normal RCU flavors.

    Note that it is unfortunately necessary to leave the old ->passed_quiesce
    mechanism in place to allow quiescent states that apply to only one
    flavor to be recorded. (Yes, we could decrement ->rcu_qs_ctr_snap in
    that case, but that is not so good for debugging of RCU internals.)
    In addition, if one of the RCU flavor's grace period has stalled, this
    will invoke rcu_momentary_dyntick_idle(), resulting in a heavy-weight
    quiescent state visible from other CPUs.

    Reported-by: Sasha Levin
    Reported-by: Dave Jones
    Signed-off-by: Paul E. McKenney
    [ paulmck: Merge commit from Sasha Levin fixing a bug where __this_cpu()
    was used in preemptible code. ]

    Paul E. McKenney
     

11 Jan, 2015

3 commits

  • Currently, rcutorture's Reader Batch checks measure from the end of
    the previous grace period to the end of the current one. This commit
    tightens up these checks by measuring from the start and end of the same
    grace period. This involves adding rcu_batches_started() and friends
    corresponding to the existing rcu_batches_completed() and friends.

    We leave SRCU alone for the moment, as it does not yet have a way of
    tracking both ends of its grace periods.

    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     
  • A bug in rcutorture has caused it to ignore completed batches.
    In preparation for fixing that bug, this commit provides TINY_RCU with
    the required rcu_batches_completed_sched().

    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     
  • Long ago, the various ->completed fields were of type long, but now are
    unsigned long due to signed-integer-overflow concerns. However, the
    various _batches_completed() functions remained of type long, even though
    their only purpose in life is to return the corresponding ->completed
    field. This patch cleans this up by changing these functions' return
    types to unsigned long.

    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     

04 Nov, 2014

1 commit

  • The "cpu" argument to rcu_note_context_switch() is always the current
    CPU, so drop it. This in turn allows the "cpu" argument to
    rcu_preempt_note_context_switch() to be removed, which allows the sole
    use of "cpu" in both functions to be replaced with a this_cpu_ptr().
    Again, the anticipated cross-CPU uses of these functions has been
    replaced by NO_HZ_FULL.

    Signed-off-by: Paul E. McKenney
    Reviewed-by: Pranith Kumar

    Paul E. McKenney
     

08 Sep, 2014

1 commit

  • The rcu_bh_qs(), rcu_preempt_qs(), and rcu_sched_qs() functions use
    old-style per-CPU variable access and write to ->passed_quiesce even
    if it is already set. This commit therefore updates to use the new-style
    per-CPU variable access functions and avoids the spurious writes.
    This commit also eliminates the "cpu" argument to these functions because
    they are always invoked on the indicated CPU.

    Reported-by: Peter Zijlstra
    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     

15 May, 2014

1 commit


21 Mar, 2014

1 commit

  • The following pattern is currently not well supported by RCU:

    1. Make data element inaccessible to RCU readers.

    2. Do work that probably lasts for more than one grace period.

    3. Do something to make sure RCU readers in flight before #1 above
    have completed.

    Here are some things that could currently be done:

    a. Do a synchronize_rcu() unconditionally at either #1 or #3 above.
    This works, but imposes needless work and latency.

    b. Post an RCU callback at #1 above that does a wakeup, then
    wait for the wakeup at #3. This works well, but likely results
    in an extra unneeded grace period. Open-coding this is also
    a bit more semi-tricky code than would be good.

    This commit therefore adds get_state_synchronize_rcu() and
    cond_synchronize_rcu() APIs. Call get_state_synchronize_rcu() at #1
    above and pass its return value to cond_synchronize_rcu() at #3 above.
    This results in a call to synchronize_rcu() if no grace period has
    elapsed between #1 and #3, but requires only a load, comparison, and
    memory barrier if a full grace period did elapse.

    Requested-by: Peter Zijlstra
    Signed-off-by: Paul E. McKenney
    Acked-by: Peter Zijlstra

    Paul E. McKenney
     

26 Feb, 2014

1 commit


18 Feb, 2014

2 commits

  • If CONFIG_RCU_NOCB_CPU_ALL=y, then rcu_needs_cpu() will always
    return false, however, the current version nevertheless checks
    for RCU callbacks. This commit therefore creates a static inline
    implementation of rcu_needs_cpu() that unconditionally returns false
    when CONFIG_RCU_NOCB_CPU_ALL=y.

    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     
  • All of the RCU source files have the usual GPL header, which contains a
    long-obsolete postal address for FSF. To avoid the need to track the
    FSF office's movements, this commit substitutes the URL where GPL may
    be found.

    Reported-by: Greg KH
    Reported-by: Steven Rostedt
    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     

13 Dec, 2013

1 commit


25 Sep, 2013

2 commits

  • The old rcu_is_cpu_idle() function is just __rcu_is_watching() with
    preemption disabled. This commit therefore renames rcu_is_cpu_idle()
    to rcu_is_watching.

    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     
  • There is currently no way for kernel code to determine whether it
    is safe to enter an RCU read-side critical section, in other words,
    whether or not RCU is paying attention to the currently running CPU.
    Given the large and increasing quantity of code shared by the idle loop
    and non-idle code, the this shortcoming is becoming increasingly painful.

    This commit therefore adds __rcu_is_watching(), which returns true if
    it is safe to enter an RCU read-side critical section on the currently
    running CPU. This function is quite fast, using only a __this_cpu_read().
    However, the caller must disable preemption.

    Reported-by: Steven Rostedt
    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     

11 Jun, 2013

5 commits

  • Now that TINY_PREEMPT_RCU is no more, exit_rcu() is always an empty
    function. But if TINY_RCU is going to have an empty function, it should
    be in include/linux/rcutiny.h, where it does not bloat the kernel.
    This commit therefore moves exit_rcu() out of kernel/rcupdate.c to
    kernel/rcutree_plugin.h, and places a static inline empty function in
    include/linux/rcutiny.h in order to shrink TINY_RCU a bit.

    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     
  • With the removal of CONFIG_TINY_PREEMPT_RCU, rcu_preempt_note_context_switch()
    is now an empty function. This commit therefore eliminates it by inlining it.

    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     
  • Now that CONFIG_TINY_PREEMPT_RCU is no more, this commit removes
    the CONFIG_TINY_RCU ifdefs from include/linux/rcutiny.h in favor of
    unconditionally compiling the CONFIG_TINY_RCU legs of those ifdefs.

    Signed-off-by: Paul E. McKenney
    [ paulmck: Moved removal of #else to "Remove TINY_PREEMPT_RCU" as
    suggested by Josh Triplett. ]
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     
  • TINY_PREEMPT_RCU could use a kthread to handle RCU callback invocation,
    which required an API to abstract kthread vs. softirq invocation.
    Now that TINY_PREEMPT_RCU is no longer with us, this commit retires
    this API in favor of direct use of the relevant softirq primitives.

    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     
  • TINY_PREEMPT_RCU adds significant code and complexity, but does not
    offer commensurate benefits. People currently using TINY_PREEMPT_RCU
    can get much better memory footprint with TINY_RCU, or, if they really
    need preemptible RCU, they can use TREE_PREEMPT_RCU with a relatively
    minor degradation in memory footprint. Please note that this move
    has been widely publicized on LKML (https://lkml.org/lkml/2012/11/12/545)
    and on LWN (http://lwn.net/Articles/541037/).

    This commit therefore removes TINY_PREEMPT_RCU.

    Signed-off-by: Paul E. McKenney
    [ paulmck: Updated to eliminate #else in rcutiny.h as suggested by Josh ]
    Reviewed-by: Josh Triplett

    Paul E. McKenney