Skip to contentSkip to conversation

Fixes for 3.9

PATCH New Paul E. McKenney 1 participant 8 messages Mar 18, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Fixes for 3.9

Hello!

This series contains the following fixes for RCU:

1. Whitespace fix courtesy of Jiang Fang.

2. Avoid raising softirq from CPUs going offline.

3. Remove obsolete CPU-hotplug comment, courtesy of Srivatsa Bhat.

4. Delete unused "wakemask" field.

5. Fix hlist_bl_set_first_rcu() lockdep annotation, courtesy of
Steven Whitehouse.

6. Add softirq-stall indications to stall-warning messages.

7. Restrict self-torture random delays in RCU grace-period initialization
to runtime.

Thanx, Paul

 b/Documentation/RCU/stallwarn.txt |   33 ++++++++++++++++++++++++---------
 b/include/linux/list_bl.h         |    5 +++++
 b/include/linux/rculist_bl.h      |    2 +-
 b/kernel/rcutree.c                |   13 +++++--------
 b/kernel/rcutree.h                |    8 +++++---
 b/kernel/rcutree_plugin.h         |    4 +++-
 6 files changed, 43 insertions(+), 22 deletions(-)
#2 lore raw

PATCH 2/7 rcu: Avoid invoking RCU core on offline CPUs

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

Offline CPUs transition through the scheduler to the idle loop one last time before being shut down. This can result in RCU raising softirq on this CPU, which is at best useless given that the CPU's callbacks will be offloaded at CPU_DEAD time. This commit therefore avoids raising softirq on offline CPUs.

---
 kernel/rcutree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcutree.c +2 -1
index 157539a..b2fc234 100644
@@ -2169,7 +2169,8 @@ static void invoke_rcu_callbacks(struct rcu_state *rsp, struct rcu_data *rdp)
 
 static void invoke_rcu_core(void)
 {
-	raise_softirq(RCU_SOFTIRQ);
+	if (cpu_online(smp_processor_id()))
+		raise_softirq(RCU_SOFTIRQ);
 }
 
 /*
Signature · 1 line
1.8.1.5
#4 lore raw

PATCH 4/7 rcu: Delete unused rcu_node "wakemask" field

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

---
 kernel/rcutree.h | 3 ---
 1 file changed, 3 deletions(-)
kernel/rcutree.h +0 -3
index c896b50..8e75609 100644
@@ -134,9 +134,6 @@ struct rcu_node {
 				/*  elements that need to drain to allow the */
 				/*  current expedited grace period to */
 				/*  complete (only for TREE_PREEMPT_RCU). */
-	atomic_t wakemask;	/* CPUs whose kthread needs to be awakened. */
-				/*  Since this has meaning only for leaf */
-				/*  rcu_node structures, 32 bits suffices. */
 	unsigned long qsmaskinit;
 				/* Per-GP initial value for qsmask & expmask. */
 	unsigned long grpmask;	/* Mask to apply to parent qsmask. */
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH 1/7 rcu: Fix spacing problem

In reply to Paul E. McKenney

From: Jiang Fang <[email protected]>

---
 kernel/rcutree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcutree.c +1 -1
index 5b8ad82..157539a 100644
@@ -3171,7 +3171,7 @@ void __init rcu_init(void)
 	rcu_init_one(&rcu_bh_state, &rcu_bh_data);
 	__rcu_init_preempt();
 	rcu_init_nocb();
-	 open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);
+	open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);
 
 	/*
 	 * We don't need protection against CPU-hotplug here because
Signature · 1 line
1.8.1.5
#7 lore raw

PATCH 7/7 rcu: Tone down debugging during boot-up and shutdown.

From: "Paul E. McKenney" <[email protected]>

In some situations, randomly delaying RCU grace-period initialization can cause more trouble than help. This commit therefore restricts this type of RCU self-torture to runtime, giving it a rest during boot and shutdown.

---
 kernel/rcutree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/rcutree.c +2 -1
index 71df6f9..0e52250 100644
@@ -1319,7 +1319,8 @@ static int rcu_gp_init(struct rcu_state *rsp)
 					    rnp->grphi, rnp->qsmask);
 		raw_spin_unlock_irq(&rnp->lock);
 #ifdef CONFIG_PROVE_RCU_DELAY
-		if ((random32() % (rcu_num_nodes * 8)) == 0)
+		if ((random32() % (rcu_num_nodes * 8)) == 0 &&
+		    system_state == SYSTEM_RUNNING)
 			schedule_timeout_uninterruptible(2);
 #endif /* #ifdef CONFIG_PROVE_RCU_DELAY */
 		cond_resched();
