Skip to contentSkip to conversation

Miscellaneous fixes for v4.21/v5.0

PATCH New Paul E. McKenney 1 participant 15 messages Nov 11, 2018

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

cover Miscellaneous fixes for v4.21/v5.0

Hello!

This series contains miscellaneous fixes:

1. Stop expedited grace periods from relying on stop-machine.

2. Update IBM maintainers' email addresses from @linux.vnet.ibm.com
to @linux.ibm.com.

3. Avoid double multiply by HZ in rcu_check_gp_start_stall().

4. Parameterize rcu_check_gp_start_stall() to allow common code
between RCU CPU stall warnings and warnings about slow-to-start grace periods.

5. Add state name to show_rcu_gp_kthreads() output.

6. Add jiffies-since-GP-activity to show_rcu_gp_kthreads().

7. Adjust the comment of function rcu_is_watching, courtesy of
Zhouyi Zhou.

8. Trace end of grace period before end of grace period.

9. Speed up expedited GPs when interrupting RCU reader.

10. Replace this_cpu_ptr() with __this_cpu_read() in
rcu_preempt_need_deferred_qs()

11. Avoid signed integer overflow in rcu_preempt_deferred_qs().

12. Add Joel Fernandes as RCU reviewer in MAINTAINERS file.

13. Create table of obsolete APIs in checkpatch.pl and apply to RCU,
courtesy of Joe Perches.

14. Make checkpatch.pl suggest lockdep instead of asserting

	!spin_is_locked().

							Thanx, Paul

------------------------------------------------------------------------

 MAINTAINERS              |   73 +++++++++++++++++++++--------------------------
 include/linux/sched.h    |    4 +-
 kernel/rcu/tree.c        |   53 ++++++++++++++++++----------------
 kernel/rcu/tree_exp.h    |   10 ++++--
 kernel/rcu/tree_plugin.h |   37 ++++++++++++++++-------
 scripts/checkpatch.pl    |   35 ++++++++++++++++++++++
 6 files changed, 132 insertions(+), 80 deletions(-)
#1 lore raw

PATCH 1/14 rcu: Stop expedited grace periods from relying on stop-machine

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

The CPU-selection code in sync_rcu_exp_select_cpus() disables preemption to prevent the cpu_online_mask from changing. However, this relies on the stop-machine mechanism in the CPU-hotplug offline code, which is not desirable (it would be good to someday remove the stop-machine mechanism).

This commit therefore instead uses the relevant leaf rcu_node structure's ->ffmask, which has a bit set for all CPUs that are fully functional. A given CPU's bit is cleared very early during offline processing by rcutree_offline_cpu() and set very late during online processing by rcutree_online_cpu(). Therefore, if a CPU's bit is set in this mask, and preemption is disabled, we have to be before the synchronize_sched() in the CPU-hotplug offline code, which means that the CPU is guaranteed to be workqueue-ready throughout the duration of the enclosing preempt_disable() region of code.

This also has the side-effect of using WORK_CPU_UNBOUND if all the CPUs for this leaf rcu_node structure are offline, which is an acceptable difference in behavior.

---
 kernel/rcu/tree_exp.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/rcu/tree_exp.h +4 -2
index 8d18c1014e2b..e669ccf3751b 100644
@@ -450,10 +450,12 @@ static void sync_rcu_exp_select_cpus(smp_call_func_t func)
 		}
 		INIT_WORK(&rnp->rew.rew_work, sync_rcu_exp_select_node_cpus);
 		preempt_disable();
-		cpu = cpumask_next(rnp->grplo - 1, cpu_online_mask);
+		cpu = find_next_bit(&rnp->ffmask, BITS_PER_LONG, -1);
 		/* If all offline, queue the work on an unbound CPU. */
-		if (unlikely(cpu > rnp->grphi))
+		if (unlikely(cpu > rnp->grphi - rnp->grplo))
 			cpu = WORK_CPU_UNBOUND;
+		else
+			cpu += rnp->grplo;
 		queue_work_on(cpu, rcu_par_gp_wq, &rnp->rew.rew_work);
 		preempt_enable();
 		rnp->exp_need_flush = true;
Signature · 1 line
2.17.1
#10 lore raw

PATCH 10/14 rcu: Replace this_cpu_ptr() with __this_cpu_read()

In reply to Paul E. McKenney

Because __this_cpu_read() can be lighter weight than equivalent uses of this_cpu_ptr(), this commit replaces the latter with the former.

---
 kernel/rcu/tree_plugin.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree_plugin.h +1 -1
