Skip to contentSkip to conversation

SRCU changes for 3.20

PATCH New Paul E. McKenney 1 participant 4 messages Jan 7, 2015

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

cover SRCU changes for 3.20

Hello!

This series contains some minor changes to SRCU:

1. Expand SRCU ->completed to 64 bits. This is to be consistent with
rcutorture, which now pays attention to this field for more precise error checking.

2. Combine DEFINE_SRCU() and DEFINE_STATIC_SRCU().

3. Make SRCU optional via a new CONFIG_SRCU Kconfig parameter,
courtesy of Pranith Kumar. This saves about 2KB.

Thanx, Paul

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

 b/arch/arm/kvm/Kconfig     |    1 +
 b/arch/arm64/kvm/Kconfig   |    1 +
 b/arch/mips/kvm/Kconfig    |    1 +
 b/arch/powerpc/kvm/Kconfig |    1 +
 b/arch/s390/kvm/Kconfig    |    1 +
 b/arch/tile/kvm/Kconfig    |    1 +
 b/arch/x86/Kconfig         |    1 +
 b/arch/x86/kvm/Kconfig     |    1 +
 b/drivers/clk/Kconfig      |    1 +
 b/drivers/cpufreq/Kconfig  |    1 +
 b/drivers/devfreq/Kconfig  |    1 +
 b/drivers/md/Kconfig       |    1 +
 b/drivers/net/Kconfig      |    1 +
 b/fs/btrfs/Kconfig         |    1 +
 b/fs/notify/Kconfig        |    1 +
 b/fs/quota/Kconfig         |    1 +
 b/include/linux/srcu.h     |   14 ++++++--------
 b/init/Kconfig             |    9 +++++++++
 b/kernel/notifier.c        |    3 +++
 b/kernel/power/Kconfig     |    1 +
 b/kernel/rcu/Makefile      |    3 ++-
 b/kernel/rcu/srcu.c        |    2 +-
 b/lib/Kconfig.debug        |    1 +
 b/mm/Kconfig               |    1 +
 b/security/tomoyo/Kconfig  |    1 +
 25 files changed, 41 insertions(+), 10 deletions(-)
#1 lore raw

PATCH 1/3 rcu: Expand SRCU ->completed to 64 bits

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

When rcutorture used only the low-order 32 bits of the grace-period number, it was not a problem for SRCU to use a 32-bit completed field. However, rcutorture now uses the full 64 bits on 64-bit systems, so this commit converts SRCU's ->completed field to unsigned long so as to provide 64 bits on 64-bit systems.

---
 include/linux/srcu.h | 4 ++--
 kernel/rcu/srcu.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/srcu.h +2 -2
