Skip to contentSkip to conversation

tinification: Make SRCU optional by using CONFIG_SRCU

PATCH In review Pranith Kumar 4 participants 5 messages Dec 4, 2014 – Dec 5, 2014

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

PATCH 1/1 tinification: Make SRCU optional by using CONFIG_SRCU

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 McKenney <[email protected]>
CC Josh Triplett <[email protected]>
---
 arch/arm/kvm/Kconfig     |  1 +
 arch/arm64/kvm/Kconfig   |  1 +
 arch/ia64/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 +
 init/Kconfig             | 10 ++++++++++
 kernel/notifier.c        |  3 +++
 kernel/rcu/Makefile      |  3 ++-
 lib/Kconfig.debug        |  1 +
 mm/Kconfig               |  1 +
 security/tomoyo/Kconfig  |  1 +
 22 files changed, 34 insertions(+), 1 deletion(-)
arch/arm/kvm/Kconfig +1 -0
index 466bd29..3afee5f 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 8ba85e9..b334084 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/ia64/kvm/Kconfig +1 -0
index 3d50ea9..f7d380b 100644
@@ -29,6 +29,7 @@ config KVM
 	select HAVE_KVM_IRQ_ROUTING
 	select KVM_APIC_ARCHITECTURE
 	select KVM_MMIO
+	select SRCU
 	---help---
 	  Support hosting fully virtualized guest machines using hardware
 	  virtualization extensions.  You will need a fairly recent
arch/mips/kvm/Kconfig +1 -0
index 30e334e..2ae1282 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 602eb51..af18e0f 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 646db9c..5fce52c 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 2298cb1..1e968f7 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 ded8a67..1c581a0 100644
@@ -137,6 +137,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 f9d16ff..7dc7ba5 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 455fd17..53e64f1 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 3489f8f..ebaa0cc 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 faf4e70..3891f67 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 5bdedf6..c355a22 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 f9009be..1c7efb1 100644
@@ -177,6 +177,7 @@ config NETCONSOLE_DYNAMIC
 
 config NETPOLL
 	def_bool NETCONSOLE
+	select SRCU
 
 config NET_POLL_CONTROLLER
 	def_bool NETPOLL
fs/btrfs/Kconfig +1 -0
index a66768e..80e9c18 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 22c629e..2a24249 100644
@@ -1,5 +1,6 @@
 config FSNOTIFY
 	def_bool n
+	select SRCU
 
 source "fs/notify/dnotify/Kconfig"
 source "fs/notify/inotify/Kconfig"
init/Kconfig +10 -0
index 903505e..100f4e7 100644
@@ -501,9 +501,18 @@ config TINY_RCU
 
 endchoice
 
+config SRCU
+	bool "Sleepable form of RCU"
+	def_bool n
+	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
@@ -1593,6 +1602,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 4803da6..ae9fc7c 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/rcu/Makefile +2 -1
index e6fae50..50a8084 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 d780351..ce76f34 100644
@@ -1199,6 +1199,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 1d1ae6b..4395b12 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 8eb779b9d..604e718 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.9.1
#1 lore raw
Quoted 15 lines · Pranith Kumar

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

Quoted 8 lines
 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 McKenney <[email protected]>
CC Josh Triplett <[email protected]>

I have queued this for testing.

Josh, does this look reasonable to you?

Lai, any issues?

Thanx, Paul

Quoted 317 lines
---
 arch/arm/kvm/Kconfig     |  1 +
 arch/arm64/kvm/Kconfig   |  1 +
 arch/ia64/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 +
 init/Kconfig             | 10 ++++++++++
 kernel/notifier.c        |  3 +++
 kernel/rcu/Makefile      |  3 ++-
 lib/Kconfig.debug        |  1 +
 mm/Kconfig               |  1 +
 security/tomoyo/Kconfig  |  1 +
 22 files changed, 34 insertions(+), 1 deletion(-)
arch/arm/kvm/Kconfig +1 -0
index 466bd29..3afee5f 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 8ba85e9..b334084 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/ia64/kvm/Kconfig +1 -0
index 3d50ea9..f7d380b 100644
@@ -29,6 +29,7 @@ config KVM
 	select HAVE_KVM_IRQ_ROUTING
 	select KVM_APIC_ARCHITECTURE
 	select KVM_MMIO
+	select SRCU
 	---help---
 	  Support hosting fully virtualized guest machines using hardware
 	  virtualization extensions.  You will need a fairly recent
arch/mips/kvm/Kconfig +1 -0
index 30e334e..2ae1282 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 602eb51..af18e0f 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 646db9c..5fce52c 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 2298cb1..1e968f7 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 ded8a67..1c581a0 100644
@@ -137,6 +137,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 f9d16ff..7dc7ba5 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 455fd17..53e64f1 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 3489f8f..ebaa0cc 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 faf4e70..3891f67 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 5bdedf6..c355a22 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 f9009be..1c7efb1 100644
@@ -177,6 +177,7 @@ config NETCONSOLE_DYNAMIC
 
 config NETPOLL
 	def_bool NETCONSOLE