index 618956cc7a55..0bb1c1593ca4 100644
@@ -597,7 +597,7 @@ rcu_preempt_deferred_qs_irqrestore(struct task_struct *t, unsigned long flags)
  */
 static bool rcu_preempt_need_deferred_qs(struct task_struct *t)
 {
-	return (this_cpu_ptr(&rcu_data)->deferred_qs ||
+	return (__this_cpu_read(rcu_data.deferred_qs) ||
 		READ_ONCE(t->rcu_read_unlock_special.s)) &&
 	       t->rcu_read_lock_nesting <= 0;
 }
Signature · 1 line
2.17.1
#12 lore raw

PATCH 12/14 MAINTAINERS: Add Joel Fernandes as RCU reviewer

In reply to Paul E. McKenney
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 1b80a021f542..188809580d5e 100644
@@ -12533,6 +12533,7 @@ M:	Josh Triplett <[email protected]>
 R:	Steven Rostedt <[email protected]>
 R:	Mathieu Desnoyers <[email protected]>
 R:	Lai Jiangshan <[email protected]>
+R:	Joel Fernandes <[email protected]>
 L:	[email protected]
 W:	http://www.rdrop.com/users/paulmck/RCU/
 S:	Supported
Signature · 1 line
2.17.1
#13 lore raw

PATCH 13/14 checkpatch: Create table of obsolete APIs and apply to RCU

In reply to Paul E. McKenney

From: Joe Perches <[email protected]>

This patch creates a deprecated_apis map, which allows such APIs to be flagged with suggested replacements more compactly and straightforwardly. It also uses this map to flag the old flavorful RCU APIs as deprecated, suggesting their vanilla-RCU counterparts as replacements.

Cc Andy Whitcroft <[email protected]>
[ paulmck: Merged with earlier less-deft approach. ]
---
 scripts/checkpatch.pl | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
scripts/checkpatch.pl +29 -0
index c883ec55654f..dd29e3c28166 100755
@@ -573,6 +573,27 @@ foreach my $entry (@mode_permission_funcs) {
 }
 $mode_perms_search = "(?:${mode_perms_search})";
 
+our %deprecated_apis = (
+	"synchronize_rcu_bh"			=> "synchronize_rcu",
+	"synchronize_rcu_bh_expedited"		=> "synchronize_rcu_expedited",
+	"call_rcu_bh"				=> "call_rcu",
+	"rcu_barrier_bh"			=> "rcu_barrier",
+	"synchronize_sched"			=> "synchronize_rcu",
+	"synchronize_sched_expedited"		=> "synchronize_rcu_expedited",
+	"call_rcu_sched"			=> "call_rcu",
+	"rcu_barrier_sched"			=> "rcu_barrier",
+	"get_state_synchronize_sched"		=> "get_state_synchronize_rcu",
+	"cond_synchronize_sched"		=> "cond_synchronize_rcu",
+);
+
+#Create a search pattern for all these strings to speed up a loop below
+our $deprecated_apis_search = "";
+foreach my $entry (keys %deprecated_apis) {
+	$deprecated_apis_search .= '|' if ($deprecated_apis_search ne "");
+	$deprecated_apis_search .= $entry;
+}
+$deprecated_apis_search = "(?:${deprecated_apis_search})";
+
 our $mode_perms_world_writable = qr{
 	S_IWUGO		|
 	S_IWOTH		|
@@ -6368,6 +6389,14 @@ sub process {
 			     "please use device_initcall() or more appropriate function instead of __initcall() (see include/linux/init.h)\n" . $herecurr);
 		}
 
+# check for deprecated apis
+		if ($line =~ /\b($deprecated_apis_search)\b\s*\(/) {
+			my $deprecated_api = $1;
+			my $new_api = $deprecated_apis{$deprecated_api};
+			WARN("DEPRECATED_API",
+			     "Deprecated use of '$deprecated_api', prefer '$new_api' instead\n" . $herecurr);
+		}
+
 # check for various structs that are normally const (ops, kgdb, device_tree)
 # and avoid what seem like struct definitions 'struct foo {'
 		if ($line !~ /\bconst\b/ &&
Signature · 1 line
2.17.1
#6 lore raw

PATCH 6/14 rcu: Add jiffies-since-GP-activity to show_rcu_gp_kthreads()

In reply to Paul E. McKenney

This commit adds a printout of the number of jiffies since the last time that the RCU grace-period kthread did any processing. This can be useful when tracking down forward-progress issues.

---
 kernel/rcu/tree.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/rcu/tree.c +5 -3
index ea78532183ac..e7c9848d1e1b 100644
@@ -515,12 +515,14 @@ static const char *gp_state_getname(short gs)
 void show_rcu_gp_kthreads(void)
 {
 	int cpu;
+	unsigned long j;
 	struct rcu_data *rdp;
 	struct rcu_node *rnp;
 
-	pr_info("%s: wait state: %s(%d) ->state: %#lx\n", rcu_state.name,
-		gp_state_getname(rcu_state.gp_state), rcu_state.gp_state,
-		rcu_state.gp_kthread->state);
+	j = jiffies - READ_ONCE(rcu_state.gp_activity);
+	pr_info("%s: wait state: %s(%d) ->state: %#lx delta ->gp_activity %ld\n",
+		rcu_state.name, gp_state_getname(rcu_state.gp_state),
+		rcu_state.gp_state, rcu_state.gp_kthread->state, j);
 	rcu_for_each_node_breadth_first(rnp) {
 		if (ULONG_CMP_GE(rcu_state.gp_seq, rnp->gp_seq_needed))
 			continue;
Signature · 1 line
2.17.1
#8 lore raw

PATCH 8/14 rcu: Trace end of grace period before end of grace period

In reply to Paul E. McKenney

Currently, rcu_gp_cleanup() traces the end of the old grace period after the old grace period has officially ended. This might make intuitive sense, but it also makes for confusing event-trace output because the "end" trace displays not the old but instead the new grace-period number. This commit therefore traces the end of an old grace period just before that grace period officially ends.

---
 kernel/rcu/tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/tree.c +2 -2
index 429a46fb087a..61bae41b1afe 100644
@@ -2035,9 +2035,9 @@ static void rcu_gp_cleanup(void)
 	rnp = rcu_get_root();
 	raw_spin_lock_irq_rcu_node(rnp); /* GP before ->gp_seq update. */
 
-	/* Declare grace period done. */
-	rcu_seq_end(&rcu_state.gp_seq);
+	/* Declare grace period done, trace first to use old GP number. */
 	trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq, TPS("end"));
+	rcu_seq_end(&rcu_state.gp_seq);
 	rcu_state.gp_state = RCU_GP_IDLE;
 	/* Check for GP requests since above loop. */
 	rdp = this_cpu_ptr(&rcu_data);
Signature · 1 line
2.17.1
#11 lore raw

PATCH 11/14 rcu: Avoid signed integer overflow in rcu_preempt_deferred_qs()

In reply to Paul E. McKenney

Subtracting INT_MIN can be interpreted as unconditional signed integer overflow, which according to the C standard is undefined behavior. Therefore, kernel build arguments notwithstanding, it would be good to future-proof the code. This commit therefore substitutes INT_MAX for INT_MIN in order to avoid undefined behavior.

While in the neighborhood, this commit also creates some meaningful names for INT_MAX and friends in order to improve readability, as suggested by Joel Fernandes.

---
 kernel/rcu/tree_plugin.h | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
kernel/rcu/tree_plugin.h +13 -8
index 0bb1c1593ca4..3ed43f8cb029 100644
@@ -397,6 +397,11 @@ static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp)
 	return rnp->gp_tasks != NULL;
 }
 
+/* Bias and limit values for ->rcu_read_lock_nesting. */
+#define RCU_NEST_BIAS INT_MAX
+#define RCU_NEST_NMAX (-INT_MAX / 2)
+#define RCU_NEST_PMAX (INT_MAX / 2)
+
 /*
  * Preemptible RCU implementation for rcu_read_lock().
  * Just increment ->rcu_read_lock_nesting, shared state will be updated
@@ -405,6 +410,8 @@ static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp)
 void __rcu_read_lock(void)
 {
 	current->rcu_read_lock_nesting++;
+	if (IS_ENABLED(CONFIG_PROVE_LOCKING))
+		WARN_ON_ONCE(current->rcu_read_lock_nesting > RCU_NEST_PMAX);
 	barrier();  /* critical section after entry code. */
 }
 EXPORT_SYMBOL_GPL(__rcu_read_lock);
@@ -424,20 +431,18 @@ void __rcu_read_unlock(void)
 		--t->rcu_read_lock_nesting;
 	} else {
 		barrier();  /* critical section before exit code. */
-		t->rcu_read_lock_nesting = INT_MIN;
+		t->rcu_read_lock_nesting = -RCU_NEST_BIAS;
 		barrier();  /* assign before ->rcu_read_unlock_special load */
 		if (unlikely(READ_ONCE(t->rcu_read_unlock_special.s)))
 			rcu_read_unlock_special(t);
 		barrier();  /* ->rcu_read_unlock_special load before assign */
 		t->rcu_read_lock_nesting = 0;
 	}