index a2783cb5d275..ef923dd96249 100644
@@ -45,7 +45,7 @@ struct rcu_batch {
 #define RCU_BATCH_INIT(name) { NULL, &(name.head) }
 
 struct srcu_struct {
-	unsigned completed;
+	unsigned long completed;
 	struct srcu_struct_array __percpu *per_cpu_ref;
 	spinlock_t queue_lock; /* protect ->batch_queue, ->running */
 	bool running;
@@ -135,7 +135,7 @@ int __srcu_read_lock(struct srcu_struct *sp) __acquires(sp);
 void __srcu_read_unlock(struct srcu_struct *sp, int idx) __releases(sp);
 void synchronize_srcu(struct srcu_struct *sp);
 void synchronize_srcu_expedited(struct srcu_struct *sp);
-long srcu_batches_completed(struct srcu_struct *sp);
+unsigned long srcu_batches_completed(struct srcu_struct *sp);
 void srcu_barrier(struct srcu_struct *sp);
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
kernel/rcu/srcu.c +1 -1
index e037f3eb2f7b..445bf8ffe3fb 100644
@@ -546,7 +546,7 @@ EXPORT_SYMBOL_GPL(srcu_barrier);
  * Report the number of batches, correlated with, but not necessarily
  * precisely the same as, the number of grace periods that have elapsed.
  */
-long srcu_batches_completed(struct srcu_struct *sp)
+unsigned long srcu_batches_completed(struct srcu_struct *sp)
 {
 	return sp->completed;
 }
Signature · 1 line
1.8.1.5
#3 lore raw

PATCH 3/3 rcu: Make SRCU optional by using CONFIG_SRCU

From: Pranith Kumar <[email protected]>

SRCU is not necessary to be compiled by default in all cases. For tinification efforts not compiling SRCU unless necessary is desirable.

The current patch tries to make compiling SRCU optional by introducing a new Kconfig option CONFIG_SRCU which is selected when any of the components making use of SRCU are selected.

If we do not select CONFIG_SRCU, srcu.o will not be compiled at all.

text data bss dec hex filename
2007 0 0 2007 7d7 kernel/rcu/srcu.o

Size of arch/powerpc/boot/zImage changes from

text data bss dec hex filename

 831552   64180   23944  919676   e087c arch/powerpc/boot/zImage : before
 829504   64180   23952  917636   e0084 arch/powerpc/boot/zImage : after

so the savings are about ~2000 bytes.

CC Paul E. McKenney <[email protected]>
CC Josh Triplett <[email protected]>
CC Lai Jiangshan <[email protected]>
[ paulmck: resolve conflict due to removal of arch/ia64/kvm/Kconfig. ]
---
 arch/arm/kvm/Kconfig     | 1 +
 arch/arm64/kvm/Kconfig   | 1 +
 arch/mips/kvm/Kconfig    | 1 +
 arch/powerpc/kvm/Kconfig | 1 +
 arch/s390/kvm/Kconfig    | 1 +
 arch/tile/kvm/Kconfig    | 1 +
 arch/x86/Kconfig         | 1 +
 arch/x86/kvm/Kconfig     | 1 +
 drivers/clk/Kconfig      | 1 +
 drivers/cpufreq/Kconfig  | 1 +
 drivers/devfreq/Kconfig  | 1 +
 drivers/md/Kconfig       | 1 +
 drivers/net/Kconfig      | 1 +
 fs/btrfs/Kconfig         | 1 +
 fs/notify/Kconfig        | 1 +
 fs/quota/Kconfig         | 1 +
 init/Kconfig             | 9 +++++++++
 kernel/notifier.c        | 3 +++
 kernel/power/Kconfig     | 1 +
 kernel/rcu/Makefile      | 3 ++-
 lib/Kconfig.debug        | 1 +
 mm/Kconfig               | 1 +
 security/tomoyo/Kconfig  | 1 +
 23 files changed, 34 insertions(+), 1 deletion(-)
arch/arm/kvm/Kconfig +1 -0
index 466bd299b1a8..3afee5f40f4f 100644
@@ -23,6 +23,7 @@ config KVM
 	select HAVE_KVM_CPU_RELAX_INTERCEPT
 	select KVM_MMIO
 	select KVM_ARM_HOST
+	select SRCU
 	depends on ARM_VIRT_EXT && ARM_LPAE
 	---help---
 	  Support hosting virtualized guest machines. You will also
arch/arm64/kvm/Kconfig +1 -0
index 8ba85e9ea388..b334084d3675 100644
@@ -26,6 +26,7 @@ config KVM
 	select KVM_ARM_HOST
 	select KVM_ARM_VGIC
 	select KVM_ARM_TIMER
+	select SRCU
 	---help---
 	  Support hosting virtualized guest machines.
 
arch/mips/kvm/Kconfig +1 -0
index 30e334e823bd..2ae12825529f 100644
@@ -20,6 +20,7 @@ config KVM
 	select PREEMPT_NOTIFIERS
 	select ANON_INODES
 	select KVM_MMIO
+	select SRCU
 	---help---
 	  Support for hosting Guest kernels.
 	  Currently supported on MIPS32 processors.
arch/powerpc/kvm/Kconfig +1 -0
index f5769f19ae25..11850f310fb4 100644
@@ -21,6 +21,7 @@ config KVM
 	select PREEMPT_NOTIFIERS
 	select ANON_INODES
 	select HAVE_KVM_EVENTFD
+	select SRCU
 
 config KVM_BOOK3S_HANDLER
 	bool
arch/s390/kvm/Kconfig +1 -0
index 646db9c467d1..5fce52cf0e57 100644
@@ -28,6 +28,7 @@ config KVM
 	select HAVE_KVM_IRQCHIP
 	select HAVE_KVM_IRQFD
 	select HAVE_KVM_IRQ_ROUTING
+	select SRCU
 	---help---
 	  Support hosting paravirtualized guest machines using the SIE
 	  virtualization capability on the mainframe. This should work
arch/tile/kvm/Kconfig +1 -0
index 2298cb1daff7..1e968f7550dc 100644
@@ -21,6 +21,7 @@ config KVM
 	depends on HAVE_KVM && MODULES
 	select PREEMPT_NOTIFIERS
 	select ANON_INODES
+	select SRCU
 	---help---
 	  Support hosting paravirtualized guest machines.
 
arch/x86/Kconfig +1 -0
index ba397bde7948..661269953c1a 100644
@@ -138,6 +138,7 @@ config X86
 	select HAVE_ACPI_APEI_NMI if ACPI
 	select ACPI_LEGACY_TABLES_LOOKUP if ACPI
 	select X86_FEATURE_NAMES if PROC_FS
+	select SRCU
 
 config INSTRUCTION_DECODER
 	def_bool y
arch/x86/kvm/Kconfig +1 -0
index f9d16ff56c6b..7dc7ba577ecd 100644
@@ -40,6 +40,7 @@ config KVM
 	select HAVE_KVM_MSI
 	select HAVE_KVM_CPU_RELAX_INTERCEPT
 	select KVM_VFIO
+	select SRCU
 	---help---
 	  Support hosting fully virtualized guest machines using hardware
 	  virtualization extensions.  You will need a fairly recent
drivers/clk/Kconfig +1 -0
index 3f44f292d066..91f86131bb7a 100644
@@ -13,6 +13,7 @@ config COMMON_CLK
 	bool
 	select HAVE_CLK_PREPARE
 	select CLKDEV_LOOKUP
+	select SRCU
 	---help---
 	  The common clock framework is a single definition of struct
 	  clk, useful across many platforms, as well as an
drivers/cpufreq/Kconfig +1 -0
index 29b2ef5a68b9..a171fef2c2b6 100644
@@ -2,6 +2,7 @@ menu "CPU Frequency scaling"
 
 config CPU_FREQ
 	bool "CPU Frequency scaling"
+	select SRCU
 	help
 	  CPU Frequency scaling allows you to change the clock speed of 
 	  CPUs on the fly. This is a nice method to save power, because 
drivers/devfreq/Kconfig +1 -0
index faf4e70c42e0..3891f6781298 100644
@@ -1,5 +1,6 @@
 menuconfig PM_DEVFREQ
 	bool "Generic Dynamic Voltage and Frequency Scaling (DVFS) support"
+	select SRCU
 	help
 	  A device may have a list of frequencies and voltages available.
 	  devfreq, a generic DVFS framework can be registered for a device
drivers/md/Kconfig +1 -0
index 5bdedf6df153..c355a226a024 100644
@@ -5,6 +5,7 @@
 menuconfig MD
 	bool "Multiple devices driver support (RAID and LVM)"
 	depends on BLOCK
+	select SRCU
 	help
 	  Support multiple physical spindles through a single logical device.
 	  Required for RAID and logical volume management.
drivers/net/Kconfig +1 -0
index d6607ee9c855..84673ebcf428 100644
@@ -197,6 +197,7 @@ config NETCONSOLE_DYNAMIC
 
 config NETPOLL
 	def_bool NETCONSOLE
+	select SRCU
 
 config NET_POLL_CONTROLLER
 	def_bool NETPOLL
fs/btrfs/Kconfig +1 -0
index a66768ebc8d1..80e9c18ea64f 100644
@@ -8,6 +8,7 @@ config BTRFS_FS
 	select LZO_DECOMPRESS
 	select RAID6_PQ
 	select XOR_BLOCKS
+	select SRCU
 
 	help
 	  Btrfs is a general purpose copy-on-write filesystem with extents,
fs/notify/Kconfig +1 -0
index 22c629eedd82..2a24249b30af 100644
@@ -1,5 +1,6 @@
 config FSNOTIFY
 	def_bool n
+	select SRCU
 
 source "fs/notify/dnotify/Kconfig"
 source "fs/notify/inotify/Kconfig"
fs/quota/Kconfig +1 -0
index c51df1dd237e..4a09975aac90 100644
@@ -5,6 +5,7 @@
 config QUOTA
 	bool "Quota support"
 	select QUOTACTL
+	select SRCU
 	help
 	  If you say Y here, you will be able to set per user limits for disk
 	  usage (also called disk quotas). Currently, it works for the
init/Kconfig +9 -0
index 9afb971497f4..f085969ba340 100644
@@ -501,9 +501,17 @@ config TINY_RCU
 
 endchoice
 
+config SRCU
+	bool
+	help
+	  This option selects the sleepable version of RCU. This version
+	  permits arbitrary sleeping or blocking within RCU read-side critical
+	  sections.
+
 config TASKS_RCU
 	bool "Task_based RCU implementation using voluntary context switch"
 	default n
+	select SRCU
 	help
 	  This option enables a task-based RCU implementation that uses
 	  only voluntary context switch (not preemption!), idle, and
@@ -1595,6 +1603,7 @@ config PERF_EVENTS
 	depends on HAVE_PERF_EVENTS
 	select ANON_INODES
 	select IRQ_WORK
+	select SRCU
 	help
 	  Enable kernel support for various performance events provided
 	  by software and hardware.
kernel/notifier.c +3 -0
index 4803da6eab62..ae9fc7cc360e 100644
@@ -402,6 +402,7 @@ int raw_notifier_call_chain(struct raw_notifier_head *nh,
 }
 EXPORT_SYMBOL_GPL(raw_notifier_call_chain);
 
+#ifdef CONFIG_SRCU
 /*
  *	SRCU notifier chain routines.    Registration and unregistration
  *	use a mutex, and call_chain is synchronized by SRCU (no locks).
@@ -528,6 +529,8 @@ void srcu_init_notifier_head(struct srcu_notifier_head *nh)
 }
 EXPORT_SYMBOL_GPL(srcu_init_notifier_head);
 
+#endif /* CONFIG_SRCU */
+
 static ATOMIC_NOTIFIER_HEAD(die_chain);
 
 int notrace notify_die(enum die_val val, const char *str,
kernel/power/Kconfig +1 -0
index 48b28d387c7f..7e01f78f0417 100644
@@ -251,6 +251,7 @@ config APM_EMULATION
 
 config PM_OPP
 	bool
+	select SRCU
 	---help---
 	  SOCs have a standard set of tuples consisting of frequency and
 	  voltage pairs that the device will support per voltage domain. This
kernel/rcu/Makefile +2 -1
index e6fae503d1bc..50a808424b06 100644
@@ -1,4 +1,5 @@
-obj-y += update.o srcu.o
+obj-y += update.o
+obj-$(CONFIG_SRCU) += srcu.o
 obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
 obj-$(CONFIG_TREE_RCU) += tree.o
 obj-$(CONFIG_PREEMPT_RCU) += tree.o
lib/Kconfig.debug +1 -0
index 5f2ce616c046..7a9c93e327f2 100644
@@ -1215,6 +1215,7 @@ config RCU_TORTURE_TEST
 	tristate "torture tests for RCU"
 	depends on DEBUG_KERNEL
 	select TORTURE_TEST
+	select SRCU
 	default n
 	help
 	  This option provides a kernel module that runs torture tests
mm/Kconfig +1 -0
index 1d1ae6b078fd..4395b12869c8 100644
@@ -325,6 +325,7 @@ config VIRT_TO_BUS
 
 config MMU_NOTIFIER
 	bool
+	select SRCU
 
 config KSM
 	bool "Enable KSM for page merging"
security/tomoyo/Kconfig +1 -0
index 8eb779b9d77f..604e718d68d3 100644
@@ -5,6 +5,7 @@ config SECURITY_TOMOYO
 	select SECURITYFS
 	select SECURITY_PATH
 	select SECURITY_NETWORK
+	select SRCU
 	default n
 	help
 	  This selects TOMOYO Linux, pathname-based access control.
Signature · 1 line
1.8.1.5
#2 lore raw

PATCH 2/3 rcu: Combine DEFINE_SRCU() and DEFINE_STATIC_SRCU()

In reply to Paul E. McKenney

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

The DEFINE_SRCU() and DEFINE_STATIC_SRCU() definitions are quite similar, so this commit combines them, saving a bit of code and removing redundancy.

---
 include/linux/srcu.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
include/linux/srcu.h +4 -6
index ef923dd96249..9cfd9623fb03 100644
@@ -102,13 +102,11 @@ void process_srcu(struct work_struct *work);
  * define and init a srcu struct at build time.
  * dont't call init_srcu_struct() nor cleanup_srcu_struct() on it.
  */
-#define DEFINE_SRCU(name)						\
+#define __DEFINE_SRCU(name, is_static)					\
 	static DEFINE_PER_CPU(struct srcu_struct_array, name##_srcu_array);\
-	struct srcu_struct name = __SRCU_STRUCT_INIT(name);
-
-#define DEFINE_STATIC_SRCU(name)					\
-	static DEFINE_PER_CPU(struct srcu_struct_array, name##_srcu_array);\
-	static struct srcu_struct name = __SRCU_STRUCT_INIT(name);
+	is_static struct srcu_struct name = __SRCU_STRUCT_INIT(name)
+#define DEFINE_SRCU(name)		__DEFINE_SRCU(name, /* not static */)
+#define DEFINE_STATIC_SRCU(name)	__DEFINE_SRCU(name, static)
 
 /**
  * call_srcu() - Queue a callback for invocation after an SRCU grace period
Signature · 1 line
1.8.1.5