Signature · 1 line
1.8.1.5
#6 lore raw

PATCH 6/7 rcu: Add softirq-stall indications to stall-warning messages

In reply to Paul E. McKenney

From: "Paul E. McKenney" <[email protected]>

If RCU's softirq handler is prevented from executing, an RCU CPU stall warning can result. Ways to prevent RCU's softirq handler from executing
include: (1) CPU spinning with interrupts disabled, (2) infinite loop in some softirq handler, and (3) in -rt kernels, an infinite loop in a set of real-time threads running at priorities higher than that of RCU's softirq handler.

Because this situation can be difficult to track down, this commit causes the count of RCU softirq handler invocations to be printed with RCU CPU stall warnings. This information does require some interpretation, as now documented in Documentation/RCU/stallwarn.txt.

---
 Documentation/RCU/stallwarn.txt | 33 ++++++++++++++++++++++++---------
 kernel/rcutree.h                |  5 +++++
 kernel/rcutree_plugin.h         |  4 +++-
 3 files changed, 32 insertions(+), 10 deletions(-)
Documentation/RCU/stallwarn.txt +24 -9
index 1927151..e38b8df 100644
@@ -92,14 +92,14 @@ If the CONFIG_RCU_CPU_STALL_INFO kernel configuration parameter is set,
 more information is printed with the stall-warning message, for example:
 
 	INFO: rcu_preempt detected stall on CPU
-	0: (63959 ticks this GP) idle=241/3fffffffffffffff/0
+	0: (63959 ticks this GP) idle=241/3fffffffffffffff/0 softirq=82/543
 	   (t=65000 jiffies)
 
 In kernels with CONFIG_RCU_FAST_NO_HZ, even more information is
 printed:
 
 	INFO: rcu_preempt detected stall on CPU
-	0: (64628 ticks this GP) idle=dd5/3fffffffffffffff/0 drain=0 . timer not pending
+	0: (64628 ticks this GP) idle=dd5/3fffffffffffffff/0 softirq=82/543 last_accelerate: a345/d342 nonlazy_posted: 25 .D
 	   (t=65000 jiffies)
 
 The "(64628 ticks this GP)" indicates that this CPU has taken more
@@ -116,13 +116,28 @@ number between the two "/"s is the value of the nesting, which will
 be a small positive number if in the idle loop and a very large positive
 number (as shown above) otherwise.
 
-For CONFIG_RCU_FAST_NO_HZ kernels, the "drain=0" indicates that the CPU is
-not in the process of trying to force itself into dyntick-idle state, the
-"." indicates that the CPU has not given up forcing RCU into dyntick-idle
-mode (it would be "H" otherwise), and the "timer not pending" indicates
-that the CPU has not recently forced RCU into dyntick-idle mode (it
-would otherwise indicate the number of microseconds remaining in this
-forced state).
+The "softirq=" portion of the message tracks the number of RCU softirq
+handlers that the stalled CPU has executed.  The number before the "/"
+is the number that had executed since boot at the time that this CPU
+last noted the beginning of a grace period, which might be the current
+(stalled) grace period, or it might be some earlier grace period (for
+example, if the CPU might have been in dyntick-idle mode for an extended
+time period.  The number after the "/" is the number that have executed
+since boot until the current time.  If this latter number stays constant
+across repeated stall-warning messages, it is possible that RCU's softirq
+handlers are no longer able to execute on this CPU.  This can happen if
+the stalled CPU is spinning with interrupts are disabled, or, in -rt
+kernels, if a high-priority process is starving RCU's softirq handler.
+
+For CONFIG_RCU_FAST_NO_HZ kernels, the "last_accelerate:" prints the
+low-order 16 bits (in hex) of the jiffies counter when this CPU last
+invoked rcu_try_advance_all_cbs() from rcu_needs_cpu() or last invoked
+rcu_accelerate_cbs() from rcu_prepare_for_idle().  The "nonlazy_posted:"
+prints the number of non-lazy callbacks posted since the last call to
+rcu_needs_cpu().  Finally, an "L" indicates that there are currently
+no non-lazy callbacks ("." is printed otherwise, as shown above) and
+"D" indicates that dyntick-idle processing is enabled ("." is printed
+otherwise, for example, if disabled via the "nohz=" kernel boot parameter).
 
 
 Multiple Warnings From One Stall
kernel/rcutree.h +5 -0
index 8e75609..26c9bb3 100644
@@ -325,6 +325,11 @@ struct rcu_data {
 	struct task_struct *nocb_kthread;
 #endif /* #ifdef CONFIG_RCU_NOCB_CPU */
 
+	/* 8) RCU CPU stall data. */
+#ifdef CONFIG_RCU_CPU_STALL_INFO
+	unsigned int softirq_snap;	/* Snapshot of softirq activity. */
+#endif /* #ifdef CONFIG_RCU_CPU_STALL_INFO */
+
 	int cpu;
 	struct rcu_state *rsp;
 };
kernel/rcutree_plugin.h +3 -1
index c1cc7e1..7fcd3bb 100644
@@ -2070,10 +2070,11 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
 		ticks_value = rsp->gpnum - rdp->gpnum;
 	}
 	print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