-#ifdef CONFIG_PROVE_LOCKING
-	{
-		int rrln = READ_ONCE(t->rcu_read_lock_nesting);
+	if (IS_ENABLED(CONFIG_PROVE_LOCKING)) {
+		int rrln = t->rcu_read_lock_nesting;
 
-		WARN_ON_ONCE(rrln < 0 && rrln > INT_MIN / 2);
+		WARN_ON_ONCE(rrln < 0 && rrln > RCU_NEST_NMAX);
 	}
-#endif /* #ifdef CONFIG_PROVE_LOCKING */
 }
 EXPORT_SYMBOL_GPL(__rcu_read_unlock);
 
@@ -617,11 +622,11 @@ static void rcu_preempt_deferred_qs(struct task_struct *t)
 	if (!rcu_preempt_need_deferred_qs(t))
 		return;
 	if (couldrecurse)
-		t->rcu_read_lock_nesting -= INT_MIN;
+		t->rcu_read_lock_nesting -= RCU_NEST_BIAS;
 	local_irq_save(flags);
 	rcu_preempt_deferred_qs_irqrestore(t, flags);
 	if (couldrecurse)
-		t->rcu_read_lock_nesting += INT_MIN;
+		t->rcu_read_lock_nesting += RCU_NEST_BIAS;
 }
 
 /*
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/14 MAINTAINERS: Update from @linux.vnet.ibm.com to @linux.ibm.com

In reply to Paul E. McKenney

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

IBM's patch-friendly email infrastructure is changing domains from @linux.vnet.ibm.com to @linux.ibm.com, which if nothing else might save a bit of typing. This commit therefore updates us stragglers' email addresses in the MAINTAINERS file. The old addresses are expected to continue to work for a few more months.

While in the neighborhood, remove some obsolete entries, which results in an orphaned subsystem: "JSM Neo PCI based serial card".

Cc Douglas Miller <[email protected]>
Cc Eddie James <[email protected]>
Cc Frank Haverkamp <[email protected]>
Cc Frederic Barrat <[email protected]>
Cc John Allen <[email protected]>
Cc Manoj N. Kumar <[email protected]>
Cc Matthew R. Ochs <[email protected]>
Cc Michael Cyr <[email protected]>
Cc Mimi Zohar <[email protected]>
Cc Naveen N. Rao <[email protected]>
Cc Paulo Flabiano Smorigo <[email protected]>
Cc Philip Kelleher <[email protected]>
Cc Steven Royer <[email protected]>
Cc Thomas Falcon <[email protected]>
Cc Tyrel Datwyler <[email protected]>
Cc Uma Krishnan <[email protected]>
---
 MAINTAINERS | 72 ++++++++++++++++++++++++-----------------------------
 1 file changed, 33 insertions(+), 39 deletions(-)
MAINTAINERS +33 -39
index f4855974f325..1b80a021f542 100644
@@ -4033,7 +4033,7 @@ S:	Supported
 F:	drivers/net/ethernet/chelsio/cxgb4vf/
 
 CXL (IBM Coherent Accelerator Processor Interface CAPI) DRIVER
-M:	Frederic Barrat <[email protected]>
+M:	Frederic Barrat <[email protected]>
 M:	Andrew Donnellan <[email protected]>
 L:	[email protected]
 S:	Supported
@@ -4045,9 +4045,9 @@ F:	Documentation/powerpc/cxl.txt
 F:	Documentation/ABI/testing/sysfs-class-cxl
 
 CXLFLASH (IBM Coherent Accelerator Processor Interface CAPI Flash) SCSI DRIVER
-M:	Manoj N. Kumar <[email protected]>
-M:	Matthew R. Ochs <[email protected]>
-M:	Uma Krishnan <[email protected]>
+M:	Manoj N. Kumar <[email protected]>
+M:	Matthew R. Ochs <[email protected]>
+M:	Uma Krishnan <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	drivers/scsi/cxlflash/
@@ -5428,7 +5428,7 @@ S:	Orphan
 F:	fs/efs/
 
 EHEA (IBM pSeries eHEA 10Gb ethernet adapter) DRIVER
-M:	Douglas Miller <[email protected]>
+M:	Douglas Miller <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	drivers/net/ethernet/ibm/ehea/
@@ -5565,7 +5565,7 @@ F:	Documentation/filesystems/ext4/ext4.rst
 F:	fs/ext4/
 
 Extended Verification Module (EVM)
-M:	Mimi Zohar <[email protected]>
+M:	Mimi Zohar <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	security/integrity/evm/
@@ -5775,7 +5775,7 @@ F:	include/linux/firmware.h
 
 FLASH ADAPTER DRIVER (IBM Flash Adapter 900GB Full Height PCI Flash Card)
 M:	Joshua Morris <[email protected]>
-M:	Philip Kelleher <[email protected]>
+M:	Philip Kelleher <[email protected]>
 S:	Maintained
 F:	drivers/block/rsxx/
 
@@ -6042,7 +6042,7 @@ F:	include/linux/fscrypt*.h
 F:	Documentation/filesystems/fscrypt.rst
 
 FSI-ATTACHED I2C DRIVER
-M:	Eddie James <[email protected]>
+M:	Eddie James <[email protected]>
 L:	[email protected]
 L:	[email protected] (moderated for non-subscribers)
 S:	Maintained
@@ -6218,8 +6218,7 @@ S:	Supported
 F:	drivers/uio/uio_pci_generic.c
 
 GENWQE (IBM Generic Workqueue Card)
-M:	Frank Haverkamp <[email protected]>
-M:	Guilherme G. Piccoli <[email protected]>
+M:	Frank Haverkamp <[email protected]>
 S:	Supported
 F:	drivers/misc/genwqe/
 
@@ -7001,8 +7000,7 @@ F:	crypto/842.c
 F:	lib/842/
 
 IBM Power in-Nest Crypto Acceleration
-M:	Leonidas S. Barbosa <[email protected]>
-M:	Paulo Flabiano Smorigo <[email protected]>
+M:	Paulo Flabiano Smorigo <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	drivers/crypto/nx/Makefile
@@ -7019,8 +7017,8 @@ S:	Supported
 F:	drivers/scsi/ipr.*
 
 IBM Power SRIOV Virtual NIC Device Driver
-M:	Thomas Falcon <[email protected]>
-M:	John Allen <[email protected]>
+M:	Thomas Falcon <[email protected]>
+M:	John Allen <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	drivers/net/ethernet/ibm/ibmvnic.*
@@ -7035,41 +7033,38 @@ F:	arch/powerpc/include/asm/vas.h
 F:	arch/powerpc/include/uapi/asm/vas.h
 
 IBM Power Virtual Ethernet Device Driver
-M:	Thomas Falcon <[email protected]>
+M:	Thomas Falcon <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	drivers/net/ethernet/ibm/ibmveth.*
 
 IBM Power Virtual FC Device Drivers
-M:	Tyrel Datwyler <[email protected]>
+M:	Tyrel Datwyler <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	drivers/scsi/ibmvscsi/ibmvfc*
 
 IBM Power Virtual Management Channel Driver
-M:	Bryant G. Ly <[email protected]>
-M:	Steven Royer <[email protected]>
+M:	Steven Royer <[email protected]>
 S:	Supported
 F:	drivers/misc/ibmvmc.*
 
 IBM Power Virtual SCSI Device Drivers
-M:	Tyrel Datwyler <[email protected]>
+M:	Tyrel Datwyler <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	drivers/scsi/ibmvscsi/ibmvscsi*
 F:	include/scsi/viosrp.h
 
 IBM Power Virtual SCSI Device Target Driver
-M:	Bryant G. Ly <[email protected]>
-M:	Michael Cyr <[email protected]>
+M:	Michael Cyr <[email protected]>
 L:	[email protected]
 L:	[email protected]
 S:	Supported
 F:	drivers/scsi/ibmvscsi_tgt/
 
 IBM Power VMX Cryptographic instructions
-M:	Leonidas S. Barbosa <[email protected]>
-M:	Paulo Flabiano Smorigo <[email protected]>
+M:	Paulo Flabiano Smorigo <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	drivers/crypto/vmx/Makefile
@@ -7346,7 +7341,7 @@ S:	Maintained
 L:	[email protected]
 
 INTEGRITY MEASUREMENT ARCHITECTURE (IMA)
-M:	Mimi Zohar <[email protected]>
+M:	Mimi Zohar <[email protected]>
 M:	Dmitry Kasatkin <[email protected]>
 L:	[email protected]
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git
@@ -7938,9 +7933,8 @@ S:	Maintained
 F:	drivers/media/platform/rcar_jpu.c
 
 JSM Neo PCI based serial card
-M:	Guilherme G. Piccoli <[email protected]>
 L:	[email protected]
-S:	Maintained
+S:	Orphan
 F:	drivers/tty/serial/jsm/
 
 K10TEMP HARDWARE MONITORING DRIVER
@@ -8170,7 +8164,7 @@ F:	include/uapi/linux/kexec.h
 F:	kernel/kexec*
 
 KEYS-ENCRYPTED
-M:	Mimi Zohar <[email protected]>
+M:	Mimi Zohar <[email protected]>
 L:	[email protected]
 L:	[email protected]
 S:	Supported
@@ -8179,9 +8173,9 @@ F:	include/keys/encrypted-type.h
 F:	security/keys/encrypted-keys/
 
 KEYS-TRUSTED
-M:	James Bottomley <[email protected]>
+M:	James Bottomley <[email protected]>
 M:      Jarkko Sakkinen <[email protected]>
-M:	Mimi Zohar <[email protected]>
+M:	Mimi Zohar <[email protected]>
 L:	[email protected]
 L:	[email protected]
 S:	Supported
@@ -8234,7 +8228,7 @@ F:	lib/test_kmod.c
 F:	tools/testing/selftests/kmod/
 
 KPROBES
-M:	Naveen N. Rao <[email protected]>
+M:	Naveen N. Rao <[email protected]>
 M:	Anil S Keshavamurthy <[email protected]>
 M:	"David S. Miller" <[email protected]>
 M:	Masami Hiramatsu <[email protected]>
@@ -8590,7 +8584,7 @@ M:	Nicholas Piggin <[email protected]>
 M:	David Howells <[email protected]>
 M:	Jade Alglave <[email protected]>
 M:	Luc Maranget <[email protected]>
-M:	"Paul E. McKenney" <[email protected]>
+M:	"Paul E. McKenney" <[email protected]>
 R:	Akira Yokosawa <[email protected]>
 R:	Daniel Lustig <[email protected]>
 L:	[email protected]
@@ -9548,7 +9542,7 @@ F:	drivers/platform/x86/mlx-platform.c
 
 MEMBARRIER SUPPORT
 M:	Mathieu Desnoyers <[email protected]>
-M:	"Paul E. McKenney" <[email protected]>
+M:	"Paul E. McKenney" <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	kernel/sched/membarrier.c
@@ -10686,7 +10680,7 @@ S:	Supported
 F:	tools/objtool/
 
 OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER
-M:	Frederic Barrat <[email protected]>
+M:	Frederic Barrat <[email protected]>
 M:	Andrew Donnellan <[email protected]>
 L:	[email protected]
 S:	Supported
@@ -12487,7 +12481,7 @@ S:	Orphan
 F:	drivers/net/wireless/ray*
 
 RCUTORTURE TEST FRAMEWORK
-M:	"Paul E. McKenney" <[email protected]>
+M:	"Paul E. McKenney" <[email protected]>
 M:	Josh Triplett <[email protected]>
 R:	Steven Rostedt <[email protected]>
 R:	Mathieu Desnoyers <[email protected]>
@@ -12534,7 +12528,7 @@ F:	arch/x86/include/asm/intel_rdt_sched.h
 F:	Documentation/x86/intel_rdt*
 
 READ-COPY UPDATE (RCU)
-M:	"Paul E. McKenney" <[email protected]>
+M:	"Paul E. McKenney" <[email protected]>
 M:	Josh Triplett <[email protected]>
 R:	Steven Rostedt <[email protected]>
 R:	Mathieu Desnoyers <[email protected]>
@@ -12674,7 +12668,7 @@ F:	include/linux/reset-controller.h
 RESTARTABLE SEQUENCES SUPPORT
 M:	Mathieu Desnoyers <[email protected]>
 M:	Peter Zijlstra <[email protected]>
-M:	"Paul E. McKenney" <[email protected]>
+M:	"Paul E. McKenney" <[email protected]>
 M:	Boqun Feng <[email protected]>
 L:	[email protected]
 S:	Supported
@@ -13199,7 +13193,7 @@ F:	drivers/scsi/sg.c
 F:	include/scsi/sg.h
 
 SCSI SUBSYSTEM
-M:	"James E.J. Bottomley" <[email protected]>
+M:	"James E.J. Bottomley" <[email protected]>
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git
 M:	"Martin K. Petersen" <[email protected]>
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
@@ -13634,7 +13628,7 @@ F:	mm/sl?b*
 
 SLEEPABLE READ-COPY UPDATE (SRCU)
 M:	Lai Jiangshan <[email protected]>
-M:	"Paul E. McKenney" <[email protected]>
+M:	"Paul E. McKenney" <[email protected]>
 M:	Josh Triplett <[email protected]>
 R:	Steven Rostedt <[email protected]>
 R:	Mathieu Desnoyers <[email protected]>
@@ -15057,7 +15051,7 @@ F:	drivers/platform/x86/topstar-laptop.c
 
 TORTURE-TEST MODULES
 M:	Davidlohr Bueso <[email protected]>
-M:	"Paul E. McKenney" <[email protected]>
+M:	"Paul E. McKenney" <[email protected]>
 M:	Josh Triplett <[email protected]>
 L:	[email protected]
 S:	Supported
Signature · 1 line
2.17.1
#14 lore raw

PATCH 14/14 checkpatch.pl: Suggest lockdep instead of asserting !spin_is_locked()

In reply to Paul E. McKenney

This commit points people who might otherwise code up something like WARN_ON(!spin_is_locked(&mylock)) to lockdep_assert_held(&mylock).

Cc Andy Whitcroft <[email protected]>
Cc Joe Perches <[email protected]>
---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/checkpatch.pl +6 -0
index dd29e3c28166..377f373db6c0 100755
@@ -6389,6 +6389,12 @@ sub process {
 			     "please use device_initcall() or more appropriate function instead of __initcall() (see include/linux/init.h)\n" . $herecurr);
 		}
 
+# check for spin_is_locked(), suggest lockdep instead
+		if ($line =~ /\bspin_is_locked\(/) {
+			WARN("USE_LOCKDEP",
+			     "Where possible, use lockdep_assert_held instead of assertions based on spin_is_locked\n" . $herecurr);
+		}
+
 # check for deprecated apis
 		if ($line =~ /\b($deprecated_apis_search)\b\s*\(/) {
 			my $deprecated_api = $1;
Signature · 1 line
2.17.1
#9 lore raw

PATCH 9/14 rcu: Speed up expedited GPs when interrupting RCU reader

In reply to Paul E. McKenney

In PREEMPT kernels, an expedited grace period might send an IPI to a CPU that is executing an RCU read-side critical section. In that case, it would be nice if the rcu_read_unlock() directly interacted with the RCU core code to immediately report the quiescent state. And this does happen in the case where the reader has been preempted. But it would also be a nice performance optimization if immediate reporting also happened in the preemption-free case.

This commit therefore adds an ->exp_hint field to the task_struct structure's ->rcu_read_unlock_special field. The IPI handler sets this hint when it has interrupted an RCU read-side critical section, and this causes the outermost rcu_read_unlock() call to invoke rcu_read_unlock_special(), which, if preemption is enabled, reports the quiescent state immediately. If preemption is disabled, then the report is required to be deferred until preemption (or bottom halves or interrupts or whatever) is re-enabled.

Because this is a hint, it does nothing for more complicated cases. For example, if the IPI interrupts an RCU reader, but interrupts are disabled across the rcu_read_unlock(), but another rcu_read_lock() is executed before interrupts are re-enabled, the hint will already have been cleared. If you do crazy things like this, reporting will be deferred until some later RCU_SOFTIRQ handler, context switch, cond_resched(), or similar.

---
 include/linux/sched.h    |  4 +++-
 kernel/rcu/tree_exp.h    |  4 +++-
 kernel/rcu/tree_plugin.h | 14 +++++++++++---
 3 files changed, 17 insertions(+), 5 deletions(-)
include/linux/sched.h +3 -1
index a51c13c2b1a0..e4c7b6241088 100644
@@ -572,8 +572,10 @@ union rcu_special {
 	struct {
 		u8			blocked;
 		u8			need_qs;
+		u8			exp_hint; /* Hint for performance. */
+		u8			pad; /* No garbage from compiler! */
 	} b; /* Bits. */
