26 Jan, 2017

1 commit

  • commit 52d7e48b86fc108e45a656d8e53e4237993c481d upstream.

    The current preemptible RCU implementation goes through three phases
    during bootup. In the first phase, there is only one CPU that is running
    with preemption disabled, so that a no-op is a synchronous grace period.
    In the second mid-boot phase, the scheduler is running, but RCU has
    not yet gotten its kthreads spawned (and, for expedited grace periods,
    workqueues are not yet running. During this time, any attempt to do
    a synchronous grace period will hang the system (or complain bitterly,
    depending). In the third and final phase, RCU is fully operational and
    everything works normally.

    This has been OK for some time, but there has recently been some
    synchronous grace periods showing up during the second mid-boot phase.
    This code worked "by accident" for awhile, but started failing as soon
    as expedited RCU grace periods switched over to workqueues in commit
    8b355e3bc140 ("rcu: Drive expedited grace periods from workqueue").
    Note that the code was buggy even before this commit, as it was subject
    to failure on real-time systems that forced all expedited grace periods
    to run as normal grace periods (for example, using the rcu_normal ksysfs
    parameter). The callchain from the failure case is as follows:

    early_amd_iommu_init()
    |-> acpi_put_table(ivrs_base);
    |-> acpi_tb_put_table(table_desc);
    |-> acpi_tb_invalidate_table(table_desc);
    |-> acpi_tb_release_table(...)
    |-> acpi_os_unmap_memory
    |-> acpi_os_unmap_iomem
    |-> acpi_os_map_cleanup
    |-> synchronize_rcu_expedited

    The kernel showing this callchain was built with CONFIG_PREEMPT_RCU=y,
    which caused the code to try using workqueues before they were
    initialized, which did not go well.

    This commit therefore reworks RCU to permit synchronous grace periods
    to proceed during this mid-boot phase. This commit is therefore a
    fix to a regression introduced in v4.9, and is therefore being put
    forward post-merge-window in v4.10.

    This commit sets a flag from the existing rcu_scheduler_starting()
    function which causes all synchronous grace periods to take the expedited
    path. The expedited path now checks this flag, using the requesting task
    to drive the expedited grace period forward during the mid-boot phase.
    Finally, this flag is updated by a core_initcall() function named
    rcu_exp_runtime_mode(), which causes the runtime codepaths to be used.

    Note that this arrangement assumes that tasks are not sent POSIX signals
    (or anything similar) from the time that the first task is spawned
    through core_initcall() time.

    Fixes: 8b355e3bc140 ("rcu: Drive expedited grace periods from workqueue")
    Reported-by: "Zheng, Lv"
    Reported-by: Borislav Petkov
    Signed-off-by: Paul E. McKenney
    Tested-by: Stan Kain
    Tested-by: Ivan
    Tested-by: Emanuel Castelo
    Tested-by: Bruno Pesavento
    Tested-by: Borislav Petkov
    Tested-by: Frederic Bezies
    Signed-off-by: Greg Kroah-Hartman

    Paul E. McKenney
     

07 Jan, 2015

1 commit

  • For RCU in UP, context-switch = QS = GP, thus we can force a
    context-switch when any call_rcu_[bh|sched]() is happened on idle_task.
    After doing so, rcu_idle/irq_enter/exit() are useless, so we can simply
    make these functions empty.

    More important, this change does not change the functionality logically.
    Note: raise_softirq(RCU_SOFTIRQ)/rcu_sched_qs() in rcu_idle_enter() and
    outmost rcu_irq_exit() will have to wake up the ksoftirqd
    (due to in_interrupt() == 0).

    Before this patch After this patch:
    call_rcu_sched() in idle; call_rcu_sched() in idle
    set resched
    do other stuffs; do other stuffs
    outmost rcu_irq_exit() outmost rcu_irq_exit() (empty function)
    (or rcu_idle_enter()) (or rcu_idle_enter(), also empty function)
    start to resched. (see above)
    rcu_sched_qs() rcu_sched_qs()
    QS,and GP and advance cb QS,and GP and advance cb
    wake up the ksoftirqd wake up the ksoftirqd
    set resched
    resched to ksoftirqd (or other) resched to ksoftirqd (or other)

    These two code patches are almost the same.

    Size changed after patched:

    size kernel/rcu/tiny-old.o kernel/rcu/tiny-patched.o
    text data bss dec hex filename
    3449 206 8 3663 e4f kernel/rcu/tiny-old.o
    2406 144 8 2558 9fe kernel/rcu/tiny-patched.o

    Signed-off-by: Lai Jiangshan
    Signed-off-by: Paul E. McKenney

    Lai Jiangshan
     

04 Nov, 2014

1 commit

  • Add early boot self tests for RCU under CONFIG_PROVE_RCU.

    Currently the only test is adding a dummy callback which increments a counter
    which we then later verify after calling rcu_barrier*().

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

    Pranith Kumar
     

10 Jul, 2014

1 commit


26 Feb, 2014

2 commits

  • The kbuild test bot uncovered an implicit dependence on the
    trace header being present before rcu.h in ia64 allmodconfig
    that looks like this:

    In file included from kernel/ksysfs.c:22:0:
    kernel/rcu/rcu.h: In function '__rcu_reclaim':
    kernel/rcu/rcu.h:107:3: error: implicit declaration of function 'trace_rcu_invoke_kfree_callback' [-Werror=implicit-function-declaration]
    kernel/rcu/rcu.h:112:3: error: implicit declaration of function 'trace_rcu_invoke_callback' [-Werror=implicit-function-declaration]
    cc1: some warnings being treated as errors

    Looking at other rcu.h users, we can find that they all
    were sourcing the trace header in advance of rcu.h itself,
    as seen in the context of this diff. There were also some
    inconsistencies as to whether it was or wasn't sourced based
    on the parent tracing Kconfig.

    Rather than "fix" it at each use site, and have inconsistent
    use based on whether "#ifdef CONFIG_RCU_TRACE" was used or not,
    lets just source the trace header just once, in the actual consumer
    of it, which is rcu.h itself. We include it unconditionally, as
    build testing shows us that is a hard requirement for some files.

    Reported-by: kbuild test robot
    Signed-off-by: Paul Gortmaker
    Signed-off-by: Paul E. McKenney

    Paul Gortmaker
     
  • This commit fixes the follwoing warning:

    kernel/ksysfs.c:143:5: warning: symbol 'rcu_expedited' was not declared. Should it be static?

    Signed-off-by: Paul Gortmaker
    [ paulmck: Moved the declaration to include/linux/rcupdate.h to avoid
    including the RCU-internal rcu.h file outside of RCU. ]
    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul Gortmaker
     

18 Feb, 2014

1 commit

  • 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


10 Dec, 2013

1 commit


16 Oct, 2013

1 commit