RCU changes for v3.3
Subsystems (32)
Linus,
Please pull the latest core-rcu-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-rcu-for-linus
Thanks,
Ingo
------------------>
Frederic Weisbecker (11):
rcu: Detect illegal rcu dereference in extended quiescent state
rcu: Inform the user about extended quiescent state on PROVE_RCU warning
rcu: Warn when rcu_read_lock() is used in extended quiescent state
nohz: Separate out irq exit and idle loop dyntick logic
nohz: Allow rcu extended quiescent state handling seperately from tick stop
x86: Enter rcu extended qs after idle notifier call
x86: Call idle notifier after irq_enter()
rcu: Fix early call to rcu_idle_enter()
nohz: Remove tick_nohz_idle_enter_norcu() / tick_nohz_idle_exit_norcu()
rcu: Don't check irq nesting from rcu idle entry/exit
rcu: Irq nesting is always 0 on rcu_enter_idle_common
Josh Triplett (1):
driver-core/cpu: Expose hotpluggability to the rest of the kernel
Kees Cook (1):
docs: Additional LWN links to RCU API
Paul E. McKenney (49):
rcu: ->signaled better named ->fqs_state
rcu: Avoid RCU-preempt expedited grace-period botch
rcu: Make synchronize_sched_expedited() better at work sharing
lockdep: Update documentation for lock-class leak detection
rcu: Track idleness independent of idle tasks
trace: Allow ftrace_dump() to be called from modules
rcu: Add failure tracing to rcutorture
rcu: Document failing tick as cause of RCU CPU stall warning
rcu: Disable preemption in rcu_is_cpu_idle()
rcu: Remove one layer of abstraction from PROVE_RCU checking
rcu: Warn when srcu_read_lock() is used in an extended quiescent state
rcu: Make srcu_read_lock_held() call common lockdep-enabled function
powerpc: Tell RCU about idle after hcall tracing
rcu: Introduce raw SRCU read-side primitives
rcu: Add documentation for raw SRCU read-side primitives
rcu: Deconfuse dynticks entry-exit tracing
rcu: Add more information to the wrong-idle-task complaint
rcu: Allow dyntick-idle mode for CPUs with callbacks
rcu: Fix idle-task checks
rcu: Permit RCU_FAST_NO_HZ to be used by TREE_PREEMPT_RCU
rcu: Add rcutorture system-shutdown capability
rcu: Control rcutorture startup from kernel boot parameters
sched: Add is_idle_task() to handle invalidated uses of idle_cpu()
rcu: Make RCU use the new is_idle_task() API
sparc: Make SPARC use the new is_idle_task() API
kdb: Make KDB use the new is_idle_task() API
events: Make events use the new is_idle_task() API
tile: Make tile use the new is_idle_task() API
rcu: Add rcutorture CPU-hotplug capability
doc: Add load/store guarantees to Documentation/atomic-ops.txt
rcu: Update trace_rcu_dyntick() header comment
rcu: Add tracing for RCU_FAST_NO_HZ
rcu: Go dyntick-idle more quickly if CPU has serviced current grace period
rcu: Avoid needlessly IPIing CPUs at GP end
rcu: Eliminate RCU_FAST_NO_HZ grace-period hang
rcu: Reduce latency of rcu_prepare_for_idle()
rcu: Remove dynticks false positives and RCU failures
rcu: Identify dyntick-idle CPUs on first force_quiescent_state() pass
rcu: Document same-context read-side constraints
rcu: Permit dyntick-idle with callbacks pending
rcu: Keep invoking callbacks if CPU otherwise idle
rcu: Adaptive dyntick-idle preparation
rcu: Remove redundant rcu_cpu_stall_suppress declaration
rcu: Make rcutorture test for hotpluggability before offlining CPUs
rcu: Add rcutorture tests for srcu_read_lock_raw()
rcu: Augment rcu_batch_end tracing for idle and callback state Revert "rcu: Permit rt_mutex_unlock() with irqs disabled"
rcu: Apply ACCESS_ONCE() to rcu_boost() return value
cpu: Export cpu_up()
Thomas Gleixner (2):
rcu: Omit self-awaken when setting up expedited grace period
rcu: Remove redundant return from rcu_report_exp_rnp()
Documentation/RCU/checklist.txt | 6 + Documentation/RCU/rcu.txt | 10 +- Documentation/RCU/stallwarn.txt | 16 +- Documentation/RCU/torture.txt | 13 ++ Documentation/RCU/trace.txt | 4 - Documentation/RCU/whatisRCU.txt | 19 ++- Documentation/atomic_ops.txt | 87 +++++++++ Documentation/lockdep-design.txt | 63 +++++++ arch/arm/kernel/process.c | 6 +- arch/avr32/kernel/process.c | 6 +- arch/blackfin/kernel/process.c | 6 +- arch/microblaze/kernel/process.c | 6 +- arch/mips/kernel/process.c | 6 +- arch/openrisc/kernel/idle.c | 6 +- arch/powerpc/kernel/idle.c | 15 ++- arch/powerpc/platforms/iseries/setup.c | 12 +- arch/powerpc/platforms/pseries/lpar.c | 4 + arch/s390/kernel/process.c | 6 +- arch/sh/kernel/idle.c | 6 +- arch/sparc/kernel/process_64.c | 6 +- arch/sparc/kernel/setup_32.c | 2 +- arch/tile/kernel/process.c | 6 +- arch/tile/mm/fault.c | 4 +- arch/um/kernel/process.c | 6 +- arch/unicore32/kernel/process.c | 6 +- arch/x86/kernel/apic/apic.c | 6 +- arch/x86/kernel/apic/io_apic.c | 2 +- arch/x86/kernel/cpu/mcheck/therm_throt.c | 2 +- arch/x86/kernel/cpu/mcheck/threshold.c | 2 +- arch/x86/kernel/irq.c | 6 +- arch/x86/kernel/process_32.c | 6 +- arch/x86/kernel/process_64.c | 10 +- drivers/base/cpu.c | 7 + include/linux/cpu.h | 1 + include/linux/hardirq.h | 21 --- include/linux/rcupdate.h | 115 ++++++++----- include/linux/sched.h | 8 + include/linux/srcu.h | 87 ++++++++-- include/linux/tick.h | 11 +- include/trace/events/rcu.h | 122 +++++++++++-- init/Kconfig | 10 +- kernel/cpu.c | 1 + kernel/debug/kdb/kdb_support.c | 2 +- kernel/events/core.c | 2 +- kernel/lockdep.c | 22 +++ kernel/rcu.h | 7 + kernel/rcupdate.c | 12 ++ kernel/rcutiny.c | 149 +++++++++++++-- kernel/rcutiny_plugin.h | 29 +++- kernel/rcutorture.c | 225 ++++++++++++++++++++++- kernel/rcutree.c | 290 +++++++++++++++++++++--------- kernel/rcutree.h | 26 ++-- kernel/rcutree_plugin.h | 289 ++++++++++++++++++++++++------ kernel/rcutree_trace.c | 12 +- kernel/rtmutex.c | 8 - kernel/softirq.c | 4 +- kernel/time/tick-sched.c | 97 ++++++---- kernel/trace/trace.c | 1 + 58 files changed, 1512 insertions(+), 407 deletions(-)
Documentation/RCU/checklist.txt +6 -0
@@ -328,6 +328,12 @@ over a rather long period of time, but improvements are always welcome! RCU rather than SRCU, because RCU is almost always faster and easier to use than is SRCU. + If you need to enter your read-side critical section in a + hardirq or exception handler, and then exit that same read-side + critical section in the task that was interrupted, then you need + to srcu_read_lock_raw() and srcu_read_unlock_raw(), which avoid + the lockdep checking that would otherwise this practice illegal. + Also unlike other forms of RCU, explicit initialization and cleanup is required via init_srcu_struct() and cleanup_srcu_struct(). These are passed a "struct srcu_struct"
Documentation/RCU/rcu.txt +5 -5
@@ -38,11 +38,11 @@ o How can the updater tell when a grace period has completed Preemptible variants of RCU (CONFIG_TREE_PREEMPT_RCU) get the same effect, but require that the readers manipulate CPU-local - counters. These counters allow limited types of blocking - within RCU read-side critical sections. SRCU also uses - CPU-local counters, and permits general blocking within - RCU read-side critical sections. These two variants of - RCU detect grace periods by sampling these counters. + counters. These counters allow limited types of blocking within + RCU read-side critical sections. SRCU also uses CPU-local + counters, and permits general blocking within RCU read-side + critical sections. These variants of RCU detect grace periods + by sampling these counters. o If I am running on a uniprocessor kernel, which can only do one thing at a time, why should I wait for a grace period?
Documentation/RCU/stallwarn.txt +10 -6
@@ -101,6 +101,11 @@ o A CPU-bound real-time task in a CONFIG_PREEMPT_RT kernel that CONFIG_TREE_PREEMPT_RCU case, you might see stall-warning messages. +o A hardware or software issue shuts off the scheduler-clock + interrupt on a CPU that is not in dyntick-idle mode. This + problem really has happened, and seems to be most likely to + result in RCU CPU stall warnings for CONFIG_NO_HZ=n kernels. + o A bug in the RCU implementation. o A hardware failure. This is quite unlikely, but has occurred
@@ -109,12 +114,11 @@ o A hardware failure. This is quite unlikely, but has occurred This resulted in a series of RCU CPU stall warnings, eventually leading the realization that the CPU had failed. -The RCU, RCU-sched, and RCU-bh implementations have CPU stall -warning. SRCU does not have its own CPU stall warnings, but its -calls to synchronize_sched() will result in RCU-sched detecting -RCU-sched-related CPU stalls. Please note that RCU only detects -CPU stalls when there is a grace period in progress. No grace period, -no CPU stall warnings. +The RCU, RCU-sched, and RCU-bh implementations have CPU stall warning. +SRCU does not have its own CPU stall warnings, but its calls to +synchronize_sched() will result in RCU-sched detecting RCU-sched-related +CPU stalls. Please note that RCU only detects CPU stalls when there is +a grace period in progress. No grace period, no CPU stall warnings. To diagnose the cause of the stall, inspect the stack traces. The offending function will usually be near the top of the stack.
Documentation/RCU/torture.txt +13 -0
@@ -61,11 +61,24 @@ nreaders This is the number of RCU reading threads supported. To properly exercise RCU implementations with preemptible read-side critical sections. +onoff_interval + The number of seconds between each attempt to execute a + randomly selected CPU-hotplug operation. Defaults to + zero, which disables CPU hotplugging. In HOTPLUG_CPU=n + kernels, rcutorture will silently refuse to do any + CPU-hotplug operations regardless of what value is + specified for onoff_interval. + shuffle_interval The number of seconds to keep the test threads affinitied to a particular subset of the CPUs, defaults to 3 seconds. Used in conjunction with test_no_idle_hz. +shutdown_secs The number of seconds to run the test before terminating + the test and powering off the system. The default is + zero, which disables test termination and system shutdown. + This capability is useful for automated testing. + stat_interval The number of seconds between output of torture statistics (via printk()). Regardless of the interval, statistics are printed when the module is unloaded.
Documentation/RCU/trace.txt +0 -4
@@ -105,14 +105,10 @@ o "dt" is the current value of the dyntick counter that is incremented or one greater than the interrupt-nesting depth otherwise. The number after the second "/" is the NMI nesting depth. - This field is displayed only for CONFIG_NO_HZ kernels. - o "df" is the number of times that some other CPU has forced a quiescent state on behalf of this CPU due to this CPU being in dynticks-idle state. - This field is displayed only for CONFIG_NO_HZ kernels. - o "of" is the number of times that some other CPU has forced a quiescent state on behalf of this CPU due to this CPU being offline. In a perfect world, this might never happen, but it
Documentation/RCU/whatisRCU.txt +14 -5
@@ -4,6 +4,7 @@ to start learning about RCU: 1. What is RCU, Fundamentally? http://lwn.net/Articles/262464/ 2. What is RCU? Part 2: Usage http://lwn.net/Articles/263130/ 3. RCU part 3: the RCU API http://lwn.net/Articles/264090/ +4. The RCU API, 2010 Edition http://lwn.net/Articles/418853/ What is RCU?
@@ -834,6 +835,8 @@ SRCU: Critical sections Grace period Barrier srcu_read_lock synchronize_srcu N/A srcu_read_unlock synchronize_srcu_expedited + srcu_read_lock_raw + srcu_read_unlock_raw srcu_dereference SRCU: Initialization/cleanup
@@ -855,27 +858,33 @@ list can be helpful: a. Will readers need to block? If so, you need SRCU. -b. What about the -rt patchset? If readers would need to block +b. Is it necessary to start a read-side critical section in a + hardirq handler or exception handler, and then to complete + this read-side critical section in the task that was + interrupted? If so, you need SRCU's srcu_read_lock_raw() and + srcu_read_unlock_raw() primitives. + +c. What about the -rt patchset? If readers would need to block in an non-rt kernel, you need SRCU. If readers would block in a -rt kernel, but not in a non-rt kernel, SRCU is not necessary. -c. Do you need to treat NMI handlers, hardirq handlers, +d. Do you need to treat NMI handlers, hardirq handlers, and code segments with preemption disabled (whether via preempt_disable(), local_irq_save(), local_bh_disable(), or some other mechanism) as if they were explicit RCU readers? If so, you need RCU-sched. -d. Do you need RCU grace periods to complete even in the face +e. Do you need RCU grace periods to complete even in the face of softirq monopolization of one or more of the CPUs? For example, is your code subject to network-based denial-of-service attacks? If so, you need RCU-bh. -e. Is your workload too update-intensive for normal use of +f. Is your workload too update-intensive for normal use of RCU, but inappropriate for other synchronization mechanisms? If so, consider SLAB_DESTROY_BY_RCU. But please be careful! -f. Otherwise, use RCU. +g. Otherwise, use RCU. Of course, this all assumes that you have determined that RCU is in fact the right tool for your job.
Documentation/atomic_ops.txt +87 -0
93 lines not on this page · raw message
Documentation/lockdep-design.txt +63 -0
66 lines not on this page · raw message
arch/arm/kernel/process.c +4 -2
@@ -183,7 +183,8 @@ void cpu_idle(void)/* endless idle loop with no priority at all */ while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();leds_event (led_idle_start);while (!need_resched ()) {#ifdef CONFIG_HOTPLUG_CPU
@@ -213,7 +214,8 @@ void cpu_idle(void) } }leds_event (led_idle_end); -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();preempt_disable ();
arch/avr32/kernel/process.c +4 -2
@@ -34,10 +34,12 @@ void cpu_idle(void) {/* endless idle loop with no priority at all */ while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();while (!need_resched ())cpu_idle_sleep (); -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();preempt_disable ();
arch/blackfin/kernel/process.c +4 -2
@@ -88,10 +88,12 @@ void cpu_idle(void)#endif if (!idle) idle = default_idle; -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();while (!need_resched ())idle (); -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();preempt_disable ();
arch/microblaze/kernel/process.c +4 -2
@@ -103,10 +103,12 @@ void cpu_idle(void)if (!idle) idle = default_idle; -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();while (!need_resched ())idle (); -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();
arch/mips/kernel/process.c +4 -2
@@ -56,7 +56,8 @@ void __noreturn cpu_idle(void)/* endless idle loop with no priority at all */ while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();while (!need_resched () &&cpu_online (cpu)) {#ifdef CONFIG_MIPS_MT_SMTC extern void smtc_idle_loop_hook (void );
@@ -77,7 +78,8 @@ void __noreturn cpu_idle(void) system_state == SYSTEM_BOOTING))play_dead ();#endif -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();preempt_disable ();
arch/openrisc/kernel/idle.c +4 -2
@@ -51,7 +51,8 @@ void cpu_idle(void)/* endless idle loop with no priority at all */ while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();while (!need_resched ()) {check_pgt_cache ();
@@ -69,7 +70,8 @@ void cpu_idle(void)set_thread_flag (TIF_POLLING_NRFLAG ); } -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();preempt_disable ();
arch/powerpc/kernel/idle.c +13 -2
@@ -46,6 +46,12 @@ static int __init powersave_off(char *arg) }__setup ("powersave=off" , powersave_off); +#if defined(CONFIG_PPC_PSERIES ) && defined(CONFIG_TRACEPOINTS ) +static const bool idle_uses_rcu =1 ; +#else +static const bool idle_uses_rcu; +#endif +/* * The body of the idle task. */
@@ -56,7 +62,10 @@ void cpu_idle(void)set_thread_flag (TIF_POLLING_NRFLAG );while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +if (!idle_uses_rcu) +rcu_idle_enter (); +while (!need_resched () && !cpu_should_die ()) {ppc64_runlatch_off ();
@@ -93,7 +102,9 @@ void cpu_idle(void)HMT_medium ();ppc64_runlatch_on (); -tick_nohz_restart_sched_tick (); +if (!idle_uses_rcu) +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();if (cpu_should_die ())cpu_die ();
arch/powerpc/platforms/iseries/setup.c +8 -4
@@ -563,7 +563,8 @@ static void yield_shared_processor(void)static void iseries_shared_idle (void ) {while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();while (!need_resched () && !hvlpevent_is_pending ()) {local_irq_disable ();ppc64_runlatch_off ();
@@ -577,7 +578,8 @@ static void iseries_shared_idle(void) }ppc64_runlatch_on (); -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();if (hvlpevent_is_pending ())process_iSeries_events ();
@@ -593,7 +595,8 @@ static void iseries_dedicated_idle(void)set_thread_flag (TIF_POLLING_NRFLAG );while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();if (!need_resched ()) {while (!need_resched ()) {ppc64_runlatch_off ();
@@ -610,7 +613,8 @@ static void iseries_dedicated_idle(void) }ppc64_runlatch_on (); -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();preempt_disable ();
arch/powerpc/platforms/pseries/lpar.c +4 -0
@@ -555,6 +555,8 @@ void __trace_hcall_entry(unsigned long opcode, unsigned long *args) (*depth)++;trace_hcall_entry (opcode, args); +if (opcode ==H_CEDE ) +rcu_idle_enter (); (*depth)--; out:
@@ -575,6 +577,8 @@ void __trace_hcall_exit(long opcode, unsigned long retval, goto out; (*depth)++; +if (opcode ==H_CEDE ) +rcu_idle_exit ();trace_hcall_exit (opcode, retval, retbuf); (*depth)--;
arch/s390/kernel/process.c +4 -2
@@ -91,10 +91,12 @@ static void default_idle(void)void cpu_idle (void ) {for (;;) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();while (!need_resched ())default_idle (); -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();preempt_disable ();
arch/sh/kernel/idle.c +4 -2
@@ -89,7 +89,8 @@ void cpu_idle(void)/* endless idle loop with no priority at all */ while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();while (!need_resched ()) {check_pgt_cache ();
@@ -111,7 +112,8 @@ void cpu_idle(void)start_critical_timings (); } -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();preempt_disable ();
arch/sparc/kernel/process_64.c +4 -2
@@ -95,12 +95,14 @@ void cpu_idle(void)set_thread_flag (TIF_POLLING_NRFLAG );while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();while (!need_resched () && !cpu_is_offline (cpu))sparc64_yield (cpu); -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();
arch/sparc/kernel/setup_32.c +1 -1
@@ -84,7 +84,7 @@ static void prom_sync_me(void)prom_printf ("PROM SYNC COMMAND...\n" );show_free_areas (0 ); -if (current->pid !=0 ) { +if (!is_idle_task (current)) {local_irq_enable ();sys_sync ();local_irq_disable ();
arch/tile/kernel/process.c +4 -2
@@ -85,7 +85,8 @@ void cpu_idle(void)/* endless idle loop with no priority at all */ while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();while (!need_resched ()) {if (cpu_is_offline (cpu))BUG ();/* no HOTPLUG_CPU */
@@ -105,7 +106,8 @@ void cpu_idle(void)local_irq_enable ();current_thread_info ()->status |=TS_POLLING ; } -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();preempt_disable ();
arch/tile/mm/fault.c +2 -2
@@ -54,7 +54,7 @@ static noinline void force_sig_info_fault(const char *type, int si_signo,if (unlikely (tsk->pid <2 )) {panic ("Signal %d (code %d) at %#lx sent to %s!" , si_signo, si_code &0xffff , address, - tsk->pid ?"init" :"the idle task" ); +is_idle_task (tsk) ?"the idle task" :"init" ); } info.si_signo = si_signo;
@@ -515,7 +515,7 @@ no_context:if (unlikely (tsk->pid <2 )) {panic ("Kernel page fault running %s!" , - tsk->pid ?"init" :"the idle task" ); +is_idle_task (tsk) ?"the idle task" :"init" ); }/*
arch/um/kernel/process.c +4 -2
@@ -246,10 +246,12 @@ void default_idle(void)if (need_resched ())schedule (); -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter (); nsecs =disable_timer ();idle_sleep (nsecs); -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit (); } }
arch/unicore32/kernel/process.c +4 -2
@@ -55,7 +55,8 @@ void cpu_idle(void) {/* endless idle loop with no priority at all */ while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();while (!need_resched ()) {local_irq_disable ();stop_critical_timings ();
@@ -63,7 +64,8 @@ void cpu_idle(void)local_irq_enable ();start_critical_timings (); } -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();preempt_disable ();
arch/x86/kernel/apic/apic.c +3 -3
@@ -876,8 +876,8 @@ void __irq_entry smp_apic_timer_interrupt(struct pt_regs *regs)* Besides, if we don't timer interrupts ignore the global * interrupt lock, which is the WrongThing (tm) to do. */ -exit_idle ();irq_enter (); +exit_idle ();local_apic_timer_interrupt ();irq_exit ();
@@ -1809,8 +1809,8 @@ void smp_spurious_interrupt(struct pt_regs *regs) {u32 v; -exit_idle ();irq_enter (); +exit_idle ();/* * Check if this really is a spurious interrupt and ACK it * if it is a vectored one. Just in case...
@@ -1846,8 +1846,8 @@ void smp_error_interrupt(struct pt_regs *regs) "Illegal register address", /* APIC Error Bit 7 */ }; -exit_idle ();irq_enter (); +exit_idle ();/* First tickle the hardware, only then report what went on. -- REW */ v0 =apic_read (APIC_ESR );apic_write (APIC_ESR ,0 );
arch/x86/kernel/apic/io_apic.c +1 -1
@@ -2421,8 +2421,8 @@ asmlinkage void smp_irq_move_cleanup_interrupt(void)unsigned vector, me;ack_APIC_irq (); -exit_idle ();irq_enter (); +exit_idle (); me =smp_processor_id ();for (vector =FIRST_EXTERNAL_VECTOR ; vector <NR_VECTORS ; vector++) {
arch/x86/kernel/cpu/mcheck/therm_throt.c +1 -1
@@ -397,8 +397,8 @@ static void (*smp_thermal_vector)(void) = unexpected_thermal_interrupt; asmlinkage void smp_thermal_interrupt(struct pt_regs *regs) { -exit_idle ();irq_enter (); +exit_idle ();inc_irq_stat (irq_thermal_count);smp_thermal_vector ();irq_exit ();
arch/x86/kernel/cpu/mcheck/threshold.c +1 -1
@@ -19,8 +19,8 @@ void (*mce_threshold_vector)(void) = default_threshold_interrupt; asmlinkage void smp_threshold_interrupt(void) { -exit_idle ();irq_enter (); +exit_idle ();inc_irq_stat (irq_threshold_count);mce_threshold_vector ();irq_exit ();
arch/x86/kernel/irq.c +3 -3
@@ -181,8 +181,8 @@ unsigned int __irq_entry do_IRQ(struct pt_regs *regs)unsigned vector = ~regs->orig_ax;unsigned irq; -exit_idle ();irq_enter (); +exit_idle (); irq =__this_cpu_read (vector_irq[vector]);
@@ -209,10 +209,10 @@ void smp_x86_platform_ipi(struct pt_regs *regs)ack_APIC_irq (); -exit_idle (); -irq_enter (); +exit_idle (); +inc_irq_stat (x86_platform_ipis);if (x86_platform_ipi_callback)
arch/x86/kernel/process_32.c +4 -2
@@ -99,7 +99,8 @@ void cpu_idle(void)/* endless idle loop with no priority at all */ while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter (); +rcu_idle_enter ();while (!need_resched ()) {check_pgt_cache ();
@@ -116,7 +117,8 @@ void cpu_idle(void)pm_idle ();start_critical_timings (); } -tick_nohz_restart_sched_tick (); +rcu_idle_exit (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();preempt_disable ();
arch/x86/kernel/process_64.c +8 -2
@@ -122,7 +122,7 @@ void cpu_idle(void)/* endless idle loop with no priority at all */ while (1 ) { -tick_nohz_stop_sched_tick (1 ); +tick_nohz_idle_enter ();while (!need_resched ()) {rmb ();
@@ -139,8 +139,14 @@ void cpu_idle(void)enter_idle ();/* Don't trace irqs off for idle */ stop_critical_timings (); + +/* enter_idle() needs rcu for notifiers */ +rcu_idle_enter (); +if (cpuidle_idle_call ())pm_idle (); + +rcu_idle_exit ();start_critical_timings ();/* In many cases the interrupt that ended idle
@@ -149,7 +155,7 @@ void cpu_idle(void)__exit_idle (); } -tick_nohz_restart_sched_tick (); +tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();preempt_disable ();
drivers/base/cpu.c +7 -0
@@ -247,6 +247,13 @@ struct sys_device *get_cpu_sysdev(unsigned cpu) }EXPORT_SYMBOL_GPL (get_cpu_sysdev); +bool cpu_is_hotpluggable (unsigned cpu) +{ +struct sys_device *dev =get_cpu_sysdev (cpu); + return dev && container_of(dev, struct cpu, sysdev)->hotpluggable; +} +EXPORT_SYMBOL_GPL (cpu_is_hotpluggable); +int __init cpu_dev_init (void ) {int err;
include/linux/cpu.h +1 -0
@@ -27,6 +27,7 @@ struct cpu {extern int register_cpu (struct cpu *cpu,int num);extern struct sys_device *get_cpu_sysdev (unsigned cpu); +extern bool cpu_is_hotpluggable (unsigned cpu);extern int cpu_add_sysdev_attr (struct sysdev_attribute *attr);extern void cpu_remove_sysdev_attr (struct sysdev_attribute *attr);
include/linux/hardirq.h +0 -21
@@ -139,20 +139,7 @@ static inline void account_system_vtime(struct task_struct *tsk)extern void account_system_vtime (struct task_struct *tsk);#endif -#if defined(CONFIG_NO_HZ)#if defined(CONFIG_TINY_RCU ) || defined(CONFIG_TINY_PREEMPT_RCU ) -extern void rcu_enter_nohz(void); -extern void rcu_exit_nohz(void); - -static inline void rcu_irq_enter(void) -{ - rcu_exit_nohz(); -} - -static inline void rcu_irq_exit(void) -{ - rcu_enter_nohz(); -}static inline void rcu_nmi_enter (void ) {
@@ -163,17 +150,9 @@ static inline void rcu_nmi_exit(void) }#else -extern void rcu_irq_enter (void ); -extern void rcu_irq_exit (void );extern void rcu_nmi_enter (void );extern void rcu_nmi_exit (void );#endif -#else -# define rcu_irq_enter () do { } while (0) -# define rcu_irq_exit () do { } while (0) -# define rcu_nmi_enter () do { } while (0) -# define rcu_nmi_exit () do { } while (0) -#endif /* #if defined(CONFIG_NO_HZ) */ /* * It is safe to do non-atomic ops on ->hardirq_context,
include/linux/rcupdate.h +73 -42
217 lines not on this page · raw message
include/linux/sched.h +8 -0
@@ -2070,6 +2070,14 @@ extern int sched_setscheduler(struct task_struct *, int,extern int sched_setscheduler_nocheck (struct task_struct *,int ,const struct sched_param *);extern struct task_struct *idle_task (int cpu); +/** +* is_idle_task - is the specified task an idle task? +* @tsk: the task in question. +*/ +static inline bool is_idle_task (struct task_struct *p) +{ +return p->pid ==0 ; +}extern struct task_struct *curr_task (int cpu);extern void set_curr_task (int cpu,struct task_struct *p);
include/linux/srcu.h +74 -13
130 lines not on this page · raw message
include/linux/tick.h +7 -4
@@ -7,6 +7,7 @@#define _LINUX_TICK_H#include <linux/clockchips.h> +#include <linux/irqflags.h> #ifdef CONFIG_GENERIC_CLOCKEVENTS
@@ -121,14 +122,16 @@ static inline int tick_oneshot_mode_active(void) { return 0; }#endif /* !CONFIG_GENERIC_CLOCKEVENTS */ # ifdef CONFIG_NO_HZ -extern void tick_nohz_stop_sched_tick (int inidle); -extern void tick_nohz_restart_sched_tick (void ); +extern void tick_nohz_idle_enter (void ); +extern void tick_nohz_idle_exit (void ); +extern void tick_nohz_irq_exit (void );extern ktime_t tick_nohz_get_sleep_length (void );extern u64 get_cpu_idle_time_us (int cpu,u64 *last_update_time);extern u64 get_cpu_iowait_time_us (int cpu,u64 *last_update_time);# else -static inline void tick_nohz_stop_sched_tick (int inidle) { } -static inline void tick_nohz_restart_sched_tick (void ) { } +static inline void tick_nohz_idle_enter (void ) { } +static inline void tick_nohz_idle_exit (void ) { } +static inline ktime_t tick_nohz_get_sleep_length (void ) {ktime_t len = { .tv64 =NSEC_PER_SEC /HZ };
include/trace/events/rcu.h +109 -13
173 lines not on this page · raw message
init/Kconfig +5 -5
@@ -469,14 +469,14 @@ config RCU_FANOUT_EXACT config RCU_FAST_NO_HZ bool "Accelerate last non-dyntick-idle CPU's grace periods" - depends on TREE_RCU && NO_HZ && SMP + depends on NO_HZ && SMP default n help This option causes RCU to attempt to accelerate grace periods - in order to allow the final CPU to enter dynticks-idle state - more quickly. On the other hand, this option increases the - overhead of the dynticks-idle checking, particularly on systems - with large numbers of CPUs. + in order to allow CPUs to enter dynticks-idle state more + quickly. On the other hand, this option increases the overhead + of the dynticks-idle checking, particularly on systems with + large numbers of CPUs. Say Y if energy efficiency is critically important, particularly if you have relatively few CPUs.
kernel/cpu.c +1 -0
@@ -380,6 +380,7 @@ out:cpu_maps_update_done ();return err; } +EXPORT_SYMBOL_GPL (cpu_up);#ifdef CONFIG_PM_SLEEP_SMP static cpumask_var_t frozen_cpus;
kernel/debug/kdb/kdb_support.c +1 -1
@@ -636,7 +636,7 @@ char kdb_task_state_char (const struct task_struct *p) (p->exit_state &EXIT_ZOMBIE ) ?'Z' : (p->exit_state &EXIT_DEAD ) ?'E' : (p->state &TASK_INTERRUPTIBLE ) ?'S' :'?' ; -if (p->pid ==0 ) { +if (is_idle_task (p)) {/* Idle task. Is it really idle, apart from the kdb * interrupt? */ if (!kdb_task_has_cpu (p) || kgdb_info[cpu].irq_depth ==1 ) {
kernel/events/core.c +1 -1
@@ -5362,7 +5362,7 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer) regs =get_irq_regs ();if (regs && !perf_exclude_event (event, regs)) { -if (!(event->attr.exclude_idle && current->pid ==0 )) +if (!(event->attr.exclude_idle &&is_idle_task (current)))if (perf_event_overflow (event, &data, regs)) ret =HRTIMER_NORESTART ; }
kernel/lockdep.c +22 -0
@@ -4170,6 +4170,28 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)printk ("%s:%d %s!\n" , file, line, s);printk ("\nother info that might help us debug this:\n\n" );printk ("\nrcu_scheduler_active = %d, debug_locks = %d\n" , rcu_scheduler_active, debug_locks); + +/* +* If a CPU is in the RCU-free window in idle (ie: in the section +* between rcu_idle_enter() and rcu_idle_exit(), then RCU +* considers that CPU to be in an "extended quiescent state", +* which means that RCU will be completely ignoring that CPU. +* Therefore, rcu_read_lock() and friends have absolutely no +* effect on a CPU running in that state. In other words, even if +* such an RCU-idle CPU has called rcu_read_lock(), RCU might well +* delete data structures out from under it. RCU really has no +* choice here: we need to keep an RCU-free window in idle where +* the CPU may possibly enter into low power mode. This way we can +* notice an extended quiescent state to other CPUs that started a grace +* period. Otherwise we would delay any grace period as long as we run +* in the idle task. +* +* So complain bitterly if someone does call rcu_read_lock(), +* rcu_read_lock_bh() and so on from extended quiescent states. +*/ +if (rcu_is_cpu_idle ()) +printk ("RCU used illegally from extended quiescent state!\n" ); +lockdep_print_held_locks (curr);printk ("\nstack backtrace:\n" );dump_stack ();
kernel/rcu.h +7 -0
@@ -30,6 +30,13 @@#endif /* #else #ifdef CONFIG_RCU_TRACE */ /* +* Process-level increment to ->dynticks_nesting field. This allows for +* architectures that use half-interrupts and half-exceptions from +* process context. +*/ +#define DYNTICK_TASK_NESTING (LLONG_MAX / 2 - 1) + +/* * debug_rcu_head_queue()/debug_rcu_head_unqueue() are used internally * by call_rcu() and rcu callback execution, and are therefore not part of the * RCU API. Leaving in rcupdate.h because they are used by all RCU flavors.
kernel/rcupdate.c +12 -0
@@ -93,6 +93,8 @@ int rcu_read_lock_bh_held(void) {if (!debug_lockdep_rcu_enabled ())return 1 ; +if (rcu_is_cpu_idle ()) +return 0 ;return in_softirq () ||irqs_disabled (); }EXPORT_SYMBOL_GPL (rcu_read_lock_bh_held);
@@ -316,3 +318,13 @@ struct debug_obj_descr rcuhead_debug_descr = { };EXPORT_SYMBOL_GPL (rcuhead_debug_descr);#endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */ + +#if defined(CONFIG_TREE_RCU ) || defined(CONFIG_TREE_PREEMPT_RCU ) || defined(CONFIG_RCU_TRACE ) +void do_trace_rcu_torture_read (char *rcutorturename,struct rcu_head *rhp) +{ +trace_rcu_torture_read (rcutorturename, rhp); +} +EXPORT_SYMBOL_GPL (do_trace_rcu_torture_read); +#else +#define do_trace_rcu_torture_read (rcutorturename, rhp) do { } while (0) +#endif
kernel/rcutiny.c +130 -19
189 lines not on this page · raw message
kernel/rcutiny_plugin.h +27 -2
@@ -312,8 +312,8 @@ static int rcu_boost(void)rt_mutex_lock (&mtx);rt_mutex_unlock (&mtx);/* Keep lockdep happy. */ -return rcu_preempt_ctrlblk.boost_tasks !=NULL || - rcu_preempt_ctrlblk.exp_tasks !=NULL ; +return ACCESS_ONCE (rcu_preempt_ctrlblk.boost_tasks) !=NULL || +ACCESS_ONCE (rcu_preempt_ctrlblk.exp_tasks) !=NULL ; }/*
@@ -885,6 +885,19 @@ static void invoke_rcu_callbacks(void)wake_up (&rcu_kthread_wq); } +#ifdef CONFIG_RCU_TRACE + +/* +* Is the current CPU running the RCU-callbacks kthread? +* Caller must have preemption disabled. +*/ +static bool rcu_is_callbacks_kthread (void ) +{ +return rcu_kthread_task == current; +} + +#endif /* #ifdef CONFIG_RCU_TRACE */ +/* * This kthread invokes RCU callbacks whose grace periods have * elapsed. It is awakened as needed, and takes the place of the
@@ -938,6 +951,18 @@ void invoke_rcu_callbacks(void)raise_softirq (RCU_SOFTIRQ ); } +#ifdef CONFIG_RCU_TRACE + +/* +* There is no callback kthread, so this thread is never it. +*/ +static bool rcu_is_callbacks_kthread (void ) +{ +return false; +} + +#endif /* #ifdef CONFIG_RCU_TRACE */ +void rcu_init (void ) {open_softirq (RCU_SOFTIRQ , rcu_process_callbacks);
kernel/rcutorture.c +218 -7
350 lines not on this page · raw message
kernel/rcutree.c +205 -85
467 lines not on this page · raw message
kernel/rcutree.h +12 -14
@@ -84,9 +84,10 @@* Dynticks per-CPU state. */ struct rcu_dynticks { -int dynticks_nesting;/* Track irq/process nesting level. */ -int dynticks_nmi_nesting;/* Track NMI nesting level. */ -atomic_t dynticks;/* Even value for dynticks-idle, else odd. */ +long long dynticks_nesting;/* Track irq/process nesting level. */ +/* Process level is worth LLONG_MAX/2. */ +int dynticks_nmi_nesting;/* Track NMI nesting level. */ +atomic_t dynticks;/* Even value for idle, else odd. */ };/* RCU's kthread states for tracing. */
@@ -274,16 +275,12 @@ struct rcu_data {/* did other CPU force QS recently? */ long blimit;/* Upper limit on a processed batch */ -#ifdef CONFIG_NO_HZ /* 3) dynticks interface. */ struct rcu_dynticks *dynticks;/* Shared per-CPU dynticks state. */ int dynticks_snap;/* Per-GP tracking for dynticks. */ -#endif /* #ifdef CONFIG_NO_HZ */ /* 4) reasons this CPU needed to be kicked by force_quiescent_state */ -#ifdef CONFIG_NO_HZ unsigned long dynticks_fqs;/* Kicked due to dynticks idle. */ -#endif /* #ifdef CONFIG_NO_HZ */ unsigned long offline_fqs;/* Kicked due to being offline. */ unsigned long resched_ipi;/* Sent a resched IPI. */
@@ -302,16 +299,12 @@ struct rcu_data {struct rcu_state *rsp; }; -/* Values for signaled field in struct rcu_state. */ +/* Values for fqs_state field in struct rcu_state. */ #define RCU_GP_IDLE 0/* No grace period in progress. */ #define RCU_GP_INIT 1/* Grace period being initialized. */ #define RCU_SAVE_DYNTICK 2/* Need to scan dyntick state. */ #define RCU_FORCE_QS 3/* Need to force quiescent state. */ -#ifdef CONFIG_NO_HZ #define RCU_SIGNAL_INIT RCU_SAVE_DYNTICK -#else /* #ifdef CONFIG_NO_HZ */ -#define RCU_SIGNAL_INIT RCU_FORCE_QS -#endif /* #else #ifdef CONFIG_NO_HZ */ #define RCU_JIFFIES_TILL_FORCE_QS 3/* for rsp->jiffies_force_qs */
@@ -361,7 +354,7 @@ struct rcu_state {/* The following fields are guarded by the root rcu_node's lock. */ -u8 signaled____cacheline_internodealigned_in_smp ; +u8 fqs_state____cacheline_internodealigned_in_smp ;/* Force QS state. */ u8 fqs_active;/* force_quiescent_state() */ /* is running. */
@@ -451,7 +444,8 @@ static void rcu_preempt_check_callbacks(int cpu);static void rcu_preempt_process_callbacks (void );void call_rcu (struct rcu_head *head,void (*func)(struct rcu_head *rcu));#if defined(CONFIG_HOTPLUG_CPU ) || defined(CONFIG_TREE_PREEMPT_RCU ) -static void rcu_report_exp_rnp (struct rcu_state *rsp,struct rcu_node *rnp); +static void rcu_report_exp_rnp (struct rcu_state *rsp,struct rcu_node *rnp, +bool wake);#endif /* #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_TREE_PREEMPT_RCU) */ static int rcu_preempt_pending (int cpu);static int rcu_preempt_needs_cpu (int cpu);
@@ -461,6 +455,7 @@ static void __init __rcu_init_preempt(void);static void rcu_initiate_boost (struct rcu_node *rnp,unsigned long flags);static void rcu_preempt_boost_start_gp (struct rcu_node *rnp);static void invoke_rcu_callbacks_kthread (void ); +static bool rcu_is_callbacks_kthread (void );#ifdef CONFIG_RCU_BOOST static void rcu_preempt_do_callbacks (void ); static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp,
@@ -473,5 +468,8 @@ static void rcu_yield(void (*f)(unsigned long), unsigned long arg);#endif /* #ifdef CONFIG_RCU_BOOST */ static void rcu_cpu_kthread_setrt (int cpu,int to_rt);static void __cpuinit rcu_prepare_kthreads (int cpu); +static void rcu_prepare_for_idle_init (int cpu); +static void rcu_cleanup_after_idle (int cpu); +static void rcu_prepare_for_idle (int cpu);#endif /* #ifndef RCU_TREE_NONCORE */
kernel/rcutree_plugin.h +231 -58
415 lines not on this page · raw message
kernel/time/tick-sched.c +60 -37
97 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 8 lines · Ingo Molnar
Linus,
Please pull the latest core-rcu-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitcore-rcu-for-linusThanks,
Hi guys
New lockdep warning here :
[ 850.464548]
[ 850.464550] ===============================
[ 850.464553] [ INFO: suspicious RCU usage. ]
[ 850.464555] 3.3.0-rc1+ #569 Not tainted
[ 850.464557] -------------------------------
[ 850.464559] include/trace/events/power.h:102 suspicious rcu_dereference_check() usage!
[ 850.464562]
[ 850.464562] other info that might help us debug this:
[ 850.464564]
[ 850.464566]
[ 850.464567] rcu_scheduler_active = 1, debug_locks = 1
[ 850.464569] RCU used illegally from extended quiescent state!
[ 850.464571] no locks held by swapper/1/0.
[ 850.464572]
[ 850.464572] stack backtrace:
[ 850.464575] Pid: 0, comm: swapper/1 Not tainted 3.3.0-rc1+ #569
[ 850.464578] Call Trace:
[ 850.464584] [<ffffffff81094a2a>] lockdep_rcu_suspicious+0xca/0xf0
[ 850.464588] [<ffffffff8100abb9>] mwait_idle+0x499/0x4c0
[ 850.464592] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.464597] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3
[ 850.464765] ------------[ cut here ]------------
[ 850.464769] WARNING: at include/linux/rcupdate.h:242 __perf_event_overflow+0x27c/0x2c0()
[ 850.464771] Hardware name: ProLiant BL460c G6
[ 850.464772] Modules linked in: ipmi_devintf nfsd exportfs ipmi_si hpilo bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 850.464783] Pid: 0, comm: swapper/1 Not tainted 3.3.0-rc1+ #569
[ 850.464784] Call Trace:
[ 850.464788] [<ffffffff81038f1f>] warn_slowpath_common+0x7f/0xc0
[ 850.464791] [<ffffffff81038f7a>] warn_slowpath_null+0x1a/0x20
[ 850.464794] [<ffffffff810f8f2c>] __perf_event_overflow+0x27c/0x2c0
[ 850.464797] [<ffffffff8177126e>] ? printk+0x41/0x43
[ 850.464801] [<ffffffff810a1ff6>] ? __module_text_address+0x16/0x80
[ 850.464804] [<ffffffff810f9019>] perf_swevent_overflow+0xa9/0xc0
[ 850.464806] [<ffffffff810f909f>] perf_swevent_event+0x6f/0x90
[ 850.464809] [<ffffffff810f9136>] perf_tp_event+0x76/0xf0
[ 850.464813] [<ffffffff810f153e>] perf_trace_power+0xbe/0xe0
[ 850.464816] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 850.464818] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 850.464821] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.464824] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3
[ 850.464826] ---[ end trace d3b6df8c2cde8681 ]---
[ 850.464828] ------------[ cut here ]------------
[ 850.464831] WARNING: at include/linux/rcupdate.h:242 perf_output_begin+0x2f6/0x330()
[ 850.464832] Hardware name: ProLiant BL460c G6
[ 850.464833] Modules linked in: ipmi_devintf nfsd exportfs ipmi_si hpilo bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 850.464842] Pid: 0, comm: swapper/1 Tainted: G W 3.3.0-rc1+ #569
[ 850.464844] Call Trace:
[ 850.464846] [<ffffffff81038f1f>] warn_slowpath_common+0x7f/0xc0
[ 850.464849] [<ffffffff81038f7a>] warn_slowpath_null+0x1a/0x20
[ 850.464852] [<ffffffff810fc2f6>] perf_output_begin+0x2f6/0x330
[ 850.464855] [<ffffffff810769e5>] ? sched_clock_cpu+0xc5/0x120
[ 850.464858] [<ffffffff8109378d>] ? trace_hardirqs_off+0xd/0x10
[ 850.464860] [<ffffffff81076a8f>] ? local_clock+0x4f/0x60
[ 850.464863] [<ffffffff810f223d>] ? __perf_event_header__init_id+0xad/0xf0
[ 850.464866] [<ffffffff810f8c03>] ? perf_prepare_sample+0x63/0x110
[ 850.464869] [<ffffffff810f8e3d>] __perf_event_overflow+0x18d/0x2c0
[ 850.464871] [<ffffffff810f8df5>] ? __perf_event_overflow+0x145/0x2c0
[ 850.464874] [<ffffffff8177126e>] ? printk+0x41/0x43
[ 850.464876] [<ffffffff810f9019>] perf_swevent_overflow+0xa9/0xc0
[ 850.464879] [<ffffffff810f909f>] perf_swevent_event+0x6f/0x90
[ 850.464881] [<ffffffff810f9136>] perf_tp_event+0x76/0xf0
[ 850.464884] [<ffffffff810f153e>] perf_trace_power+0xbe/0xe0
[ 850.464887] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 850.464890] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 850.464893] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.464895] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3
[ 850.464897] ---[ end trace d3b6df8c2cde8682 ]---
[ 850.464899]
[ 850.464900] ===============================
[ 850.464901] [ INFO: suspicious RCU usage. ]
[ 850.464902] 3.3.0-rc1+ #569 Tainted: G W
[ 850.464904] -------------------------------
[ 850.464905] kernel/events/ring_buffer.c:120 suspicious rcu_dereference_check() usage!
[ 850.464907]
[ 850.464907] other info that might help us debug this:
[ 850.464908]
[ 850.464909]
[ 850.464910] rcu_scheduler_active = 1, debug_locks = 1
[ 850.464911] RCU used illegally from extended quiescent state!
[ 850.464913] 2 locks held by swapper/1/0:
[ 850.464914] #0: (rcu_read_lock){.+.+..}, at: [<ffffffff810f8df5>] __perf_event_overflow+0x145/0x2c0
[ 850.464920] #1: (rcu_read_lock){.+.+..}, at: [<ffffffff810fc03f>] perf_output_begin+0x3f/0x330
[ 850.464924]
[ 850.464925] stack backtrace:
[ 850.464927] Pid: 0, comm: swapper/1 Tainted: G W 3.3.0-rc1+ #569
[ 850.464928] Call Trace:
[ 850.464931] [<ffffffff81094a2a>] lockdep_rcu_suspicious+0xca/0xf0
[ 850.464933] [<ffffffff810fc268>] perf_output_begin+0x268/0x330
[ 850.464936] [<ffffffff810fc03f>] ? perf_output_begin+0x3f/0x330
[ 850.464938] [<ffffffff810769e5>] ? sched_clock_cpu+0xc5/0x120
[ 850.464941] [<ffffffff8109378d>] ? trace_hardirqs_off+0xd/0x10
[ 850.464943] [<ffffffff81076a8f>] ? local_clock+0x4f/0x60
[ 850.464946] [<ffffffff810f223d>] ? __perf_event_header__init_id+0xad/0xf0
[ 850.464949] [<ffffffff810f8c03>] ? perf_prepare_sample+0x63/0x110
[ 850.464952] [<ffffffff810f8e3d>] __perf_event_overflow+0x18d/0x2c0
[ 850.464954] [<ffffffff810f8df5>] ? __perf_event_overflow+0x145/0x2c0
[ 850.464957] [<ffffffff8177126e>] ? printk+0x41/0x43
[ 850.464959] [<ffffffff810f9019>] perf_swevent_overflow+0xa9/0xc0
[ 850.464962] [<ffffffff810f909f>] perf_swevent_event+0x6f/0x90
[ 850.464964] [<ffffffff810f9136>] perf_tp_event+0x76/0xf0
[ 850.464967] [<ffffffff810f153e>] perf_trace_power+0xbe/0xe0
[ 850.464970] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 850.464973] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 850.464975] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.464978] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3
[ 850.464980] ------------[ cut here ]------------
[ 850.464983] WARNING: at include/linux/rcupdate.h:248 perf_output_end+0x5b/0x70()
[ 850.464984] Hardware name: ProLiant BL460c G6
[ 850.464985] Modules linked in: ipmi_devintf nfsd exportfs ipmi_si hpilo bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 850.464994] Pid: 0, comm: swapper/1 Tainted: G W 3.3.0-rc1+ #569
[ 850.464995] Call Trace:
[ 850.464998] [<ffffffff81038f1f>] warn_slowpath_common+0x7f/0xc0
[ 850.465001] [<ffffffff81038f7a>] warn_slowpath_null+0x1a/0x20
[ 850.465003] [<ffffffff810fc38b>] perf_output_end+0x5b/0x70
[ 850.465006] [<ffffffff810f8edc>] __perf_event_overflow+0x22c/0x2c0
[ 850.465008] [<ffffffff810f8df5>] ? __perf_event_overflow+0x145/0x2c0
[ 850.465011] [<ffffffff810f9019>] perf_swevent_overflow+0xa9/0xc0
[ 850.465014] [<ffffffff810f909f>] perf_swevent_event+0x6f/0x90
[ 850.465016] [<ffffffff810f9136>] perf_tp_event+0x76/0xf0
[ 850.465019] [<ffffffff810f153e>] perf_trace_power+0xbe/0xe0
[ 850.465022] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 850.465025] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 850.465027] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.465030] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3
[ 850.465032] ---[ end trace d3b6df8c2cde8683 ]---
[ 850.465033] ------------[ cut here ]------------
[ 850.465036] WARNING: at include/linux/rcupdate.h:248 __perf_event_overflow+0x2a6/0x2c0()
[ 850.465037] Hardware name: ProLiant BL460c G6
[ 850.465038] Modules linked in: ipmi_devintf nfsd exportfs ipmi_si hpilo bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 850.465047] Pid: 0, comm: swapper/1 Tainted: G W 3.3.0-rc1+ #569
[ 850.465048] Call Trace:
[ 850.465051] [<ffffffff81038f1f>] warn_slowpath_common+0x7f/0xc0
[ 850.465054] [<ffffffff81038f7a>] warn_slowpath_null+0x1a/0x20
[ 850.465056] [<ffffffff810f8f56>] __perf_event_overflow+0x2a6/0x2c0
[ 850.465059] [<ffffffff810f8df5>] ? __perf_event_overflow+0x145/0x2c0
[ 850.465061] [<ffffffff810f9019>] perf_swevent_overflow+0xa9/0xc0
[ 850.465064] [<ffffffff810f909f>] perf_swevent_event+0x6f/0x90
[ 850.465066] [<ffffffff810f9136>] perf_tp_event+0x76/0xf0
[ 850.465069] [<ffffffff810f153e>] perf_trace_power+0xbe/0xe0
[ 850.465072] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 850.465075] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 850.465077] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.465080] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3
[ 850.465082] ---[ end trace d3b6df8c2cde8684 ]---
[ 850.467615]
[ 850.467617] ===============================
[ 850.467619] [ INFO: suspicious RCU usage. ]
[ 850.467621] 3.3.0-rc1+ #569 Tainted: G W
[ 850.467624] -------------------------------
[ 850.467626] include/trace/events/power.h:127 suspicious rcu_dereference_check() usage!
[ 850.467629]
[ 850.467629] other info that might help us debug this:
[ 850.467630]
[ 850.467632]
[ 850.467632] rcu_scheduler_active = 1, debug_locks = 1
[ 850.467634] RCU used illegally from extended quiescent state!
[ 850.467636] no locks held by swapper/1/0.
[ 850.467637]
[ 850.467638] stack backtrace:
[ 850.467640] Pid: 0, comm: swapper/1 Tainted: G W 3.3.0-rc1+ #569
[ 850.467642] Call Trace:
[ 850.467646] [<ffffffff81094a2a>] lockdep_rcu_suspicious+0xca/0xf0
[ 850.467650] [<ffffffff8100a9cd>] mwait_idle+0x2ad/0x4c0
[ 850.467653] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.467656] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3Quoted 5 lines · Eric Dumazet
Quoted 4 lines · Ingo Molnar
Linus,
Please pull the latest core-rcu-for-linus git tree from:
Quoted 7 lines
Quoted 3 lines
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitcore-rcu-for-linusThanks,
Hi guys
New lockdep warning here :
Hmmm... Looks like tracing from within the inner idle loop.
Because RCU ignores CPUs in the inner idle loop (after the call to rcu_idle_enter()), RCU read-side critical sections are not legal there.
One approach would be to delay the call to rcu_idle_enter() until after the tracing is done, and to ensure that the call to rcu_idle_exit() happens before any tracing. I am not seeing perf_trace_power(), so need to update and look again. Or are you looking at -next rather than mainline?
Thanx, Paul
Quoted 167 lines
[ 850.464548]
[ 850.464550] ===============================
[ 850.464553] [ INFO: suspicious RCU usage. ]
[ 850.464555] 3.3.0-rc1+ #569 Not tainted
[ 850.464557] -------------------------------
[ 850.464559] include/trace/events/power.h:102 suspicious rcu_dereference_check() usage!
[ 850.464562]
[ 850.464562] other info that might help us debug this:
[ 850.464564]
[ 850.464566]
[ 850.464567] rcu_scheduler_active = 1, debug_locks = 1
[ 850.464569] RCU used illegally from extended quiescent state!
[ 850.464571] no locks held by swapper/1/0.
[ 850.464572]
[ 850.464572] stack backtrace:
[ 850.464575] Pid: 0, comm: swapper/1 Not tainted 3.3.0-rc1+ #569
[ 850.464578] Call Trace:
[ 850.464584] [<ffffffff81094a2a>] lockdep_rcu_suspicious+0xca/0xf0
[ 850.464588] [<ffffffff8100abb9>] mwait_idle+0x499/0x4c0
[ 850.464592] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.464597] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3
[ 850.464765] ------------[ cut here ]------------
[ 850.464769] WARNING: at include/linux/rcupdate.h:242 __perf_event_overflow+0x27c/0x2c0()
[ 850.464771] Hardware name: ProLiant BL460c G6
[ 850.464772] Modules linked in: ipmi_devintf nfsd exportfs ipmi_si hpilo bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 850.464783] Pid: 0, comm: swapper/1 Not tainted 3.3.0-rc1+ #569
[ 850.464784] Call Trace:
[ 850.464788] [<ffffffff81038f1f>] warn_slowpath_common+0x7f/0xc0
[ 850.464791] [<ffffffff81038f7a>] warn_slowpath_null+0x1a/0x20
[ 850.464794] [<ffffffff810f8f2c>] __perf_event_overflow+0x27c/0x2c0
[ 850.464797] [<ffffffff8177126e>] ? printk+0x41/0x43
[ 850.464801] [<ffffffff810a1ff6>] ? __module_text_address+0x16/0x80
[ 850.464804] [<ffffffff810f9019>] perf_swevent_overflow+0xa9/0xc0
[ 850.464806] [<ffffffff810f909f>] perf_swevent_event+0x6f/0x90
[ 850.464809] [<ffffffff810f9136>] perf_tp_event+0x76/0xf0
[ 850.464813] [<ffffffff810f153e>] perf_trace_power+0xbe/0xe0
[ 850.464816] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 850.464818] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 850.464821] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.464824] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3
[ 850.464826] ---[ end trace d3b6df8c2cde8681 ]---
[ 850.464828] ------------[ cut here ]------------
[ 850.464831] WARNING: at include/linux/rcupdate.h:242 perf_output_begin+0x2f6/0x330()
[ 850.464832] Hardware name: ProLiant BL460c G6
[ 850.464833] Modules linked in: ipmi_devintf nfsd exportfs ipmi_si hpilo bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 850.464842] Pid: 0, comm: swapper/1 Tainted: G W 3.3.0-rc1+ #569
[ 850.464844] Call Trace:
[ 850.464846] [<ffffffff81038f1f>] warn_slowpath_common+0x7f/0xc0
[ 850.464849] [<ffffffff81038f7a>] warn_slowpath_null+0x1a/0x20
[ 850.464852] [<ffffffff810fc2f6>] perf_output_begin+0x2f6/0x330
[ 850.464855] [<ffffffff810769e5>] ? sched_clock_cpu+0xc5/0x120
[ 850.464858] [<ffffffff8109378d>] ? trace_hardirqs_off+0xd/0x10
[ 850.464860] [<ffffffff81076a8f>] ? local_clock+0x4f/0x60
[ 850.464863] [<ffffffff810f223d>] ? __perf_event_header__init_id+0xad/0xf0
[ 850.464866] [<ffffffff810f8c03>] ? perf_prepare_sample+0x63/0x110
[ 850.464869] [<ffffffff810f8e3d>] __perf_event_overflow+0x18d/0x2c0
[ 850.464871] [<ffffffff810f8df5>] ? __perf_event_overflow+0x145/0x2c0
[ 850.464874] [<ffffffff8177126e>] ? printk+0x41/0x43
[ 850.464876] [<ffffffff810f9019>] perf_swevent_overflow+0xa9/0xc0
[ 850.464879] [<ffffffff810f909f>] perf_swevent_event+0x6f/0x90
[ 850.464881] [<ffffffff810f9136>] perf_tp_event+0x76/0xf0
[ 850.464884] [<ffffffff810f153e>] perf_trace_power+0xbe/0xe0
[ 850.464887] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 850.464890] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 850.464893] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.464895] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3
[ 850.464897] ---[ end trace d3b6df8c2cde8682 ]---
[ 850.464899]
[ 850.464900] ===============================
[ 850.464901] [ INFO: suspicious RCU usage. ]
[ 850.464902] 3.3.0-rc1+ #569 Tainted: G W
[ 850.464904] -------------------------------
[ 850.464905] kernel/events/ring_buffer.c:120 suspicious rcu_dereference_check() usage!
[ 850.464907]
[ 850.464907] other info that might help us debug this:
[ 850.464908]
[ 850.464909]
[ 850.464910] rcu_scheduler_active = 1, debug_locks = 1
[ 850.464911] RCU used illegally from extended quiescent state!
[ 850.464913] 2 locks held by swapper/1/0:
[ 850.464914] #0: (rcu_read_lock){.+.+..}, at: [<ffffffff810f8df5>] __perf_event_overflow+0x145/0x2c0
[ 850.464920] #1: (rcu_read_lock){.+.+..}, at: [<ffffffff810fc03f>] perf_output_begin+0x3f/0x330
[ 850.464924]
[ 850.464925] stack backtrace:
[ 850.464927] Pid: 0, comm: swapper/1 Tainted: G W 3.3.0-rc1+ #569
[ 850.464928] Call Trace:
[ 850.464931] [<ffffffff81094a2a>] lockdep_rcu_suspicious+0xca/0xf0
[ 850.464933] [<ffffffff810fc268>] perf_output_begin+0x268/0x330
[ 850.464936] [<ffffffff810fc03f>] ? perf_output_begin+0x3f/0x330
[ 850.464938] [<ffffffff810769e5>] ? sched_clock_cpu+0xc5/0x120
[ 850.464941] [<ffffffff8109378d>] ? trace_hardirqs_off+0xd/0x10
[ 850.464943] [<ffffffff81076a8f>] ? local_clock+0x4f/0x60
[ 850.464946] [<ffffffff810f223d>] ? __perf_event_header__init_id+0xad/0xf0
[ 850.464949] [<ffffffff810f8c03>] ? perf_prepare_sample+0x63/0x110
[ 850.464952] [<ffffffff810f8e3d>] __perf_event_overflow+0x18d/0x2c0
[ 850.464954] [<ffffffff810f8df5>] ? __perf_event_overflow+0x145/0x2c0
[ 850.464957] [<ffffffff8177126e>] ? printk+0x41/0x43
[ 850.464959] [<ffffffff810f9019>] perf_swevent_overflow+0xa9/0xc0
[ 850.464962] [<ffffffff810f909f>] perf_swevent_event+0x6f/0x90
[ 850.464964] [<ffffffff810f9136>] perf_tp_event+0x76/0xf0
[ 850.464967] [<ffffffff810f153e>] perf_trace_power+0xbe/0xe0
[ 850.464970] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 850.464973] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 850.464975] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.464978] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3
[ 850.464980] ------------[ cut here ]------------
[ 850.464983] WARNING: at include/linux/rcupdate.h:248 perf_output_end+0x5b/0x70()
[ 850.464984] Hardware name: ProLiant BL460c G6
[ 850.464985] Modules linked in: ipmi_devintf nfsd exportfs ipmi_si hpilo bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 850.464994] Pid: 0, comm: swapper/1 Tainted: G W 3.3.0-rc1+ #569
[ 850.464995] Call Trace:
[ 850.464998] [<ffffffff81038f1f>] warn_slowpath_common+0x7f/0xc0
[ 850.465001] [<ffffffff81038f7a>] warn_slowpath_null+0x1a/0x20
[ 850.465003] [<ffffffff810fc38b>] perf_output_end+0x5b/0x70
[ 850.465006] [<ffffffff810f8edc>] __perf_event_overflow+0x22c/0x2c0
[ 850.465008] [<ffffffff810f8df5>] ? __perf_event_overflow+0x145/0x2c0
[ 850.465011] [<ffffffff810f9019>] perf_swevent_overflow+0xa9/0xc0
[ 850.465014] [<ffffffff810f909f>] perf_swevent_event+0x6f/0x90
[ 850.465016] [<ffffffff810f9136>] perf_tp_event+0x76/0xf0
[ 850.465019] [<ffffffff810f153e>] perf_trace_power+0xbe/0xe0
[ 850.465022] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 850.465025] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 850.465027] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.465030] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3
[ 850.465032] ---[ end trace d3b6df8c2cde8683 ]---
[ 850.465033] ------------[ cut here ]------------
[ 850.465036] WARNING: at include/linux/rcupdate.h:248 __perf_event_overflow+0x2a6/0x2c0()
[ 850.465037] Hardware name: ProLiant BL460c G6
[ 850.465038] Modules linked in: ipmi_devintf nfsd exportfs ipmi_si hpilo bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 850.465047] Pid: 0, comm: swapper/1 Tainted: G W 3.3.0-rc1+ #569
[ 850.465048] Call Trace:
[ 850.465051] [<ffffffff81038f1f>] warn_slowpath_common+0x7f/0xc0
[ 850.465054] [<ffffffff81038f7a>] warn_slowpath_null+0x1a/0x20
[ 850.465056] [<ffffffff810f8f56>] __perf_event_overflow+0x2a6/0x2c0
[ 850.465059] [<ffffffff810f8df5>] ? __perf_event_overflow+0x145/0x2c0
[ 850.465061] [<ffffffff810f9019>] perf_swevent_overflow+0xa9/0xc0
[ 850.465064] [<ffffffff810f909f>] perf_swevent_event+0x6f/0x90
[ 850.465066] [<ffffffff810f9136>] perf_tp_event+0x76/0xf0
[ 850.465069] [<ffffffff810f153e>] perf_trace_power+0xbe/0xe0
[ 850.465072] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 850.465075] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 850.465077] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.465080] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3
[ 850.465082] ---[ end trace d3b6df8c2cde8684 ]---
[ 850.467615]
[ 850.467617] ===============================
[ 850.467619] [ INFO: suspicious RCU usage. ]
[ 850.467621] 3.3.0-rc1+ #569 Tainted: G W
[ 850.467624] -------------------------------
[ 850.467626] include/trace/events/power.h:127 suspicious rcu_dereference_check() usage!
[ 850.467629]
[ 850.467629] other info that might help us debug this:
[ 850.467630]
[ 850.467632]
[ 850.467632] rcu_scheduler_active = 1, debug_locks = 1
[ 850.467634] RCU used illegally from extended quiescent state!
[ 850.467636] no locks held by swapper/1/0.
[ 850.467637]
[ 850.467638] stack backtrace:
[ 850.467640] Pid: 0, comm: swapper/1 Tainted: G W 3.3.0-rc1+ #569
[ 850.467642] Call Trace:
[ 850.467646] [<ffffffff81094a2a>] lockdep_rcu_suspicious+0xca/0xf0
[ 850.467650] [<ffffffff8100a9cd>] mwait_idle+0x2ad/0x4c0
[ 850.467653] [<ffffffff810011e6>] cpu_idle+0x96/0xe0
[ 850.467656] [<ffffffff8176bbae>] start_secondary+0x1df/0x1e3Quoted 16 lines · Paul E. McKenney
Quoted 5 lines · Eric Dumazet
Quoted 4 lines · Ingo Molnar
Linus,
Please pull the latest core-rcu-for-linus git tree from:
Quoted 7 lines
Quoted 3 lines
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitcore-rcu-for-linusThanks,
Hi guys
New lockdep warning here :
Hmmm... Looks like tracing from within the inner idle loop.
Quoted 7 lines
Because RCU ignores CPUs in the inner idle loop (after the call to
rcu_idle_enter()), RCU read-side critical sections are not legal there.One approach would be to delay the call to
rcu_idle_enter()until after the tracing is done, and to ensure that the call torcu_idle_exit()happens before any tracing. I am not seeingperf_trace_power(), so need to update and look again. Or are you looking at -next rather than mainline?
perf_trace_power() is automatically generated by include/trace/ftrace.h This is a tracepoint handler so we don't need to worry about it. The problem is the call to the tracepoint itself.
Quoted 16 lines · Paul E. McKenney
Quoted 5 lines · Eric Dumazet
Quoted 4 lines · Ingo Molnar
Linus,
Please pull the latest core-rcu-for-linus git tree from:
Quoted 7 lines
Quoted 3 lines
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitcore-rcu-for-linusThanks,
Hi guys
New lockdep warning here :
Hmmm... Looks like tracing from within the inner idle loop.
Quoted 8 lines
Because RCU ignores CPUs in the inner idle loop (after the call to
rcu_idle_enter()), RCU read-side critical sections are not legal there.One approach would be to delay the call to
rcu_idle_enter()until after the tracing is done, and to ensure that the call torcu_idle_exit()happens before any tracing. I am not seeingperf_trace_power(), so need to update and look again. Or are you looking at -next rather than mainline?
I am using mainline, not -next
It seems "powertop" triggers the warnings.
Check include/trace/events/power.h line 75 :
DECLARE_EVENT_CLASS(power,
This declares perf_trace_power()...
include/trace/ftrace.h line 718
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
static notrace void \
perf_trace_##call(void *__data, proto) ...
Thanks
Quoted 20 lines · Frederic Weisbecker
Quoted 19 lines · Paul E. McKenney
Quoted 5 lines · Eric Dumazet
Quoted 4 lines · Ingo Molnar
Linus,
Please pull the latest core-rcu-for-linus git tree from:
Quoted 7 lines
Quoted 3 lines
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitcore-rcu-for-linusThanks,
Hi guys
New lockdep warning here :
Hmmm... Looks like tracing from within the inner idle loop.
Because RCU ignores CPUs in the inner idle loop (after the call to
rcu_idle_enter()), RCU read-side critical sections are not legal there.
Quoted 8 lines
Quoted 4 lines
One approach would be to delay the call to
rcu_idle_enter()until after the tracing is done, and to ensure that the call torcu_idle_exit()happens before any tracing. I am not seeingperf_trace_power(), so need to update and look again. Or are you looking at -next rather than mainline?
perf_trace_power()is automatically generated byinclude/trace/ftrace.hThis is a tracepoint handler so we don't need to worry about it. The problem is the call to the tracepoint itself.
Agreed. I was just naively expecting "git grep perf_trace_power" to show me the call points. :-(
Thanx, Paul
Quoted 34 lines · Eric Dumazet
Quoted 16 lines · Paul E. McKenney
Quoted 5 lines · Eric Dumazet
Quoted 4 lines · Ingo Molnar
Linus,
Please pull the latest core-rcu-for-linus git tree from:
Quoted 7 lines
Quoted 3 lines
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitcore-rcu-for-linusThanks,
Hi guys
New lockdep warning here :
Hmmm... Looks like tracing from within the inner idle loop.
Quoted 8 lines
Because RCU ignores CPUs in the inner idle loop (after the call to
rcu_idle_enter()), RCU read-side critical sections are not legal there.One approach would be to delay the call to
rcu_idle_enter()until after the tracing is done, and to ensure that the call torcu_idle_exit()happens before any tracing. I am not seeingperf_trace_power(), so need to update and look again. Or are you looking at -next rather than mainline?I am using mainline, not -next
It seems "powertop" triggers the warnings.
Check
include/trace/events/power.hline 75 :DECLARE_EVENT_CLASS(power,
Quoted 7 lines
This declares
perf_trace_power()...
include/trace/ftrace.hline 718#define
DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)\
static notrace void \
perf_trace_##call(void*__data, proto) ...
Thank you for the info!
Now I just need to find the call point.
Ah, I see... I need to find one of trace_power_start(), trace_power_frequency(), or trace_power_end(). I would have to guess that this is either the trace_power_start() or the trace_power_end() called from drivers/cpuidle/cpuidle.c lines 97 and 102. Those are within cpuidle_idle_call(), which are called from cpu_idle() in arch/x86/kernel/process_32.c and arch/x86/kernel/process_64.c, so this sounds plausible.
And they are indeed busted -- RCU believes the CPU is idle at the point that cpuidle_idle_call() is invoked.
A hacky patch is below. Here are some of my concerns with it:
1. Is there a configuration in which the scheduler clock gets
turned off, but in which cpuidle_idle_call() always returns zero? If so, we either really need RCU to consider the entire inner loop to be idle (thus needing to snapshot the value of cpuidle_idle_call() in the outer loop) or we need explicit calls to rcu_sched_qs() and friends.
Yes, we could momentarily exit RCU idleness mode, but I would need to think that one through...
2. I am not totally confident that I have the order of operations
surrounding the call to pm_idle() correct.
3. This only addresses x86, and it looks like a few other architectures
have this same problem.
4. Probably other things that I haven't thought of.
That said, the patch does seem to compile, at least on my 32-bit laptop...
Thanx, Paul
------------------------------------------------------------------------
idle: Avoid using RCU when RCU thinks the CPU is idle
The x86 idle loops invoke cpuidle_idle_call() which uses tracing which uses RCU. Unfortunately, these idle loops have already told RCU to ignore this CPU when they call it. This patch hacks the idle loops to avoid this problem, but probably causing several other problems in the process.
---
arch/x86/kernel/process_32.c +6 -3
@@ -84,6 +84,8 @@ static inline void play_dead(void)*/ void cpu_idle (void ) { +bool pm_idle_ok; +int cpu =smp_processor_id ();/*
@@ -100,7 +102,6 @@ void cpu_idle(void)/* endless idle loop with no priority at all */ while (1 ) {tick_nohz_idle_enter (); -rcu_idle_enter ();while (!need_resched ()) {check_pgt_cache ();
@@ -113,11 +114,13 @@ void cpu_idle(void)local_irq_disable ();/* Don't trace irqs off for idle */ stop_critical_timings (); -if (cpuidle_idle_call ()) + pm_idle_ok =cpuidle_idle_call (); +rcu_idle_enter (); +if (pm_idle_ok)pm_idle (); +rcu_idle_exit ();start_critical_timings (); } -rcu_idle_exit ();tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();
arch/x86/kernel/process_64.c +9 -2
@@ -109,6 +109,8 @@ static inline void play_dead(void)*/ void cpu_idle (void ) { +bool pm_idle_ok; +current_thread_info ()->status |=TS_POLLING ;/*
@@ -140,10 +142,15 @@ void cpu_idle(void)/* Don't trace irqs off for idle */ stop_critical_timings (); -/* enter_idle() needs rcu for notifiers */ + pm_idle_ok =cpuidle_idle_call (); + +/* +* Both enter_idle() and cpuidle_idle_call() need +* RCU for notifiers +*/ rcu_idle_enter (); -if (cpuidle_idle_call ()) +if (pm_idle_ok)pm_idle ();rcu_idle_exit ();
Quoted 40 lines · Paul E. McKenney
Ah, I see... I need to find one of
trace_power_start(),trace_power_frequency(), ortrace_power_end(). I would have to guess that this is either thetrace_power_start()or thetrace_power_end()called fromdrivers/cpuidle/cpuidle.clines 97 and 102. Those are withincpuidle_idle_call(), which are called fromcpu_idle()inarch/x86/kernel/process_32.candarch/x86/kernel/process_64.c, so this sounds plausible.And they are indeed busted -- RCU believes the CPU is idle at the point that
cpuidle_idle_call()is invoked.A hacky patch is below. Here are some of my concerns with it:
1. Is there a configuration in which the scheduler clock gets
turned off, but in whichcpuidle_idle_call()always returns zero? If so, we either really need RCU to consider the entire inner loop to be idle (thus needing to snapshot the value ofcpuidle_idle_call()in the outer loop) or we need explicit calls torcu_sched_qs()and friends.Yes, we could momentarily exit RCU idleness mode, but I would need to think that one through...
2. I am not totally confident that I have the order of operations
surrounding the call topm_idle()correct.3. This only addresses x86, and it looks like a few other architectures
have this same problem.4. Probably other things that I haven't thought of.
That said, the patch does seem to compile, at least on my 32-bit laptop...
Thanx, Paul
------------------------------------------------------------------------
idle: Avoid using RCU when RCU thinks the CPU is idle
Quoted 8 lines
The x86 idle loops invoke
cpuidle_idle_call()which uses tracing which uses RCU. Unfortunately, these idle loops have already told RCU to ignore this CPU when they call it. This patch hacks the idle loops to avoid this problem, but probably causing several other problems in the process.Not-yet-signed-off-by Paul E. McKenney <[email protected]>---
Hi Paul
Just tested it on my x86_64 machine, but warnings are still here
Thanks !
[ 61.111559]
[ 61.111563] ===============================
[ 61.111565] [ INFO: suspicious RCU usage. ]
[ 61.111567] 3.3.0-rc1+ #572 Not tainted
[ 61.111569] -------------------------------
[ 61.111571] include/trace/events/power.h:102 suspicious rcu_dereference_check() usage!
[ 61.111573]
[ 61.111574] other info that might help us debug this:
[ 61.111575]
[ 61.111577]
[ 61.111577] rcu_scheduler_active = 1, debug_locks = 1
[ 61.111579] RCU used illegally from extended quiescent state!
[ 61.111582] no locks held by swapper/0/0.
[ 61.111583]
[ 61.111584] stack backtrace:
[ 61.111587] Pid: 0, comm: swapper/0 Not tainted 3.3.0-rc1+ #572
[ 61.111589] Call Trace:
[ 61.111598] [<ffffffff810949ba>] lockdep_rcu_suspicious+0xca/0xf0
[ 61.111604] [<ffffffff8100abb9>] mwait_idle+0x499/0x4c0
[ 61.111609] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.111615] [<ffffffff8174f49f>] rest_init+0x133/0x144
[ 61.111618] [<ffffffff8174f3e5>] ? rest_init+0x79/0x144
[ 61.111623] [<ffffffff81cc2b51>] start_kernel+0x35b/0x366
[ 61.111627] [<ffffffff81cc2321>] x86_64_start_reservations+0x131/0x135
[ 61.111631] [<ffffffff81cc2415>] x86_64_start_kernel+0xf0/0xf7
[ 61.111743] ------------[ cut here ]------------
[ 61.111750] WARNING: at include/linux/rcupdate.h:242 __perf_event_overflow+0x27c/0x2c0()
[ 61.111754] Hardware name: ProLiant BL460c G6
[ 61.111756] Modules linked in: ipmi_devintf nfsd exportfs hpilo ipmi_si bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 61.111770] Pid: 0, comm: swapper/0 Not tainted 3.3.0-rc1+ #572
[ 61.111772] Call Trace:
[ 61.111777] [<ffffffff81038eaf>] warn_slowpath_common+0x7f/0xc0
[ 61.111781] [<ffffffff81038f0a>] warn_slowpath_null+0x1a/0x20
[ 61.111784] [<ffffffff810f8ebc>] __perf_event_overflow+0x27c/0x2c0
[ 61.111788] [<ffffffff817711ae>] ? printk+0x41/0x43
[ 61.111794] [<ffffffff810a1f86>] ? __module_text_address+0x16/0x80
[ 61.111798] [<ffffffff810f8fa9>] perf_swevent_overflow+0xa9/0xc0
[ 61.111801] [<ffffffff810f902f>] perf_swevent_event+0x6f/0x90
[ 61.111804] [<ffffffff810f90c6>] perf_tp_event+0x76/0xf0
[ 61.111809] [<ffffffff810f14ce>] perf_trace_power+0xbe/0xe0
[ 61.111812] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 61.111815] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 61.111819] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.111822] [<ffffffff8174f49f>] rest_init+0x133/0x144
[ 61.111825] [<ffffffff8174f3e5>] ? rest_init+0x79/0x144
[ 61.111828] [<ffffffff81cc2b51>] start_kernel+0x35b/0x366
[ 61.111831] [<ffffffff81cc2321>] x86_64_start_reservations+0x131/0x135
[ 61.111834] [<ffffffff81cc2415>] x86_64_start_kernel+0xf0/0xf7
[ 61.111837] ---[ end trace 18a36211154afbbb ]---
[ 61.111839] ------------[ cut here ]------------
[ 61.111843] WARNING: at include/linux/rcupdate.h:242 perf_output_begin+0x2f6/0x330()
[ 61.111845] Hardware name: ProLiant BL460c G6
[ 61.111848] Modules linked in: ipmi_devintf nfsd exportfs hpilo ipmi_si bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 61.111859] Pid: 0, comm: swapper/0 Tainted: G W 3.3.0-rc1+ #572
[ 61.111861] Call Trace:
[ 61.111864] [<ffffffff81038eaf>] warn_slowpath_common+0x7f/0xc0
[ 61.111868] [<ffffffff81038f0a>] warn_slowpath_null+0x1a/0x20
[ 61.111871] [<ffffffff810fc286>] perf_output_begin+0x2f6/0x330
[ 61.111875] [<ffffffff81076975>] ? sched_clock_cpu+0xc5/0x120
[ 61.111879] [<ffffffff8109371d>] ? trace_hardirqs_off+0xd/0x10
[ 61.111882] [<ffffffff81076a1f>] ? local_clock+0x4f/0x60
[ 61.111886] [<ffffffff810f21cd>] ? __perf_event_header__init_id+0xad/0xf0
[ 61.111889] [<ffffffff810f8b93>] ? perf_prepare_sample+0x63/0x110
[ 61.111892] [<ffffffff810f8dcd>] __perf_event_overflow+0x18d/0x2c0
[ 61.111895] [<ffffffff810f8d85>] ? __perf_event_overflow+0x145/0x2c0
[ 61.111898] [<ffffffff817711ae>] ? printk+0x41/0x43
[ 61.111901] [<ffffffff810f8fa9>] perf_swevent_overflow+0xa9/0xc0
[ 61.111904] [<ffffffff810f902f>] perf_swevent_event+0x6f/0x90
[ 61.111907] [<ffffffff810f90c6>] perf_tp_event+0x76/0xf0
[ 61.111911] [<ffffffff810f14ce>] perf_trace_power+0xbe/0xe0
[ 61.111915] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 61.111918] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 61.111922] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.111926] [<ffffffff8174f49f>] rest_init+0x133/0x144
[ 61.111929] [<ffffffff8174f3e5>] ? rest_init+0x79/0x144
[ 61.111933] [<ffffffff81cc2b51>] start_kernel+0x35b/0x366
[ 61.111937] [<ffffffff81cc2321>] x86_64_start_reservations+0x131/0x135
[ 61.111940] [<ffffffff81cc2415>] x86_64_start_kernel+0xf0/0xf7
[ 61.111943] ---[ end trace 18a36211154afbbc ]---
[ 61.111946]
[ 61.111947] ===============================
[ 61.111949] [ INFO: suspicious RCU usage. ]
[ 61.111950] 3.3.0-rc1+ #572 Tainted: G W
[ 61.111952] -------------------------------
[ 61.111954] kernel/events/ring_buffer.c:120 suspicious rcu_dereference_check() usage!
[ 61.111956]
[ 61.111957] other info that might help us debug this:
[ 61.111958]
[ 61.111960]
[ 61.111960] rcu_scheduler_active = 1, debug_locks = 1
[ 61.111962] RCU used illegally from extended quiescent state!
[ 61.111964] 2 locks held by swapper/0/0:
[ 61.111966] #0: (rcu_read_lock){.+.+..}, at: [<ffffffff810f8d85>] __perf_event_overflow+0x145/0x2c0
[ 61.111974] #1: (rcu_read_lock){.+.+..}, at: [<ffffffff810fbfcf>] perf_output_begin+0x3f/0x330
[ 61.111980]
[ 61.111980] stack backtrace:
[ 61.111982] Pid: 0, comm: swapper/0 Tainted: G W 3.3.0-rc1+ #572
[ 61.111984] Call Trace:
[ 61.111987] [<ffffffff810949ba>] lockdep_rcu_suspicious+0xca/0xf0
[ 61.111990] [<ffffffff810fc1f8>] perf_output_begin+0x268/0x330
[ 61.111993] [<ffffffff810fbfcf>] ? perf_output_begin+0x3f/0x330
[ 61.111997] [<ffffffff81076975>] ? sched_clock_cpu+0xc5/0x120
[ 61.111999] [<ffffffff8109371d>] ? trace_hardirqs_off+0xd/0x10
[ 61.112003] [<ffffffff81076a1f>] ? local_clock+0x4f/0x60
[ 61.112006] [<ffffffff810f21cd>] ? __perf_event_header__init_id+0xad/0xf0
[ 61.112009] [<ffffffff810f8b93>] ? perf_prepare_sample+0x63/0x110
[ 61.112013] [<ffffffff810f8dcd>] __perf_event_overflow+0x18d/0x2c0
[ 61.112015] [<ffffffff810f8d85>] ? __perf_event_overflow+0x145/0x2c0
[ 61.112019] [<ffffffff817711ae>] ? printk+0x41/0x43
[ 61.112022] [<ffffffff810f8fa9>] perf_swevent_overflow+0xa9/0xc0
[ 61.112024] [<ffffffff810f902f>] perf_swevent_event+0x6f/0x90
[ 61.112028] [<ffffffff810f90c6>] perf_tp_event+0x76/0xf0
[ 61.112031] [<ffffffff810f14ce>] perf_trace_power+0xbe/0xe0
[ 61.112034] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 61.112038] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 61.112041] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.112044] [<ffffffff8174f49f>] rest_init+0x133/0x144
[ 61.112047] [<ffffffff8174f3e5>] ? rest_init+0x79/0x144
[ 61.112050] [<ffffffff81cc2b51>] start_kernel+0x35b/0x366
[ 61.112053] [<ffffffff81cc2321>] x86_64_start_reservations+0x131/0x135
[ 61.112057] [<ffffffff81cc2415>] x86_64_start_kernel+0xf0/0xf7
[ 61.112059] ------------[ cut here ]------------
[ 61.112062] WARNING: at include/linux/rcupdate.h:248 perf_output_end+0x5b/0x70()
[ 61.112064] Hardware name: ProLiant BL460c G6
[ 61.112065] Modules linked in: ipmi_devintf nfsd exportfs hpilo ipmi_si bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 61.112076] Pid: 0, comm: swapper/0 Tainted: G W 3.3.0-rc1+ #572
[ 61.112078] Call Trace:
[ 61.112081] [<ffffffff81038eaf>] warn_slowpath_common+0x7f/0xc0
[ 61.112085] [<ffffffff81038f0a>] warn_slowpath_null+0x1a/0x20
[ 61.112088] [<ffffffff810fc31b>] perf_output_end+0x5b/0x70
[ 61.112091] [<ffffffff810f8e6c>] __perf_event_overflow+0x22c/0x2c0
[ 61.112094] [<ffffffff810f8d85>] ? __perf_event_overflow+0x145/0x2c0
[ 61.112097] [<ffffffff810f8fa9>] perf_swevent_overflow+0xa9/0xc0
[ 61.112101] [<ffffffff810f902f>] perf_swevent_event+0x6f/0x90
[ 61.112104] [<ffffffff810f90c6>] perf_tp_event+0x76/0xf0
[ 61.112107] [<ffffffff810f14ce>] perf_trace_power+0xbe/0xe0
[ 61.112110] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 61.112113] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 61.112116] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.112120] [<ffffffff8174f49f>] rest_init+0x133/0x144
[ 61.112122] ------------[ cut here ]------------
[ 61.112126] WARNING: at include/linux/rcupdate.h:248 perf_output_end+0x5b/0x70()
[ 61.112128] Hardware name: ProLiant BL460c G6
[ 61.112129] Modules linked in: ipmi_devintf nfsd exportfs hpilo [<ffffffff8174f3e5>] ? rest_init+0x79/0x144
[ 61.112137] [<ffffffff81cc2b51>] start_kernel+0x35b/0x366
[ 61.112138] ipmi_si bnx2x [<ffffffff81cc2321>] x86_64_start_reservations+0x131/0x135
[ 61.112143] crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 61.112148] Pid: 0, comm: swapper/2 Tainted: G W 3.3.0-rc1+ #572
[ 61.112150] [<ffffffff81cc2415>] x86_64_start_kernel+0xf0/0xf7
[ 61.112152] ---[ end trace 18a36211154afbbd ]---
[ 61.112153] ------------[ cut here ]------------
[ 61.112155] WARNING: at include/linux/rcupdate.h:248 __perf_event_overflow+0x2a6/0x2c0()
[ 61.112156] Hardware name: ProLiant BL460c G6
[ 61.112157] Modules linked in: ipmi_devintf nfsd exportfs hpilo ipmi_si bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 61.112165] Pid: 0, comm: swapper/0 Tainted: G W 3.3.0-rc1+ #572
[ 61.112166] Call Trace:
[ 61.112168] [<ffffffff81038eaf>] warn_slowpath_common+0x7f/0xc0
[ 61.112170] Call Trace:
[ 61.112172] [<ffffffff81038f0a>] warn_slowpath_null+0x1a/0x20
[ 61.112176] [<ffffffff81038eaf>] warn_slowpath_common+0x7f/0xc0
[ 61.112178] [<ffffffff810f8ee6>] __perf_event_overflow+0x2a6/0x2c0
[ 61.112182] [<ffffffff81038f0a>] warn_slowpath_null+0x1a/0x20
[ 61.112184] [<ffffffff810f8d85>] ? __perf_event_overflow+0x145/0x2c0
[ 61.112186] [<ffffffff810f8fa9>] perf_swevent_overflow+0xa9/0xc0
[ 61.112189] [<ffffffff810fc31b>] perf_output_end+0x5b/0x70
[ 61.112191] [<ffffffff810f902f>] perf_swevent_event+0x6f/0x90
[ 61.112193] [<ffffffff810f90c6>] perf_tp_event+0x76/0xf0
[ 61.112196] [<ffffffff810f8e6c>] __perf_event_overflow+0x22c/0x2c0
[ 61.112199] [<ffffffff810f14ce>] perf_trace_power+0xbe/0xe0
[ 61.112202] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 61.112205] [<ffffffff810f8d85>] ? __perf_event_overflow+0x145/0x2c0
[ 61.112207] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 61.112209] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.112212] [<ffffffff8174f49f>] rest_init+0x133/0x144
[ 61.112214] [<ffffffff810f8fa9>] perf_swevent_overflow+0xa9/0xc0
[ 61.112217] [<ffffffff810f902f>] perf_swevent_event+0x6f/0x90
[ 61.112219] [<ffffffff8174f3e5>] ? rest_init+0x79/0x144
[ 61.112222] [<ffffffff810f90c6>] perf_tp_event+0x76/0xf0
[ 61.112227] [<ffffffff8102009d>] ? lapic_next_event+0x1d/0x30
[ 61.112229] [<ffffffff81cc2b51>] start_kernel+0x35b/0x366
[ 61.112232] [<ffffffff81cc2321>] x86_64_start_reservations+0x131/0x135
[ 61.112235] [<ffffffff810f14ce>] perf_trace_power+0xbe/0xe0
[ 61.112238] [<ffffffff81cc2415>] x86_64_start_kernel+0xf0/0xf7
[ 61.112239] ---[ end trace 18a36211154afbbe ]---
[ 61.112242] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 61.112245] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 61.112248] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.112252] [<ffffffff8176baee>] start_secondary+0x1df/0x1e3
[ 61.112254] ---[ end trace 18a36211154afbbf ]---
[ 61.114605]
[ 61.114608] ===============================
[ 61.114611] [ INFO: suspicious RCU usage. ]
[ 61.114614] 3.3.0-rc1+ #572 Tainted: G W
[ 61.114616] -------------------------------
[ 61.114620] include/trace/events/power.h:127 suspicious rcu_dereference_check() usage!
[ 61.114625]
[ 61.114626] other info that might help us debug this:
[ 61.114628]
[ 61.114630]
[ 61.114630] rcu_scheduler_active = 1, debug_locks = 1
[ 61.114633] RCU used illegally from extended quiescent state!
[ 61.114635] no locks held by swapper/2/0.
[ 61.114637]
[ 61.114638] stack backtrace:
[ 61.114641] Pid: 0, comm: swapper/2 Tainted: G W 3.3.0-rc1+ #572
[ 61.114645] Call Trace:
[ 61.114650] [<ffffffff810949ba>] lockdep_rcu_suspicious+0xca/0xf0
[ 61.114655] [<ffffffff8100a9cd>] mwait_idle+0x2ad/0x4c0
[ 61.114660] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.114664] [<ffffffff8176baee>] start_secondary+0x1df/0x1e3Quoted 48 lines · Eric Dumazet
Quoted 46 lines · Paul E. McKenney
Ah, I see... I need to find one of
trace_power_start(),trace_power_frequency(), ortrace_power_end(). I would have to guess that this is either thetrace_power_start()or thetrace_power_end()called fromdrivers/cpuidle/cpuidle.clines 97 and 102. Those are withincpuidle_idle_call(), which are called fromcpu_idle()inarch/x86/kernel/process_32.candarch/x86/kernel/process_64.c, so this sounds plausible.And they are indeed busted -- RCU believes the CPU is idle at the point that
cpuidle_idle_call()is invoked.A hacky patch is below. Here are some of my concerns with it:
1. Is there a configuration in which the scheduler clock gets
turned off, but in whichcpuidle_idle_call()always returns zero? If so, we either really need RCU to consider the entire inner loop to be idle (thus needing to snapshot the value ofcpuidle_idle_call()in the outer loop) or we need explicit calls torcu_sched_qs()and friends.Yes, we could momentarily exit RCU idleness mode, but I would need to think that one through...
2. I am not totally confident that I have the order of operations
surrounding the call topm_idle()correct.3. This only addresses x86, and it looks like a few other architectures
have this same problem.4. Probably other things that I haven't thought of.
That said, the patch does seem to compile, at least on my 32-bit laptop...
Thanx, Paul
------------------------------------------------------------------------
idle: Avoid using RCU when RCU thinks the CPU is idle
The x86 idle loops invoke
cpuidle_idle_call()which uses tracing which uses RCU. Unfortunately, these idle loops have already told RCU to ignore this CPU when they call it. This patch hacks the idle loops to avoid this problem, but probably causing several other problems in the process.
Quoted 8 lines
Quoted 2 lines
Not-yet-signed-off-by Paul E. McKenney <[email protected]>---
Hi Paul
Just tested it on my
x86_64machine, but warnings are still hereThanks !
Gah!!! The mwait_idle() function itself (which is the default value of the pm_idle function pointer) uses tracing and thus RCU! What part of "don't use RCU from idle CPUs" was unclear, one wonders?
Ah well, the good news is that we can now detect such abuse and fix it.
But fixing it appears to require pushing rcu_idle_enter() and rcu_idle_exit() pairs down to the bottom of each and every idle loop and governor.
So... The cpuidle_idle_call() function has an idle loop inside of itself, namely the ->enter() call for the desired target state. It does tracing on both sides of that call. Should the ->enter() calls actually avoid use of tracing, I could push the rcu_idle_enter() and rcu_idle_exit() down into cpuidle_idle_call(). We seem to have a ladder_governor and a menu_governor in 3.2, and these have states, which in turn have ->enter functions.
Hmmm... Residual power dissipation is given in milliwatts. I could imagine some heartburn from many of the more aggressive embedded folks, given that they might prefer microwatts -- or maybe even nanowatts, for all I know.
There are a bunch of states defined in drivers/idle/intel_idle.c, and these use intel_idle() as their ->enter() states. This one looks to have a nice place for rcu_idle_enter() and rcu_idle_exit().
But I also need to push rcu_idle_enter() and rcu_idle_exit() into any function that can be assigned to pm_idle(): default_idle(), poll_idle(), mwait_idle(), and amd_e400_idle(). OK, that is not all -that- bad, though this must also be done for a number of other architectures as well.
OK, will post a patch. I will need testing -- clearly my testing on KVM is missing a few important code paths...
Thanx, Paul
Quoted 212 lines
[ 61.111559]
[ 61.111563] ===============================
[ 61.111565] [ INFO: suspicious RCU usage. ]
[ 61.111567] 3.3.0-rc1+ #572 Not tainted
[ 61.111569] -------------------------------
[ 61.111571] include/trace/events/power.h:102 suspicious rcu_dereference_check() usage!
[ 61.111573]
[ 61.111574] other info that might help us debug this:
[ 61.111575]
[ 61.111577]
[ 61.111577] rcu_scheduler_active = 1, debug_locks = 1
[ 61.111579] RCU used illegally from extended quiescent state!
[ 61.111582] no locks held by swapper/0/0.
[ 61.111583]
[ 61.111584] stack backtrace:
[ 61.111587] Pid: 0, comm: swapper/0 Not tainted 3.3.0-rc1+ #572
[ 61.111589] Call Trace:
[ 61.111598] [<ffffffff810949ba>] lockdep_rcu_suspicious+0xca/0xf0
[ 61.111604] [<ffffffff8100abb9>] mwait_idle+0x499/0x4c0
[ 61.111609] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.111615] [<ffffffff8174f49f>] rest_init+0x133/0x144
[ 61.111618] [<ffffffff8174f3e5>] ? rest_init+0x79/0x144
[ 61.111623] [<ffffffff81cc2b51>] start_kernel+0x35b/0x366
[ 61.111627] [<ffffffff81cc2321>] x86_64_start_reservations+0x131/0x135
[ 61.111631] [<ffffffff81cc2415>] x86_64_start_kernel+0xf0/0xf7
[ 61.111743] ------------[ cut here ]------------
[ 61.111750] WARNING: at include/linux/rcupdate.h:242 __perf_event_overflow+0x27c/0x2c0()
[ 61.111754] Hardware name: ProLiant BL460c G6
[ 61.111756] Modules linked in: ipmi_devintf nfsd exportfs hpilo ipmi_si bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 61.111770] Pid: 0, comm: swapper/0 Not tainted 3.3.0-rc1+ #572
[ 61.111772] Call Trace:
[ 61.111777] [<ffffffff81038eaf>] warn_slowpath_common+0x7f/0xc0
[ 61.111781] [<ffffffff81038f0a>] warn_slowpath_null+0x1a/0x20
[ 61.111784] [<ffffffff810f8ebc>] __perf_event_overflow+0x27c/0x2c0
[ 61.111788] [<ffffffff817711ae>] ? printk+0x41/0x43
[ 61.111794] [<ffffffff810a1f86>] ? __module_text_address+0x16/0x80
[ 61.111798] [<ffffffff810f8fa9>] perf_swevent_overflow+0xa9/0xc0
[ 61.111801] [<ffffffff810f902f>] perf_swevent_event+0x6f/0x90
[ 61.111804] [<ffffffff810f90c6>] perf_tp_event+0x76/0xf0
[ 61.111809] [<ffffffff810f14ce>] perf_trace_power+0xbe/0xe0
[ 61.111812] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 61.111815] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 61.111819] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.111822] [<ffffffff8174f49f>] rest_init+0x133/0x144
[ 61.111825] [<ffffffff8174f3e5>] ? rest_init+0x79/0x144
[ 61.111828] [<ffffffff81cc2b51>] start_kernel+0x35b/0x366
[ 61.111831] [<ffffffff81cc2321>] x86_64_start_reservations+0x131/0x135
[ 61.111834] [<ffffffff81cc2415>] x86_64_start_kernel+0xf0/0xf7
[ 61.111837] ---[ end trace 18a36211154afbbb ]---
[ 61.111839] ------------[ cut here ]------------
[ 61.111843] WARNING: at include/linux/rcupdate.h:242 perf_output_begin+0x2f6/0x330()
[ 61.111845] Hardware name: ProLiant BL460c G6
[ 61.111848] Modules linked in: ipmi_devintf nfsd exportfs hpilo ipmi_si bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 61.111859] Pid: 0, comm: swapper/0 Tainted: G W 3.3.0-rc1+ #572
[ 61.111861] Call Trace:
[ 61.111864] [<ffffffff81038eaf>] warn_slowpath_common+0x7f/0xc0
[ 61.111868] [<ffffffff81038f0a>] warn_slowpath_null+0x1a/0x20
[ 61.111871] [<ffffffff810fc286>] perf_output_begin+0x2f6/0x330
[ 61.111875] [<ffffffff81076975>] ? sched_clock_cpu+0xc5/0x120
[ 61.111879] [<ffffffff8109371d>] ? trace_hardirqs_off+0xd/0x10
[ 61.111882] [<ffffffff81076a1f>] ? local_clock+0x4f/0x60
[ 61.111886] [<ffffffff810f21cd>] ? __perf_event_header__init_id+0xad/0xf0
[ 61.111889] [<ffffffff810f8b93>] ? perf_prepare_sample+0x63/0x110
[ 61.111892] [<ffffffff810f8dcd>] __perf_event_overflow+0x18d/0x2c0
[ 61.111895] [<ffffffff810f8d85>] ? __perf_event_overflow+0x145/0x2c0
[ 61.111898] [<ffffffff817711ae>] ? printk+0x41/0x43
[ 61.111901] [<ffffffff810f8fa9>] perf_swevent_overflow+0xa9/0xc0
[ 61.111904] [<ffffffff810f902f>] perf_swevent_event+0x6f/0x90
[ 61.111907] [<ffffffff810f90c6>] perf_tp_event+0x76/0xf0
[ 61.111911] [<ffffffff810f14ce>] perf_trace_power+0xbe/0xe0
[ 61.111915] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 61.111918] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 61.111922] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.111926] [<ffffffff8174f49f>] rest_init+0x133/0x144
[ 61.111929] [<ffffffff8174f3e5>] ? rest_init+0x79/0x144
[ 61.111933] [<ffffffff81cc2b51>] start_kernel+0x35b/0x366
[ 61.111937] [<ffffffff81cc2321>] x86_64_start_reservations+0x131/0x135
[ 61.111940] [<ffffffff81cc2415>] x86_64_start_kernel+0xf0/0xf7
[ 61.111943] ---[ end trace 18a36211154afbbc ]---
[ 61.111946]
[ 61.111947] ===============================
[ 61.111949] [ INFO: suspicious RCU usage. ]
[ 61.111950] 3.3.0-rc1+ #572 Tainted: G W
[ 61.111952] -------------------------------
[ 61.111954] kernel/events/ring_buffer.c:120 suspicious rcu_dereference_check() usage!
[ 61.111956]
[ 61.111957] other info that might help us debug this:
[ 61.111958]
[ 61.111960]
[ 61.111960] rcu_scheduler_active = 1, debug_locks = 1
[ 61.111962] RCU used illegally from extended quiescent state!
[ 61.111964] 2 locks held by swapper/0/0:
[ 61.111966] #0: (rcu_read_lock){.+.+..}, at: [<ffffffff810f8d85>] __perf_event_overflow+0x145/0x2c0
[ 61.111974] #1: (rcu_read_lock){.+.+..}, at: [<ffffffff810fbfcf>] perf_output_begin+0x3f/0x330
[ 61.111980]
[ 61.111980] stack backtrace:
[ 61.111982] Pid: 0, comm: swapper/0 Tainted: G W 3.3.0-rc1+ #572
[ 61.111984] Call Trace:
[ 61.111987] [<ffffffff810949ba>] lockdep_rcu_suspicious+0xca/0xf0
[ 61.111990] [<ffffffff810fc1f8>] perf_output_begin+0x268/0x330
[ 61.111993] [<ffffffff810fbfcf>] ? perf_output_begin+0x3f/0x330
[ 61.111997] [<ffffffff81076975>] ? sched_clock_cpu+0xc5/0x120
[ 61.111999] [<ffffffff8109371d>] ? trace_hardirqs_off+0xd/0x10
[ 61.112003] [<ffffffff81076a1f>] ? local_clock+0x4f/0x60
[ 61.112006] [<ffffffff810f21cd>] ? __perf_event_header__init_id+0xad/0xf0
[ 61.112009] [<ffffffff810f8b93>] ? perf_prepare_sample+0x63/0x110
[ 61.112013] [<ffffffff810f8dcd>] __perf_event_overflow+0x18d/0x2c0
[ 61.112015] [<ffffffff810f8d85>] ? __perf_event_overflow+0x145/0x2c0
[ 61.112019] [<ffffffff817711ae>] ? printk+0x41/0x43
[ 61.112022] [<ffffffff810f8fa9>] perf_swevent_overflow+0xa9/0xc0
[ 61.112024] [<ffffffff810f902f>] perf_swevent_event+0x6f/0x90
[ 61.112028] [<ffffffff810f90c6>] perf_tp_event+0x76/0xf0
[ 61.112031] [<ffffffff810f14ce>] perf_trace_power+0xbe/0xe0
[ 61.112034] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 61.112038] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 61.112041] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.112044] [<ffffffff8174f49f>] rest_init+0x133/0x144
[ 61.112047] [<ffffffff8174f3e5>] ? rest_init+0x79/0x144
[ 61.112050] [<ffffffff81cc2b51>] start_kernel+0x35b/0x366
[ 61.112053] [<ffffffff81cc2321>] x86_64_start_reservations+0x131/0x135
[ 61.112057] [<ffffffff81cc2415>] x86_64_start_kernel+0xf0/0xf7
[ 61.112059] ------------[ cut here ]------------
[ 61.112062] WARNING: at include/linux/rcupdate.h:248 perf_output_end+0x5b/0x70()
[ 61.112064] Hardware name: ProLiant BL460c G6
[ 61.112065] Modules linked in: ipmi_devintf nfsd exportfs hpilo ipmi_si bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 61.112076] Pid: 0, comm: swapper/0 Tainted: G W 3.3.0-rc1+ #572
[ 61.112078] Call Trace:
[ 61.112081] [<ffffffff81038eaf>] warn_slowpath_common+0x7f/0xc0
[ 61.112085] [<ffffffff81038f0a>] warn_slowpath_null+0x1a/0x20
[ 61.112088] [<ffffffff810fc31b>] perf_output_end+0x5b/0x70
[ 61.112091] [<ffffffff810f8e6c>] __perf_event_overflow+0x22c/0x2c0
[ 61.112094] [<ffffffff810f8d85>] ? __perf_event_overflow+0x145/0x2c0
[ 61.112097] [<ffffffff810f8fa9>] perf_swevent_overflow+0xa9/0xc0
[ 61.112101] [<ffffffff810f902f>] perf_swevent_event+0x6f/0x90
[ 61.112104] [<ffffffff810f90c6>] perf_tp_event+0x76/0xf0
[ 61.112107] [<ffffffff810f14ce>] perf_trace_power+0xbe/0xe0
[ 61.112110] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 61.112113] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 61.112116] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.112120] [<ffffffff8174f49f>] rest_init+0x133/0x144
[ 61.112122] ------------[ cut here ]------------
[ 61.112126] WARNING: at include/linux/rcupdate.h:248 perf_output_end+0x5b/0x70()
[ 61.112128] Hardware name: ProLiant BL460c G6
[ 61.112129] Modules linked in: ipmi_devintf nfsd exportfs hpilo [<ffffffff8174f3e5>] ? rest_init+0x79/0x144
[ 61.112137] [<ffffffff81cc2b51>] start_kernel+0x35b/0x366
[ 61.112138] ipmi_si bnx2x [<ffffffff81cc2321>] x86_64_start_reservations+0x131/0x135
[ 61.112143] crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 61.112148] Pid: 0, comm: swapper/2 Tainted: G W 3.3.0-rc1+ #572
[ 61.112150] [<ffffffff81cc2415>] x86_64_start_kernel+0xf0/0xf7
[ 61.112152] ---[ end trace 18a36211154afbbd ]---
[ 61.112153] ------------[ cut here ]------------
[ 61.112155] WARNING: at include/linux/rcupdate.h:248 __perf_event_overflow+0x2a6/0x2c0()
[ 61.112156] Hardware name: ProLiant BL460c G6
[ 61.112157] Modules linked in: ipmi_devintf nfsd exportfs hpilo ipmi_si bnx2x crc32c libcrc32c mdio [last unloaded: scsi_wait_scan]
[ 61.112165] Pid: 0, comm: swapper/0 Tainted: G W 3.3.0-rc1+ #572
[ 61.112166] Call Trace:
[ 61.112168] [<ffffffff81038eaf>] warn_slowpath_common+0x7f/0xc0
[ 61.112170] Call Trace:
[ 61.112172] [<ffffffff81038f0a>] warn_slowpath_null+0x1a/0x20
[ 61.112176] [<ffffffff81038eaf>] warn_slowpath_common+0x7f/0xc0
[ 61.112178] [<ffffffff810f8ee6>] __perf_event_overflow+0x2a6/0x2c0
[ 61.112182] [<ffffffff81038f0a>] warn_slowpath_null+0x1a/0x20
[ 61.112184] [<ffffffff810f8d85>] ? __perf_event_overflow+0x145/0x2c0
[ 61.112186] [<ffffffff810f8fa9>] perf_swevent_overflow+0xa9/0xc0
[ 61.112189] [<ffffffff810fc31b>] perf_output_end+0x5b/0x70
[ 61.112191] [<ffffffff810f902f>] perf_swevent_event+0x6f/0x90
[ 61.112193] [<ffffffff810f90c6>] perf_tp_event+0x76/0xf0
[ 61.112196] [<ffffffff810f8e6c>] __perf_event_overflow+0x22c/0x2c0
[ 61.112199] [<ffffffff810f14ce>] perf_trace_power+0xbe/0xe0
[ 61.112202] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 61.112205] [<ffffffff810f8d85>] ? __perf_event_overflow+0x145/0x2c0
[ 61.112207] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 61.112209] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.112212] [<ffffffff8174f49f>] rest_init+0x133/0x144
[ 61.112214] [<ffffffff810f8fa9>] perf_swevent_overflow+0xa9/0xc0
[ 61.112217] [<ffffffff810f902f>] perf_swevent_event+0x6f/0x90
[ 61.112219] [<ffffffff8174f3e5>] ? rest_init+0x79/0x144
[ 61.112222] [<ffffffff810f90c6>] perf_tp_event+0x76/0xf0
[ 61.112227] [<ffffffff8102009d>] ? lapic_next_event+0x1d/0x30
[ 61.112229] [<ffffffff81cc2b51>] start_kernel+0x35b/0x366
[ 61.112232] [<ffffffff81cc2321>] x86_64_start_reservations+0x131/0x135
[ 61.112235] [<ffffffff810f14ce>] perf_trace_power+0xbe/0xe0
[ 61.112238] [<ffffffff81cc2415>] x86_64_start_kernel+0xf0/0xf7
[ 61.112239] ---[ end trace 18a36211154afbbe ]---
[ 61.112242] [<ffffffff8100ab2f>] ? mwait_idle+0x40f/0x4c0
[ 61.112245] [<ffffffff8100ab2f>] mwait_idle+0x40f/0x4c0
[ 61.112248] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.112252] [<ffffffff8176baee>] start_secondary+0x1df/0x1e3
[ 61.112254] ---[ end trace 18a36211154afbbf ]---
[ 61.114605]
[ 61.114608] ===============================
[ 61.114611] [ INFO: suspicious RCU usage. ]
[ 61.114614] 3.3.0-rc1+ #572 Tainted: G W
[ 61.114616] -------------------------------
[ 61.114620] include/trace/events/power.h:127 suspicious rcu_dereference_check() usage!
[ 61.114625]
[ 61.114626] other info that might help us debug this:
[ 61.114628]
[ 61.114630]
[ 61.114630] rcu_scheduler_active = 1, debug_locks = 1
[ 61.114633] RCU used illegally from extended quiescent state!
[ 61.114635] no locks held by swapper/2/0.
[ 61.114637]
[ 61.114638] stack backtrace:
[ 61.114641] Pid: 0, comm: swapper/2 Tainted: G W 3.3.0-rc1+ #572
[ 61.114645] Call Trace:
[ 61.114650] [<ffffffff810949ba>] lockdep_rcu_suspicious+0xca/0xf0
[ 61.114655] [<ffffffff8100a9cd>] mwait_idle+0x2ad/0x4c0
[ 61.114660] [<ffffffff810011e8>] cpu_idle+0x98/0xe0
[ 61.114664] [<ffffffff8176baee>] start_secondary+0x1df/0x1e3Quoted 4 lines · Paul E. McKenney
Hmmm... Residual power dissipation is given in milliwatts. I could imagine some heartburn from many of the more aggressive embedded folks, given that they might prefer microwatts -- or maybe even nanowatts, for all I know.
FWIW idle battery referenced draw from a modern smartphone will be in the low single digit miliwatts or so.
Quoted 9 lines · Mark Brown
Quoted 4 lines · Paul E. McKenney
Hmmm... Residual power dissipation is given in milliwatts. I could imagine some heartburn from many of the more aggressive embedded folks, given that they might prefer microwatts -- or maybe even nanowatts, for all I know.
FWIW idle battery referenced draw from a modern smartphone will be in the low single digit miliwatts or so.
Ah, OK, so only the non-smart cellphones would care, but they generally don't run Linux, from what I understand. Thanks for the info!
Thanx, Paul
Quoted 85 lines · Paul E. McKenney
Quoted 48 lines · Eric Dumazet
Quoted 46 lines · Paul E. McKenney
Ah, I see... I need to find one of
trace_power_start(),trace_power_frequency(), ortrace_power_end(). I would have to guess that this is either thetrace_power_start()or thetrace_power_end()called fromdrivers/cpuidle/cpuidle.clines 97 and 102. Those are withincpuidle_idle_call(), which are called fromcpu_idle()inarch/x86/kernel/process_32.candarch/x86/kernel/process_64.c, so this sounds plausible.And they are indeed busted -- RCU believes the CPU is idle at the point that
cpuidle_idle_call()is invoked.A hacky patch is below. Here are some of my concerns with it:
1. Is there a configuration in which the scheduler clock gets
turned off, but in whichcpuidle_idle_call()always returns zero? If so, we either really need RCU to consider the entire inner loop to be idle (thus needing to snapshot the value ofcpuidle_idle_call()in the outer loop) or we need explicit calls torcu_sched_qs()and friends.Yes, we could momentarily exit RCU idleness mode, but I would need to think that one through...
2. I am not totally confident that I have the order of operations
surrounding the call topm_idle()correct.3. This only addresses x86, and it looks like a few other architectures
have this same problem.4. Probably other things that I haven't thought of.
That said, the patch does seem to compile, at least on my 32-bit laptop...
Thanx, Paul
------------------------------------------------------------------------
idle: Avoid using RCU when RCU thinks the CPU is idle
The x86 idle loops invoke
cpuidle_idle_call()which uses tracing which uses RCU. Unfortunately, these idle loops have already told RCU to ignore this CPU when they call it. This patch hacks the idle loops to avoid this problem, but probably causing several other problems in the process.Quoted 8 lines
Quoted 2 lines
Not-yet-signed-off-by Paul E. McKenney <[email protected]>---
Hi Paul
Just tested it on my
x86_64machine, but warnings are still hereThanks !
Gah!!! The
mwait_idle()function itself (which is the default value of thepm_idlefunction pointer) uses tracing and thus RCU! What part of "don't use RCU from idle CPUs" was unclear, one wonders?Ah well, the good news is that we can now detect such abuse and fix it.
But fixing it appears to require pushing
rcu_idle_enter()andrcu_idle_exit()pairs down to the bottom of each and every idle loop and governor.So... The
cpuidle_idle_call()function has an idle loop inside of itself, namely the ->enter() call for the desired target state. It does tracing on both sides of that call. Should the ->enter() calls actually avoid use of tracing, I could push thercu_idle_enter()andrcu_idle_exit()down intocpuidle_idle_call(). We seem to have aladder_governorand amenu_governorin 3.2, and these have states, which in turn have ->enter functions.Hmmm... Residual power dissipation is given in milliwatts. I could imagine some heartburn from many of the more aggressive embedded folks, given that they might prefer microwatts -- or maybe even nanowatts, for all I know.
There are a bunch of states defined in
drivers/idle/intel_idle.c, and these useintel_idle()as their ->enter() states. This one looks to have a nice place forrcu_idle_enter()andrcu_idle_exit().
Quoted 7 lines
But I also need to push
rcu_idle_enter()andrcu_idle_exit()into any function that can be assigned topm_idle():default_idle(),poll_idle(),mwait_idle(), andamd_e400_idle(). OK, that is not all -that- bad, though this must also be done for a number of other architectures as well.OK, will post a patch. I will need testing -- clearly my testing on KVM is missing a few important code paths...
And here is another version of the patch.
Thanx, Paul
------------------------------------------------------------------------
x86: Avoid invoking RCU when CPU is idle
The idle loop is a quiscent state for RCU, which means that RCU ignores CPUs that have told RCU that they are idle via rcu_idle_enter(). There are nevertheless quite a few places where idle CPUs use RCU, most commonly indirectly via tracing. This patch fixes these problems for x86.
Many of these bugs have been in the kernel for quite some time, but Frederic's recent change now gives warnings.
This patch takes the straightforward approach of pushing the rcu_idle_enter()/rcu_idle_exit() pair further down into the core of the idle loop.
arch/x86/kernel/process.c +12 -1
@@ -386,17 +386,21 @@ void default_idle(void)*/ smp_mb (); +rcu_idle_enter ();if (!need_resched ())safe_halt ();/* enables interrupts racelessly */ else local_irq_enable (); +rcu_idle_exit ();current_thread_info ()->status |=TS_POLLING ;trace_power_end (smp_processor_id ());trace_cpu_idle (PWR_EVENT_EXIT ,smp_processor_id ()); }else {local_irq_enable ();/* loop is done by the caller */ +rcu_idle_enter ();cpu_relax (); +rcu_idle_exit (); } }#ifdef CONFIG_APM_MODULE
@@ -457,14 +461,19 @@ static void mwait_idle(void)__monitor ((void *)¤t_thread_info ()->flags,0 ,0 );smp_mb (); +rcu_idle_enter ();if (!need_resched ())__sti_mwait (0 ,0 );else local_irq_enable (); +rcu_idle_exit ();trace_power_end (smp_processor_id ());trace_cpu_idle (PWR_EVENT_EXIT ,smp_processor_id ()); - }else + }else {local_irq_enable (); +rcu_idle_enter (); +rcu_idle_exit (); + } }/*
@@ -477,8 +486,10 @@ static void poll_idle(void)trace_power_start (POWER_CSTATE ,0 ,smp_processor_id ());trace_cpu_idle (0 ,smp_processor_id ());local_irq_enable (); +rcu_idle_enter ();while (!need_resched ())cpu_relax (); +rcu_idle_exit ();trace_power_end (smp_processor_id ());trace_cpu_idle (PWR_EVENT_EXIT ,smp_processor_id ()); }
arch/x86/kernel/process_32.c +0 -2
@@ -100,7 +100,6 @@ void cpu_idle(void)/* endless idle loop with no priority at all */ while (1 ) {tick_nohz_idle_enter (); -rcu_idle_enter ();while (!need_resched ()) {check_pgt_cache ();
@@ -117,7 +116,6 @@ void cpu_idle(void)pm_idle ();start_critical_timings (); } -rcu_idle_exit ();tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();
arch/x86/kernel/process_64.c +0 -4
@@ -140,13 +140,9 @@ void cpu_idle(void)/* Don't trace irqs off for idle */ stop_critical_timings (); -/* enter_idle() needs rcu for notifiers */ -rcu_idle_enter (); -if (cpuidle_idle_call ())pm_idle (); -rcu_idle_exit ();start_critical_timings ();/* In many cases the interrupt that ended idle
drivers/idle/intel_idle.c +2 -0
@@ -261,6 +261,7 @@ static int intel_idle(struct cpuidle_device *dev, kt_before =ktime_get_real ();stop_critical_timings (); +rcu_idle_enter ();if (!need_resched ()) {__monitor ((void *)¤t_thread_info ()->flags,0 ,0 );
@@ -268,6 +269,7 @@ static int intel_idle(struct cpuidle_device *dev,if (!need_resched ())__mwait (eax, ecx); } +rcu_idle_exit ();start_critical_timings ();
Eric Dumazet
Tested-byQuoted 16 lines · Paul E. McKenney
And here is another version of the patch.
Thanx, Paul
------------------------------------------------------------------------
x86: Avoid invoking RCU when CPU is idle
The idle loop is a quiscent state for RCU, which means that RCU ignores CPUs that have told RCU that they are idle via
rcu_idle_enter(). There are nevertheless quite a few places where idle CPUs use RCU, most commonly indirectly via tracing. This patch fixes these problems for x86.Many of these bugs have been in the kernel for quite some time, but Frederic's recent change now gives warnings.
Quoted 7 lines
This patch takes the straightforward approach of pushing the rcu_idle_enter()/rcu_idle_exit() pair further down into the core of the idle loop.
Signed-off-by Paul E. McKenney <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>
Oh well, just when I decided to sleep a bit, you send a new patch :)
This seems to remove the warnings at least on my x86_64 server, thanks !
Quoted 8 lines · Paul E. McKenney
Quoted 6 lines · Mark Brown
Quoted 4 lines · Paul E. McKenney
Hmmm... Residual power dissipation is given in milliwatts. I could imagine some heartburn from many of the more aggressive embedded folks, given that they might prefer microwatts -- or maybe even nanowatts, for all I know.
Quoted 5 lines
Quoted 2 lines
FWIW idle battery referenced draw from a modern smartphone will be in the low single digit miliwatts or so.
Ah, OK, so only the non-smart cellphones would care, but they generally don't run Linux, from what I understand. Thanks for the info!
Well, that depends. Anything you're actually accomplishing when you're optimising at that level is at the less than a milliwatt level.
Quoted 22 lines · Eric Dumazet
Quoted 20 lines · Paul E. McKenney
And here is another version of the patch.
Thanx, Paul
------------------------------------------------------------------------
x86: Avoid invoking RCU when CPU is idle
The idle loop is a quiscent state for RCU, which means that RCU ignores CPUs that have told RCU that they are idle via
rcu_idle_enter(). There are nevertheless quite a few places where idle CPUs use RCU, most commonly indirectly via tracing. This patch fixes these problems for x86.Many of these bugs have been in the kernel for quite some time, but Frederic's recent change now gives warnings.
This patch takes the straightforward approach of pushing the rcu_idle_enter()/rcu_idle_exit() pair further down into the core of the idle loop.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Paul E. McKenney <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>Oh well, just when I decided to sleep a bit, you send a new patch :)
;-) ;-) ;-)
Quoted 3 lines
This seems to remove the warnings at least on my
x86_64server, thanks !Tested-by Eric Dumazet <[email protected]>
Good to hear! Thank you!!! I have added your Reported-by and Tested-by.
Thanx, Paul
Quoted 9 lines · Mark Brown
Quoted 7 lines · Paul E. McKenney
Quoted 6 lines · Mark Brown
Quoted 4 lines · Paul E. McKenney
Hmmm... Residual power dissipation is given in milliwatts. I could imagine some heartburn from many of the more aggressive embedded folks, given that they might prefer microwatts -- or maybe even nanowatts, for all I know.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
FWIW idle battery referenced draw from a modern smartphone will be in the low single digit miliwatts or so.
Ah, OK, so only the non-smart cellphones would care, but they generally don't run Linux, from what I understand. Thanks for the info!
Well, that depends. Anything you're actually accomplishing when you're optimising at that level is at the less than a milliwatt level.
OK, good point.
In the meantime, here are some alleged fixes for the corresponding bug in the ARM tree. Some of these are "interesting" in the sense that RCU can be used more deeply in the idle loop than I would believe to be safe, for example, via locking->lockdep->RCU after some interesting pieces of hardware have been shut off. I took my best guess and commented the ones that I am least sure of.
Thoughts? Other than I need to CC a cast of thousands? (I cannot break this up without having git bisect points with busted RCU on ARM.)
Thanx, Paul
------------------------------------------------------------------------
arm: Avoid invoking RCU when CPU is idle
The idle loop is a quiscent state for RCU, which means that RCU ignores CPUs that have told RCU that they are idle via rcu_idle_enter(). There are nevertheless quite a few places where idle CPUs use RCU, most commonly indirectly via tracing. This patch fixes these problems for ARM.
Many of these bugs have been in the kernel for quite some time, but Frederic's recent change now gives warnings.
This patch takes the straightforward approach of pushing the rcu_idle_enter()/rcu_idle_exit() pair further down into the core of the idle loop.
arch/arm/kernel/process.c +0 -2
@@ -207,7 +207,6 @@ void cpu_idle(void)/* endless idle loop with no priority at all */ while (1 ) {tick_nohz_idle_enter (); -rcu_idle_enter ();leds_event (led_idle_start);while (!need_resched ()) {#ifdef CONFIG_HOTPLUG_CPU
@@ -237,7 +236,6 @@ void cpu_idle(void) } }leds_event (led_idle_end); -rcu_idle_exit ();tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();
arch/arm/mach-at91/cpuidle.c +3 -0
@@ -20,6 +20,7 @@#include <asm/proc-fns.h> #include <linux/io.h> #include <linux/export.h> +#include <linux/rcupdate.h> #include "pm.h"
@@ -43,6 +44,7 @@ static int at91_enter_idle(struct cpuidle_device *dev,local_irq_disable ();do_gettimeofday (&before); +rcu_idle_enter ();if (index ==0 )/* Wait for interrupt state */ cpu_do_idle ();
@@ -53,6 +55,7 @@ static int at91_enter_idle(struct cpuidle_device *dev,cpu_do_idle ();sdram_selfrefresh_disable (saved_lpr); } +rcu_idle_exit ();do_gettimeofday (&after);local_irq_enable (); idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC +
arch/arm/mach-davinci/cpuidle.c +3 -0
@@ -17,6 +17,7 @@#include <linux/cpuidle.h> #include <linux/io.h> #include <linux/export.h> +#include <linux/rcupdate.h> #include <asm/proc-fns.h> #include <mach/cpuidle.h>
@@ -90,12 +91,14 @@ static int davinci_enter_idle(struct cpuidle_device *dev,local_irq_disable ();do_gettimeofday (&before); +rcu_idle_enter ();if (ops && ops->enter) ops->enter (ops->flags);/* Wait for interrupt state */ cpu_do_idle ();if (ops && ops->exit) ops->exit (ops->flags); +rcu_idle_exit ();do_gettimeofday (&after);local_irq_enable ();
arch/arm/mach-exynos/common.c +2 -0
@@ -203,8 +203,10 @@ static struct map_desc exynos4_iodesc1[] __initdata = {static void exynos_idle (void ) { +rcu_idle_enter ();if (!need_resched ())cpu_do_idle (); +rcu_idle_exit ();local_irq_enable (); }
arch/arm/mach-highbank/pm.c +12 -0
@@ -17,6 +17,7 @@#include <linux/init.h> #include <linux/io.h> #include <linux/suspend.h> +#include <linux/rcupdate.h> #include <asm/proc-fns.h> #include <asm/smp_scu.h>
@@ -33,12 +34,23 @@ static int highbank_suspend_finish(unsigned long val)static int highbank_pm_enter (suspend_state_t state) { +/* +* Some of the functions preceding the cpu_suspend() can +* invoke RCU, but only in case of failure to disable preemption +* or preempt_disable() misnesting. Assume that these errors +* are not committed in the following code, because RCU just +* doesn't want to run on a CPU that has its caches disabled. +*/ +rcu_idle_enter (); +hignbank_set_pwr_suspend ();highbank_set_cpu_jump (0 , cpu_resume);scu_power_mode (scu_base_addr,SCU_PM_POWEROFF );cpu_suspend (0 , highbank_suspend_finish); +rcu_idle_exit (); +return 0 ; }
arch/arm/mach-imx/mm-imx3.c +3 -0
@@ -19,6 +19,7 @@#include <linux/mm.h> #include <linux/init.h> #include <linux/err.h> +#include <linux/rcupdate.h> #include <asm/pgtable.h> #include <asm/hardware/cache-l2x0.h>
@@ -34,6 +35,7 @@ static void imx3_idle(void) {unsigned long reg =0 ; +rcu_idle_enter ();if (!need_resched ()) __asm__ __volatile__(/* disable I and D cache */
@@ -58,6 +60,7 @@ static void imx3_idle(void) "orr %0, %0, #0x00000004\n" "mcr p15, 0, %0, c1, c0, 0\n" : "=r" (reg)); +rcu_idle_exit ();local_irq_enable (); }
arch/arm/mach-imx/pm-imx27.c +4 -0
@@ -10,12 +10,14 @@#include <linux/kernel.h> #include <linux/suspend.h> #include <linux/io.h> +#include <linux/rcupdate.h> #include <mach/system.h> #include <mach/hardware.h> static int mx27_suspend_enter (suspend_state_t state) {u32 cscr; +rcu_idle_enter ();switch (state) {case PM_SUSPEND_MEM :/* Clear MPEN and SPEN to disable MPLL/SPLL */
@@ -24,9 +26,11 @@ static int mx27_suspend_enter(suspend_state_t state)__raw_writel (cscr,MX27_IO_ADDRESS (MX27_CCM_BASE_ADDR ));/* Executes WFI */ arch_idle (); +rcu_idle_exit ();break ;default : +rcu_idle_exit ();return -EINVAL ; }return 0 ;
arch/arm/mach-imx/pm-imx6q.c +4 -0
@@ -14,6 +14,7 @@#include <linux/io.h> #include <linux/of.h> #include <linux/suspend.h> +#include <linux/rcupdate.h> #include <asm/cacheflush.h> #include <asm/proc-fns.h> #include <asm/suspend.h>
@@ -31,6 +32,7 @@ static int imx6q_suspend_finish(unsigned long val)static int imx6q_pm_enter (suspend_state_t state) { +rcu_idle_enter ();switch (state) {case PM_SUSPEND_MEM :imx6q_set_lpm (STOP_POWER_OFF );
@@ -40,8 +42,10 @@ static int imx6q_pm_enter(suspend_state_t state)cpu_suspend (0 , imx6q_suspend_finish);imx_smp_prepare ();imx_gpc_post_resume (); +rcu_idle_exit ();break ;default : +rcu_idle_exit ();return -EINVAL ; }
arch/arm/mach-kirkwood/cpuidle.c +3 -0
@@ -19,6 +19,7 @@#include <linux/cpuidle.h> #include <linux/io.h> #include <linux/export.h> +#include <linux/rcupdate.h> #include <asm/proc-fns.h> #include <mach/kirkwood.h>
@@ -41,6 +42,7 @@ static int kirkwood_enter_idle(struct cpuidle_device *dev,local_irq_disable ();do_gettimeofday (&before); +rcu_idle_enter ();if (index ==0 )/* Wait for interrupt state */ cpu_do_idle ();
@@ -55,6 +57,7 @@ static int kirkwood_enter_idle(struct cpuidle_device *dev,writel (0x7 ,DDR_OPERATION_BASE );cpu_do_idle (); } +rcu_idle_exit ();do_gettimeofday (&after);local_irq_enable (); idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC +
arch/arm/mach-mx5/mm.c +3 -0
@@ -14,6 +14,7 @@#include <linux/mm.h> #include <linux/init.h> #include <linux/clk.h> +#include <linux/rcupdate.h> #include <asm/mach/map.h>
@@ -37,7 +38,9 @@ static void imx5_idle(void)mx5_cpu_lp_set (WAIT_UNCLOCKED_POWER_OFF );if (tzic_enable_wake ()) goto err1; +rcu_idle_enter ();/* No tracing until rcu_idle_exit(). */ cpu_do_idle (); +rcu_idle_exit (); err1:clk_disable (gpc_dvfs_clk); }
arch/arm/mach-mx5/pm-imx5.c +3 -0
@@ -12,6 +12,7 @@#include <linux/clk.h> #include <linux/io.h> #include <linux/err.h> +#include <linux/rcupdate.h> #include <asm/cacheflush.h> #include <asm/tlbflush.h> #include <mach/common.h>
@@ -27,6 +28,7 @@ static int mx5_suspend_prepare(void)static int mx5_suspend_enter (suspend_state_t state) { +rcu_idle_enter ();switch (state) {case PM_SUSPEND_MEM :mx5_cpu_lp_set (STOP_POWER_OFF );
@@ -47,6 +49,7 @@ static int mx5_suspend_enter(suspend_state_t state)__raw_writel (0 ,MXC_SRPG_EMPGC1_SRPGCR ); }cpu_do_idle (); +rcu_idle_exit ();return 0 ; }
arch/arm/mach-mxs/pm.c +4 -0
@@ -15,16 +15,20 @@#include <linux/kernel.h> #include <linux/suspend.h> #include <linux/io.h> +#include <linux/rcupdate.h> #include <mach/system.h> static int mxs_suspend_enter (suspend_state_t state) { +rcu_idle_enter ();switch (state) {case PM_SUSPEND_MEM :arch_idle (); +rcu_idle_exit ();break ;default : +rcu_idle_exit ();return -EINVAL ; }return 0 ;
arch/arm/mach-omap1/pm.c +4 -0
@@ -108,11 +108,13 @@ void omap1_pm_idle(void)__u32 use_idlect1 = arm_idlect1_mask;int do_sleep =0 ; +rcu_idle_enter ();local_irq_disable ();local_fiq_disable ();if (need_resched ()) {local_fiq_enable ();local_irq_enable (); +rcu_idle_exit ();return ; }
@@ -158,6 +160,7 @@ void omap1_pm_idle(void)local_fiq_enable ();local_irq_enable (); +rcu_idle_exit ();return ; } omap_sram_suspend(omap_readl(ARM_IDLECT1),
@@ -165,6 +168,7 @@ void omap1_pm_idle(void)local_fiq_enable ();local_irq_enable (); +rcu_idle_exit (); }/*
arch/arm/mach-omap2/pm24xx.c +2 -0
@@ -232,6 +232,7 @@ static int omap2_can_sleep(void)static void omap2_pm_idle (void ) { +rcu_idle_enter ();local_irq_disable ();local_fiq_disable ();
@@ -250,6 +251,7 @@ static void omap2_pm_idle(void) out:local_fiq_enable ();local_irq_enable (); +rcu_idle_exit (); }#ifdef CONFIG_SUSPEND
arch/arm/mach-omap2/pm34xx.c +2 -0
@@ -427,7 +427,9 @@ static void omap3_pm_idle(void)trace_power_start (POWER_CSTATE ,1 ,smp_processor_id ());trace_cpu_idle (1 ,smp_processor_id ()); +rcu_idle_enter ();omap_sram_idle (); +rcu_idle_exit ();trace_power_end (smp_processor_id ());trace_cpu_idle (PWR_EVENT_EXIT ,smp_processor_id ());
arch/arm/mach-omap2/pm44xx.c +3 -0
@@ -16,6 +16,7 @@#include <linux/list.h> #include <linux/err.h> #include <linux/slab.h> +#include <linux/rcupdate.h> #include "common.h" #include "clockdomain.h"
@@ -178,6 +179,7 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)*/ static void omap_default_idle (void ) { +rcu_idle_enter ();local_irq_disable ();local_fiq_disable ();
@@ -185,6 +187,7 @@ static void omap_default_idle(void)local_fiq_enable ();local_irq_enable (); +rcu_idle_exit (); }/**
arch/arm/mach-pnx4008/pm.c +2 -0
@@ -102,6 +102,7 @@ static inline void pnx4008_suspend(void)static int pnx4008_pm_enter (suspend_state_t state) { +rcu_idle_enter ();switch (state) {case PM_SUSPEND_STANDBY :pnx4008_standby ();
@@ -110,6 +111,7 @@ static int pnx4008_pm_enter(suspend_state_t state)pnx4008_suspend ();break ; } +rcu_idle_exit ();return 0 ; }
arch/arm/mach-prima2/pm.c +4 -0
@@ -15,6 +15,7 @@#include <linux/of_device.h> #include <linux/of_platform.h> #include <linux/io.h> +#include <linux/rcupdate.h> #include <linux/rtc/sirfsoc_rtciobrg.h> #include <asm/suspend.h> #include <asm/hardware/cache-l2x0.h>
@@ -64,6 +65,7 @@ static int sirfsoc_pre_suspend_power_off(void)static int sirfsoc_pm_enter (suspend_state_t state) { +rcu_idle_enter ();/* No good place for this: locking->lockdep->RCU. */ switch (state) {case PM_SUSPEND_MEM :sirfsoc_pre_suspend_power_off ();
@@ -73,8 +75,10 @@ static int sirfsoc_pm_enter(suspend_state_t state)/* go zzz */ cpu_suspend (0 , sirfsoc_finish_suspend);outer_resume (); +rcu_idle_exit ();break ;default : +rcu_idle_exit ();return -EINVAL ; }return 0 ;
arch/arm/mach-s5p64x0/common.c +2 -0
@@ -146,6 +146,7 @@ static void s5p64x0_idle(void) {unsigned long val; +rcu_idle_enter ();if (!need_resched ()) { val =__raw_readl (S5P64X0_PWR_CFG ); val &= ~(0x3 <<5 );
@@ -154,6 +155,7 @@ static void s5p64x0_idle(void)cpu_do_idle (); } +rcu_idle_exit ();local_irq_enable (); }
arch/arm/mach-s5pc100/common.c +2 -0
@@ -131,9 +131,11 @@ static struct map_desc s5pc100_iodesc[] __initdata = {static void s5pc100_idle (void ) { +rcu_idle_enter ();if (!need_resched ())cpu_do_idle (); +rcu_idle_exit ();local_irq_enable (); }
arch/arm/mach-s5pv210/common.c +2 -0
@@ -144,9 +144,11 @@ static struct map_desc s5pv210_iodesc[] __initdata = {static void s5pv210_idle (void ) { +rcu_idle_enter ();if (!need_resched ())cpu_do_idle (); +rcu_idle_exit ();local_irq_enable (); }
arch/arm/mach-shmobile/cpuidle.c +3 -0
@@ -13,6 +13,7 @@#include <linux/suspend.h> #include <linux/module.h> #include <linux/err.h> +#include <linux/rcupdate.h> #include <asm/system.h> #include <asm/io.h>
@@ -33,6 +34,7 @@ static int shmobile_cpuidle_enter(struct cpuidle_device *dev, before =ktime_get (); +rcu_idle_enter ();local_irq_disable ();local_fiq_disable ();
@@ -40,6 +42,7 @@ static int shmobile_cpuidle_enter(struct cpuidle_device *dev,local_irq_enable ();local_fiq_enable (); +rcu_idle_exit (); after =ktime_get (); dev->last_residency =ktime_to_ns (ktime_sub (after, before)) >>10 ;
arch/arm/mach-shmobile/pm-sh7372.c +8 -0
@@ -21,6 +21,7 @@#include <linux/irq.h> #include <linux/bitrev.h> #include <linux/console.h> +#include <linux/rcupdate.h> #include <asm/system.h> #include <asm/io.h> #include <asm/tlbflush.h>
@@ -520,17 +521,24 @@ static int sh7372_enter_suspend(suspend_state_t suspend_state) sh7372_a4s.genpd.status == GPD_STATE_POWER_OFF) { /* enter A4S sleep with PLLC0 off */ pr_debug("entering A4S\n"); + rcu_idle_enter(); sh7372_enter_a4s_common(0); + rcu_idle_exit(); } else {/* enter A3SM sleep with PLLC0 off */ pr_debug ("entering A3SM\n" ); +rcu_idle_enter ();sh7372_enter_a3sm_common (0 ); +rcu_idle_exit (); } }else {/* default to Core Standby that supports all wakeup sources */ pr_debug ("entering Core Standby\n" ); +rcu_idle_enter ();sh7372_enter_core_standby (); +rcu_idle_exit (); } +return 0 ; }
Quoted 14 lines · Paul E. McKenney
Quoted 2 lines · Mark Brown
Well, that depends. Anything you're actually accomplishing when you're optimising at that level is at the less than a milliwatt level.
OK, good point.
In the meantime, here are some alleged fixes for the corresponding bug in the ARM tree. Some of these are "interesting" in the sense that RCU can be used more deeply in the idle loop than I would believe to be safe, for example, via
locking->lockdep->RCUafter some interesting pieces of hardware have been shut off. I took my best guess and commented the ones that I am least sure of.
Quoted 2 lines
Thoughts? Other than I need to CC a cast of thousands? (I cannot break this up without having git bisect points with busted RCU on ARM.)
Not really - I don't know ARM CPU side stuff in any detail, I mostly work on things external to the SoCs.
Quoted 91 lines · Paul E. McKenney
Quoted 90 lines · Paul E. McKenney
Quoted 48 lines · Eric Dumazet
Quoted 46 lines · Paul E. McKenney
Ah, I see... I need to find one of
trace_power_start(),trace_power_frequency(), ortrace_power_end(). I would have to guess that this is either thetrace_power_start()or thetrace_power_end()called fromdrivers/cpuidle/cpuidle.clines 97 and 102. Those are withincpuidle_idle_call(), which are called fromcpu_idle()inarch/x86/kernel/process_32.candarch/x86/kernel/process_64.c, so this sounds plausible.And they are indeed busted -- RCU believes the CPU is idle at the point that
cpuidle_idle_call()is invoked.A hacky patch is below. Here are some of my concerns with it:
1. Is there a configuration in which the scheduler clock gets
turned off, but in whichcpuidle_idle_call()always returns zero? If so, we either really need RCU to consider the entire inner loop to be idle (thus needing to snapshot the value ofcpuidle_idle_call()in the outer loop) or we need explicit calls torcu_sched_qs()and friends.Yes, we could momentarily exit RCU idleness mode, but I would need to think that one through...
2. I am not totally confident that I have the order of operations
surrounding the call topm_idle()correct.3. This only addresses x86, and it looks like a few other architectures
have this same problem.4. Probably other things that I haven't thought of.
That said, the patch does seem to compile, at least on my 32-bit laptop...
Thanx, Paul
------------------------------------------------------------------------
idle: Avoid using RCU when RCU thinks the CPU is idle
The x86 idle loops invoke
cpuidle_idle_call()which uses tracing which uses RCU. Unfortunately, these idle loops have already told RCU to ignore this CPU when they call it. This patch hacks the idle loops to avoid this problem, but probably causing several other problems in the process.Quoted 8 lines
Quoted 2 lines
Not-yet-signed-off-by Paul E. McKenney <[email protected]>---
Hi Paul
Just tested it on my
x86_64machine, but warnings are still hereThanks !
Gah!!! The
mwait_idle()function itself (which is the default value of thepm_idlefunction pointer) uses tracing and thus RCU! What part of "don't use RCU from idle CPUs" was unclear, one wonders?Ah well, the good news is that we can now detect such abuse and fix it.
But fixing it appears to require pushing
rcu_idle_enter()andrcu_idle_exit()pairs down to the bottom of each and every idle loop and governor.So... The
cpuidle_idle_call()function has an idle loop inside of itself, namely the ->enter() call for the desired target state. It does tracing on both sides of that call. Should the ->enter() calls actually avoid use of tracing, I could push thercu_idle_enter()andrcu_idle_exit()down intocpuidle_idle_call(). We seem to have aladder_governorand amenu_governorin 3.2, and these have states, which in turn have ->enter functions.Hmmm... Residual power dissipation is given in milliwatts. I could imagine some heartburn from many of the more aggressive embedded folks, given that they might prefer microwatts -- or maybe even nanowatts, for all I know.
There are a bunch of states defined in
drivers/idle/intel_idle.c, and these useintel_idle()as their ->enter() states. This one looks to have a nice place forrcu_idle_enter()andrcu_idle_exit().But I also need to push
rcu_idle_enter()andrcu_idle_exit()into any function that can be assigned topm_idle():default_idle(),poll_idle(),mwait_idle(), andamd_e400_idle(). OK, that is not all -that- bad, though this must also be done for a number of other architectures as well.
Quoted 7 lines
Quoted 2 lines
OK, will post a patch. I will need testing -- clearly my testing on KVM is missing a few important code paths...
And here is another version of the patch.
Thanx, Paul
Hello,
I just hit the same problem.
Is this patch scheduled for 3.3 until release or will land during 3.4 merge window?
-ss
Quoted 143 lines
------------------------------------------------------------------------
x86: Avoid invoking RCU when CPU is idle
The idle loop is a quiscent state for RCU, which means that RCU ignores CPUs that have told RCU that they are idle via
rcu_idle_enter(). There are nevertheless quite a few places where idle CPUs use RCU, most commonly indirectly via tracing. This patch fixes these problems for x86.Many of these bugs have been in the kernel for quite some time, but Frederic's recent change now gives warnings.
This patch takes the straightforward approach of pushing the rcu_idle_enter()/rcu_idle_exit() pair further down into the core of the idle loop.
Signed-off-by Paul E. McKenney <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>arch/x86/kernel/process.c +12
-1@@ -386,17 +386,21 @@ void default_idle(void)*/ smp_mb (); +rcu_idle_enter ();if (!need_resched ())safe_halt ();/* enables interrupts racelessly */ else local_irq_enable (); +rcu_idle_exit ();current_thread_info ()->status |=TS_POLLING ;trace_power_end (smp_processor_id ());trace_cpu_idle (PWR_EVENT_EXIT ,smp_processor_id ()); }else {local_irq_enable ();/* loop is done by the caller */ +rcu_idle_enter ();cpu_relax (); +rcu_idle_exit (); } }#ifdef CONFIG_APM_MODULE @@ -457,14 +461,19 @@ static void mwait_idle(void)__monitor ((void *)¤t_thread_info ()->flags,0 ,0 );smp_mb (); +rcu_idle_enter ();if (!need_resched ())__sti_mwait (0 ,0 );else local_irq_enable (); +rcu_idle_exit ();trace_power_end (smp_processor_id ());trace_cpu_idle (PWR_EVENT_EXIT ,smp_processor_id ()); - }else + }else {local_irq_enable (); +rcu_idle_enter (); +rcu_idle_exit (); + } }/* @@ -477,8 +486,10 @@ static void poll_idle(void)trace_power_start (POWER_CSTATE ,0 ,smp_processor_id ());trace_cpu_idle (0 ,smp_processor_id ());local_irq_enable (); +rcu_idle_enter ();while (!need_resched ())cpu_relax (); +rcu_idle_exit ();trace_power_end (smp_processor_id ());trace_cpu_idle (PWR_EVENT_EXIT ,smp_processor_id ()); }arch/x86/kernel/process_32.c +0
-2@@ -100,7 +100,6 @@ void cpu_idle(void)/* endless idle loop with no priority at all */ while (1 ) {tick_nohz_idle_enter (); -rcu_idle_enter ();while (!need_resched ()) {check_pgt_cache ();@@ -117,7 +116,6 @@ void cpu_idle(void)pm_idle ();start_critical_timings (); } -rcu_idle_exit ();tick_nohz_idle_exit ();preempt_enable_no_resched ();schedule ();arch/x86/kernel/process_64.c +0
-4@@ -140,13 +140,9 @@ void cpu_idle(void)/* Don't trace irqs off for idle */ stop_critical_timings (); -/* enter_idle() needs rcu for notifiers */ -rcu_idle_enter (); -if (cpuidle_idle_call ())pm_idle (); -rcu_idle_exit ();start_critical_timings ();/* In many cases the interrupt that ended idle drivers/idle/intel_idle.c +2
-1@@ -261,6 +261,7 @@ static int intel_idle(struct cpuidle_device *dev, kt_before =ktime_get_real ();stop_critical_timings (); +rcu_idle_enter ();if (!need_resched ()) {__monitor ((void *)¤t_thread_info ()->flags,0 ,0 );@@ -268,6 +269,7 @@ static int intel_idle(struct cpuidle_device *dev,if (!need_resched ())__mwait (eax, ecx); } +rcu_idle_exit ();start_critical_timings (); --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 54 lines · Sergey Senozhatsky
Quoted 54 lines
Quoted 53 lines
Quoted 10 lines
------------------------------------------------------------------------
Quoted 9 lines
idle: Avoid using RCU when RCU thinks the CPU is idle
The x86 idle loops invoke
cpuidle_idle_call()which uses tracing which uses RCU. Unfortunately, these idle loops have already told RCU to ignore this CPU when they call it. This patch hacks the idle loops to avoid this problem, but probably causing several other problems in the process.Quoted 8 lines
Quoted 2 lines
Not-yet-signed-off-by Paul E. McKenney <[email protected]>---
Hi Paul
Just tested it on my
x86_64machine, but warnings are still hereThanks !
Gah!!! The
mwait_idle()function itself (which is the default value of thepm_idlefunction pointer) uses tracing and thus RCU! What part of "don't use RCU from idle CPUs" was unclear, one wonders?Ah well, the good news is that we can now detect such abuse and fix it.
But fixing it appears to require pushing
rcu_idle_enter()andrcu_idle_exit()pairs down to the bottom of each and every idle loop and governor.So... The
cpuidle_idle_call()function has an idle loop inside of itself, namely the ->enter() call for the desired target state. It does tracing on both sides of that call. Should the ->enter() calls actually avoid use of tracing, I could push thercu_idle_enter()andrcu_idle_exit()down intocpuidle_idle_call(). We seem to have aladder_governorand amenu_governorin 3.2, and these have states, which in turn have ->enter functions.Hmmm... Residual power dissipation is given in milliwatts. I could imagine some heartburn from many of the more aggressive embedded folks, given that they might prefer microwatts -- or maybe even nanowatts, for all I know.
There are a bunch of states defined in
drivers/idle/intel_idle.c, and these useintel_idle()as their ->enter() states. This one looks to have a nice place forrcu_idle_enter()andrcu_idle_exit().But I also need to push
rcu_idle_enter()andrcu_idle_exit()into any function that can be assigned topm_idle(): default_idle(),poll_idle(),mwait_idle(), andamd_e400_idle(). OK, that is not all -that- bad, though this must also be done for a number of other architectures as well.OK, will post a patch. I will need testing -- clearly my testing on KVM is missing a few important code paths...
Quoted 6 lines
Quoted 1 line
And here is another version of the patch.
Hello,
I just hit the same problem.Is this patch scheduled for 3.3 until release or will land during 3.4 merge window?
There are 3 patches in Paul's 3.4 queue, and another 9 of Steven Rostedt's that fix this. They'll wind up in 3.4.
I looked at reverting the patch that adds this new warning and it doesn't trivially revert.
josh
Quoted 60 lines · Josh Boyer
Quoted 58 lines · Sergey Senozhatsky
Quoted 51 lines
Quoted 51 lines
Quoted 10 lines
------------------------------------------------------------------------
Quoted 9 lines
idle: Avoid using RCU when RCU thinks the CPU is idle
The x86 idle loops invoke
cpuidle_idle_call()which uses tracing which uses RCU. Unfortunately, these idle loops have already told RCU to ignore this CPU when they call it. This patch hacks the idle loops to avoid this problem, but probably causing several other problems in the process.Quoted 8 lines
Quoted 2 lines
Not-yet-signed-off-by Paul E. McKenney <[email protected]>---
Hi Paul
Just tested it on my
x86_64machine, but warnings are still hereThanks !
Gah!!! The
mwait_idle()function itself (which is the default value of thepm_idlefunction pointer) uses tracing and thus RCU! What part of "don't use RCU from idle CPUs" was unclear, one wonders?Ah well, the good news is that we can now detect such abuse and fix it.
But fixing it appears to require pushing
rcu_idle_enter()andrcu_idle_exit()pairs down to the bottom of each and every idle loop and governor.So... The
cpuidle_idle_call()function has an idle loop inside of itself, namely the ->enter() call for the desired target state. It does tracing on both sides of that call. Should the ->enter() calls actually avoid use of tracing, I could push thercu_idle_enter()andrcu_idle_exit()down intocpuidle_idle_call(). We seem to have aladder_governorand amenu_governorin 3.2, and these have states, which in turn have ->enter functions.Hmmm... Residual power dissipation is given in milliwatts. I could imagine some heartburn from many of the more aggressive embedded folks, given that they might prefer microwatts -- or maybe even nanowatts, for all I know.
There are a bunch of states defined in
drivers/idle/intel_idle.c, and these useintel_idle()as their ->enter() states. This one looks to have a nice place forrcu_idle_enter()andrcu_idle_exit().But I also need to push
rcu_idle_enter()andrcu_idle_exit()into any function that can be assigned topm_idle(): default_idle(),poll_idle(),mwait_idle(), andamd_e400_idle(). OK, that is not all -that- bad, though this must also be done for a number of other architectures as well.Quoted 4 lines
Quoted 2 lines
OK, will post a patch. I will need testing -- clearly my testing on KVM is missing a few important code paths...
And here is another version of the patch.
Hello,
I just hit the same problem.
Quoted 8 lines
Quoted 2 lines
Is this patch scheduled for 3.3 until release or will land during 3.4 merge window?
There are 3 patches in Paul's 3.4 queue, and another 9 of Steven Rostedt's that fix this. They'll wind up in 3.4.
I looked at reverting the patch that adds this new warning and it doesn't trivially revert.
What are you based on? I should be able to disable the warning for you easily enough.
Thanx, Paul
Quoted 9 lines · Paul E. McKenney
Quoted 8 lines · Josh Boyer
Quoted 5 lines · Sergey Senozhatsky
Hello,
I just hit the same problem.Is this patch scheduled for 3.3 until release or will land during 3.4 merge window?
Quoted 8 lines
Quoted 5 lines
There are 3 patches in Paul's 3.4 queue, and another 9 of Steven Rostedt's that fix this. They'll wind up in 3.4.
I looked at reverting the patch that adds this new warning and it doesn't trivially revert.
What are you based on? I should be able to disable the warning for you easily enough.
3.3. I think I tried reverting 00f49e5729af602deb559b0cf293a00b625e8636 and it failed. Then I locally commented out the WARN_ONCE in the functions which got rid of that, but we still get a 'suspicious RCU usage' warning when running powertop. I gave up after that, since it all goes away if we disable the debugging options and you have fixes queued for 3.4.
josh
Quoted 17 lines · Josh Boyer
Quoted 15 lines · Paul E. McKenney
Quoted 13 lines · Josh Boyer
Quoted 5 lines · Sergey Senozhatsky
Hello,
I just hit the same problem.Is this patch scheduled for 3.3 until release or will land during 3.4 merge window?
There are 3 patches in Paul's 3.4 queue, and another 9 of Steven Rostedt's that fix this. They'll wind up in 3.4.
I looked at reverting the patch that adds this new warning and it doesn't trivially revert.
Quoted 8 lines
Quoted 2 lines
What are you based on? I should be able to disable the warning for you easily enough.
3.3. I think I tried reverting
00f49e5729af602deb559b0cf293a00b625e8636and it failed. Then I locally commented out theWARN_ONCEin the functions which got rid of that, but we still get a 'suspicious RCU usage' warning when running powertop. I gave up after that, since it all goes away if we disable the debugging options and you have fixes queued for 3.4.
How about the following?
Thanx, Paul
------------------------------------------------------------------------
rcu: hack to disable RCU idle checking
Not for inclusion -- for mainline the correct approach is to fix things so that RCU is not invoked from CPUs that RCU believes to be idle. Use the upcoming RCU_NONIDLE() macro for this, or the new tracing functions designed for use from idle.
kernel/rcutiny.c +1 -1
@@ -169,7 +169,7 @@ void rcu_irq_enter(void)*/ int rcu_is_cpu_idle (void ) { -return !rcu_dynticks_nesting; +return false; }EXPORT_SYMBOL (rcu_is_cpu_idle);
kernel/rcutree.c +1 -6
@@ -572,12 +572,7 @@ void rcu_nmi_exit(void)*/ int rcu_is_cpu_idle (void ) { -int ret; - -preempt_disable (); - ret = (atomic_read (&__get_cpu_var (rcu_dynticks).dynticks) &0x1 ) ==0 ; -preempt_enable (); -return ret; +return false; }EXPORT_SYMBOL (rcu_is_cpu_idle);