-	printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
+	printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
 	       cpu, ticks_value, ticks_title,
 	       atomic_read(&rdtp->dynticks) & 0xfff,
 	       rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
+	       rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
 	       fast_no_hz);
 }
 
@@ -2087,6 +2088,7 @@ static void print_cpu_stall_info_end(void)
 static void zero_cpu_stall_ticks(struct rcu_data *rdp)
 {
 	rdp->ticks_this_gp = 0;
+	rdp->softirq_snap = kstat_softirqs_cpu(RCU_SOFTIRQ, smp_processor_id());
 }
 
 /* Increment ->ticks_this_gp for all flavors of RCU. */
Signature · 1 line
1.8.1.5
#3 lore raw

PATCH 3/7 rcu: Remove comment referring to __stop_machine()

In reply to Paul E. McKenney

From: "Srivatsa S. Bhat" <[email protected]>

Although it used to be that CPU_DYING notifiers executed on the outgoing CPU with interrupts disabled and with all other CPUs spinning, this is no longer the case. This commit therefore removes this obsolete comment.

---
 kernel/rcutree.c | 5 -----
 1 file changed, 5 deletions(-)
kernel/rcutree.c +0 -5
index b2fc234..71df6f9 100644
@@ -2931,11 +2931,6 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self,
 		break;
 	case CPU_DYING:
 	case CPU_DYING_FROZEN:
-		/*
-		 * The whole machine is "stopped" except this CPU, so we can
-		 * touch any data without introducing corruption. We send the
-		 * dying CPU's callbacks to an arbitrarily chosen online CPU.
-		 */
 		for_each_rcu_flavor(rsp)
 			rcu_cleanup_dying_cpu(rsp);
 		rcu_cleanup_after_idle(cpu);
Signature · 1 line
1.8.1.5
#5 lore raw

PATCH 5/7 rcu: Fix hlist_bl_set_first_rcu() annotation

In reply to Paul E. McKenney

From: Steven Whitehouse <[email protected]>

Abhi noticed that we were getting a complaint from the RCU subsystem about access of an RCU protected list under the write side bit lock. This commit adds additional annotation to check both the RCU read lock and the write side bit lock before printing a message.

Reported by: Abhijith Das <[email protected]>

---
 include/linux/list_bl.h    | 5 +++++
 include/linux/rculist_bl.h | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
include/linux/list_bl.h +5 -0
index 31f9d75..2eb8855 100644
@@ -125,6 +125,11 @@ static inline void hlist_bl_unlock(struct hlist_bl_head *b)
 	__bit_spin_unlock(0, (unsigned long *)b);
 }
 
+static inline bool hlist_bl_is_locked(struct hlist_bl_head *b)
+{
+	return bit_spin_is_locked(0, (unsigned long *)b);
+}
+
 /**
  * hlist_bl_for_each_entry	- iterate over list of given type
  * @tpos:	the type * to use as a loop cursor.
include/linux/rculist_bl.h +1 -1
index cf1244f..4f216c5 100644
@@ -20,7 +20,7 @@ static inline void hlist_bl_set_first_rcu(struct hlist_bl_head *h,
 static inline struct hlist_bl_node *hlist_bl_first_rcu(struct hlist_bl_head *h)
 {
 	return (struct hlist_bl_node *)
-		((unsigned long)rcu_dereference(h->first) & ~LIST_BL_LOCKMASK);
+		((unsigned long)rcu_dereference_check(h->first, hlist_bl_is_locked(h)) & ~LIST_BL_LOCKMASK);
 }
 
 /**
Signature · 1 line
1.8.1.5