-	u16 s; /* Set of bits. */
+	u32 s; /* Set of bits. */
 };
 
 enum perf_event_task_context {
kernel/rcu/tree_exp.h +3 -1
index e669ccf3751b..928fe5893a57 100644
@@ -692,8 +692,10 @@ static void sync_rcu_exp_handler(void *unused)
 	 */
 	if (t->rcu_read_lock_nesting > 0) {
 		raw_spin_lock_irqsave_rcu_node(rnp, flags);
-		if (rnp->expmask & rdp->grpmask)
+		if (rnp->expmask & rdp->grpmask) {
 			rdp->deferred_qs = true;
+			WRITE_ONCE(t->rcu_read_unlock_special.b.exp_hint, true);
+		}
 		raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
 	}
 
kernel/rcu/tree_plugin.h +11 -3
index 05915e536336..618956cc7a55 100644
@@ -642,13 +642,21 @@ static void rcu_read_unlock_special(struct task_struct *t)
 
 	local_irq_save(flags);
 	irqs_were_disabled = irqs_disabled_flags(flags);
-	if ((preempt_bh_were_disabled || irqs_were_disabled) &&
-	    t->rcu_read_unlock_special.b.blocked) {
+	if (preempt_bh_were_disabled || irqs_were_disabled) {
+		WRITE_ONCE(t->rcu_read_unlock_special.b.exp_hint, false);
 		/* Need to defer quiescent state until everything is enabled. */
-		raise_softirq_irqoff(RCU_SOFTIRQ);
+		if (irqs_were_disabled) {
+			/* Enabling irqs does not reschedule, so... */
+			raise_softirq_irqoff(RCU_SOFTIRQ);
+		} else {
+			/* Enabling BH or preempt does reschedule, so... */
+			set_tsk_need_resched(current);
+			set_preempt_need_resched();
+		}
 		local_irq_restore(flags);
 		return;
 	}
+	WRITE_ONCE(t->rcu_read_unlock_special.b.exp_hint, false);
 	rcu_preempt_deferred_qs_irqrestore(t, flags);
 }
 
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/14 rcu: Avoid double multiply by HZ

In reply to Paul E. McKenney

The rcu_check_gp_start_stall() function multiplies the return value from rcu_jiffies_till_stall_check() by HZ, but the units are already in jiffies. This commit therefore avoids the need for introduction of a jiffies-squared unit by removing the extraneous multiplication.

---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
index 121f833acd04..4933f5d9d992 100644
@@ -2603,7 +2603,7 @@ static void force_quiescent_state(void)
 static void
 rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp)
 {
-	const unsigned long gpssdelay = rcu_jiffies_till_stall_check() * HZ;
+	const unsigned long gpssdelay = rcu_jiffies_till_stall_check();
 	unsigned long flags;
 	unsigned long j;
 	struct rcu_node *rnp_root = rcu_get_root();
Signature · 1 line
2.17.1
#5 lore raw

PATCH 5/14 rcu: Add state name to show_rcu_gp_kthreads() output

In reply to Paul E. McKenney

This commit adds the name of the RCU grace-period state to the show_rcu_gp_kthreads() output in order to ease debugging. This commit also moves gp_state_getname() up in the code so that show_rcu_gp_kthreads() can use it.

---
 kernel/rcu/tree.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
kernel/rcu/tree.c +13 -12
index 36e30150e1e9..ea78532183ac 100644
@@ -499,6 +499,16 @@ void rcu_force_quiescent_state(void)
 }
 EXPORT_SYMBOL_GPL(rcu_force_quiescent_state);
 