+	select SRCU
 
 config NET_POLL_CONTROLLER
 	def_bool NETPOLL
fs/btrfs/Kconfig +1 -0
index a66768e..80e9c18 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 22c629e..2a24249 100644
@@ -1,5 +1,6 @@
 config FSNOTIFY
 	def_bool n
+	select SRCU
 
 source "fs/notify/dnotify/Kconfig"
 source "fs/notify/inotify/Kconfig"
init/Kconfig +10 -0
index 903505e..100f4e7 100644
@@ -501,9 +501,18 @@ config TINY_RCU
 
 endchoice
 
+config SRCU
+	bool "Sleepable form of RCU"
+	def_bool n
+	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
@@ -1593,6 +1602,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 4803da6..ae9fc7c 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/rcu/Makefile +2 -1
index e6fae50..50a8084 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 d780351..ce76f34 100644
@@ -1199,6 +1199,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 1d1ae6b..4395b12 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 8eb779b9d..604e718 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.9.1
#2 lore raw
Quoted 25 lines · Paul E. McKenney
Quoted 15 lines · Pranith Kumar

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

Quoted 8 lines
 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 McKenney <[email protected]>
CC Josh Triplett <[email protected]>
Quoted 32 lines

I have queued this for testing.

Josh, does this look reasonable to you?

Lai, any issues?

Thanx, Paul

Quoted 24 lines
---
 arch/arm/kvm/Kconfig     |  1 +
 arch/arm64/kvm/Kconfig   |  1 +
 arch/ia64/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 +
 init/Kconfig             | 10 ++++++++++
 kernel/notifier.c        |  3 +++
 kernel/rcu/Makefile      |  3 ++-
 lib/Kconfig.debug        |  1 +
 mm/Kconfig               |  1 +
 security/tomoyo/Kconfig  |  1 +
 22 files changed, 34 insertions(+), 1 deletion(-)

Miss fs/quota/Kconfig?

./fs/quota/dquot.c:100: * Operation of reading pointer needs srcu_read_lock(&dquot_srcu), and
./fs/quota/dquot.c:1609: index = srcu_read_lock(&dquot_srcu);
./fs/quota/dquot.c:1657: index = srcu_read_lock(&dquot_srcu);
./fs/quota/dquot.c:1695: index = srcu_read_lock(&dquot_srcu);
./fs/quota/dquot.c:1724: index = srcu_read_lock(&dquot_srcu);
./fs/quota/dquot.c:1756: index = srcu_read_lock(&dquot_srcu);
./fs/quota/dquot.c:1797: index = srcu_read_lock(&dquot_srcu);
./fs/quota/dquot.c:1827: * protect them by srcu_read_lock().

And

./drivers/base/power/opp.c:90: struct srcu_notifier_head head;
./drivers/base/power/opp.c:439: srcu_init_notifier_head(&dev_opp->head);
./drivers/base/power/opp.c:484: srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_ADD, new_opp);
./drivers/base/power/opp.c:564: srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_ENABLE,
./drivers/base/power/opp.c:567: srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_DISABLE,
./drivers/base/power/opp.c:625:struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev)

===

include/linux/srcu.h and ./include/linux/notifier.h should also use "#ifdef CONFIG_SRCU .... "

Quoted 9 lines

arch/x86/Kconfig config X86 · line 140

Quoted 9 lines
arch/x86/Kconfig +1 -0
index ded8a67..1c581a0 100644
@@ -137,6 +137,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

Why you select SRCU when X86?

Quoted 3 lines

arch/x86/Kconfig config X86 · line 142

Quoted 3 lines
arch/x86/Kconfig +2 -0
+config SRCU
+	bool "Sleepable form of RCU"

Why it has a title? Somebody need to select it manually for third party kernel module?

Quoted 5 lines

arch/x86/Kconfig config X86

Quoted 5 lines
arch/x86/Kconfig +5 -0
+	def_bool n
+	help
+	  This option selects the sleepable version of RCU. This version
+	  permits arbitrary sleeping or blocking within RCU read-side critical
+	  sections.

You used "form" and "version" at the same time.

Quoted 10 lines

arch/x86/Kconfig void srcu_init_notifier_head(struct srcu_notifier_head *nh) · line 532

Quoted 10 lines
arch/x86/Kconfig +2 -0
+#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 */

Do we need a new CONFIG_SRCU_NOTIFIER ?

#3 lore raw
Quoted 72 lines · Lai Jiangshan
Quoted 25 lines · Paul E. McKenney
Quoted 15 lines · Pranith Kumar

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