+/*
+ * Convert a ->gp_state value to a character string.
+ */
+static const char *gp_state_getname(short gs)
+{
+	if (gs < 0 || gs >= ARRAY_SIZE(gp_state_names))
+		return "???";
+	return gp_state_names[gs];
+}
+
 /*
  * Show the state of the grace-period kthreads.
  */
@@ -508,8 +518,9 @@ void show_rcu_gp_kthreads(void)
 	struct rcu_data *rdp;
 	struct rcu_node *rnp;
 
-	pr_info("%s: wait state: %d ->state: %#lx\n", rcu_state.name,
-		rcu_state.gp_state, rcu_state.gp_kthread->state);
+	pr_info("%s: wait state: %s(%d) ->state: %#lx\n", rcu_state.name,
+		gp_state_getname(rcu_state.gp_state), rcu_state.gp_state,
+		rcu_state.gp_kthread->state);
 	rcu_for_each_node_breadth_first(rnp) {
 		if (ULONG_CMP_GE(rcu_state.gp_seq, rnp->gp_seq_needed))
 			continue;
@@ -1142,16 +1153,6 @@ static void record_gp_stall_check_time(void)
 	rcu_state.n_force_qs_gpstart = READ_ONCE(rcu_state.n_force_qs);
 }
 
-/*
- * Convert a ->gp_state value to a character string.
- */
-static const char *gp_state_getname(short gs)
-{
-	if (gs < 0 || gs >= ARRAY_SIZE(gp_state_names))
-		return "???";
-	return gp_state_names[gs];
-}
-
 /*
  * Complain about starvation of grace-period kthread.
  */
Signature · 1 line
2.17.1
#7 lore raw

PATCH 7/14 rcu: Adjust the comment of function rcu_is_watching

In reply to Paul E. McKenney

From: Zhouyi Zhou <[email protected]>

Because RCU avoids interrupting idle CPUs, rcu_is_watching() is used to test whether or not it is currently legal to run RCU read-side critical sections on this CPU. However, the first sentence and last sentences of current comment for rcu_is_watching have opposite meaning of what is expected. This commit therefore fixes this header comment.

---
 kernel/rcu/tree.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/rcu/tree.c +3 -3
index e7c9848d1e1b..429a46fb087a 100644
@@ -904,12 +904,12 @@ void rcu_irq_enter_irqson(void)
 }
 
 /**
- * rcu_is_watching - see if RCU thinks that the current CPU is idle
+ * rcu_is_watching - see if RCU thinks that the current CPU is not idle
  *
  * Return true if RCU is watching the running CPU, which means that this
  * CPU can safely enter RCU read-side critical sections.  In other words,
- * if the current CPU is in its idle loop and is neither in an interrupt
- * or NMI handler, return true.
+ * if the current CPU is not in its idle loop or is in an interrupt or
+ * NMI handler, return true.
  */
 bool notrace rcu_is_watching(void)
 {
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/14 rcu: Parameterize rcu_check_gp_start_stall()

In reply to Paul E. McKenney

In order to debug forward-progress stalls, it is necessary to check for excessively delayed grace-period starts. This is currently done for RCU CPU stall warnings by rcu_check_gp_start_stall(), which checks to see if the start of a requested grace period has been delayed by an RCU CPU stall warning period. Because rcutorture will need to check for the time consumed by an RCU forward-progress delay, this commit promotes gpssdelay from a local variable to a formal parameter. It is not necessary to export rcu_check_gp_start_stall() because rcutorture will access it via a wrapper function.

---
 kernel/rcu/tree.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/rcu/tree.c +4 -4
index 4933f5d9d992..36e30150e1e9 100644
@@ -2600,10 +2600,10 @@ static void force_quiescent_state(void)
  * This function checks for grace-period requests that fail to motivate
  * RCU to come out of its idle mode.
  */
-static void
-rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp)
+void
+rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp,
+			 const unsigned long gpssdelay)
 {
-	const unsigned long gpssdelay = rcu_jiffies_till_stall_check();
 	unsigned long flags;
 	unsigned long j;
 	struct rcu_node *rnp_root = rcu_get_root();
@@ -2690,7 +2690,7 @@ static __latent_entropy void rcu_process_callbacks(struct softirq_action *unused
 		local_irq_restore(flags);
 	}
 
-	rcu_check_gp_start_stall(rnp, rdp);
+	rcu_check_gp_start_stall(rnp, rdp, rcu_jiffies_till_stall_check());
 
 	/* If there are callbacks ready, invoke them. */
 	if (rcu_segcblist_ready_cbs(&rdp->cblist))
Signature · 1 line
2.17.1