Quoted 8 lines
 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 McKenney <[email protected]>
CC Josh Triplett <[email protected]>
Quoted 32 lines

I have queued this for testing.

Josh, does this look reasonable to you?

Lai, any issues?

Thanx, Paul

Quoted 24 lines
---
 arch/arm/kvm/Kconfig     |  1 +
 arch/arm64/kvm/Kconfig   |  1 +
 arch/ia64/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 +
 init/Kconfig             | 10 ++++++++++
 kernel/notifier.c        |  3 +++
 kernel/rcu/Makefile      |  3 ++-
 lib/Kconfig.debug        |  1 +
 mm/Kconfig               |  1 +
 security/tomoyo/Kconfig  |  1 +
 22 files changed, 34 insertions(+), 1 deletion(-)

Miss fs/quota/Kconfig?

./fs/quota/dquot.c:100: * Operation of reading pointer needs srcu_read_lock(&dquot_srcu), and

./fs/quota/dquot.c:1609:        index = srcu_read_lock(&dquot_srcu);
./fs/quota/dquot.c:1657:        index = srcu_read_lock(&dquot_srcu);
./fs/quota/dquot.c:1695:        index = srcu_read_lock(&dquot_srcu);
./fs/quota/dquot.c:1724:        index = srcu_read_lock(&dquot_srcu);
./fs/quota/dquot.c:1756:        index = srcu_read_lock(&dquot_srcu);
./fs/quota/dquot.c:1797:        index = srcu_read_lock(&dquot_srcu);

./fs/quota/dquot.c:1827: * protect them by srcu_read_lock().

And

Quoted 8 lines

./drivers/base/power/opp.c:90: struct srcu_notifier_head head;
./drivers/base/power/opp.c:439: srcu_init_notifier_head(&dev_opp->head);
./drivers/base/power/opp.c:484: srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_ADD, new_opp);
./drivers/base/power/opp.c:564: srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_ENABLE,
./drivers/base/power/opp.c:567: srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_DISABLE,
./drivers/base/power/opp.c:625:struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev)

===

I've added the above two locations to enable SRCU.

Quoted 5 lines

include/linux/srcu.h and ./include/linux/notifier.h should also use "#ifdef CONFIG_SRCU .... "

Quoted 15 lines
Quoted 9 lines

arch/x86/Kconfig config X86 · line 140

Quoted 9 lines
arch/x86/Kconfig +1 -0
index ded8a67..1c581a0 100644
@@ -137,6 +137,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

Why you select SRCU when X86?

The reason is that x86 selects PERF_EVENTS which inturn needs SRCU. We were not sure if SRCU will be recursively enabled when PERF_EVENTS is enabled.

Quoted 5 lines
Quoted 3 lines

arch/x86/Kconfig config X86 · line 142

Quoted 3 lines
arch/x86/Kconfig +2 -0
+config SRCU
+    bool "Sleepable form of RCU"

Why it has a title? Somebody need to select it manually for third party kernel module?

Yes, it is a choice given to enable SRCU even when no in-kernel module uses it.

Quoted 8 lines
Quoted 6 lines

arch/x86/Kconfig config X86

Quoted 6 lines
arch/x86/Kconfig +5 -0
+    def_bool n
+    help
+      This option selects the sleepable version of RCU. This version
+      permits arbitrary sleeping or blocking within RCU read-side critical
+      sections.

You used "form" and "version" at the same time.

I will fix this in the next iteration.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
arch/x86/Kconfig +1 -0
+#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);
 
Quoted 3 lines
Quoted 1 line

arch/x86/Kconfig void srcu_init_notifier_head(struct srcu_notifier_head *nh) · line 532

Quoted 1 line
arch/x86/Kconfig +1 -0
+#endif /* CONFIG_SRCU */

Do we need a new CONFIG_SRCU_NOTIFIER ?

I am not sure actually. Why not just CONFIG_SRCU like here?

Signature · 1 line
Pranith
maintainer
#4 lore raw
Quoted 10 lines · Pranith Kumar
Quoted 7 lines · Lai Jiangshan
Quoted 4 lines · Paul E. McKenney

init/Kconfig config TINY_RCU · line 505

Quoted 3 lines · Pranith Kumar
init/Kconfig +2 -0
+config SRCU
+    bool "Sleepable form of RCU"

Why it has a title? Somebody need to select it manually for third party kernel module?

Yes, it is a choice given to enable SRCU even when no in-kernel module uses it.

That makes sense for testing purposes, but I don't think it makes sense for the final patch. I'd suggest making it a completely automatic symbol with no title.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ def_bool n

You already say "bool" above, and "default n" is the default default, so you can omit this line entirely.

- Josh Triplett