srcu: Isolate srcu sections using CONFIG_SRCU
Subsystems (2)
PATCH 1/1 srcu: Isolate srcu sections using CONFIG_SRCU
Isolate the SRCU functions and data structures within CONFIG_SRCU so that there is a compile time failure if srcu is used when not enabled. This was decided to be better than waiting until link time for a failure to occur.
Also make including kvm_host.h conditional on CONFIG_KVM being enabled. This prevents build failures as KVM is dependent on SRCU.
--- arch/s390/kernel/asm-offsets.c | 7 ++++++- include/linux/notifier.h | 47 ++++++++++++++++++++++++------------------ include/linux/srcu.h | 6 +++++- 3 files changed, 38 insertions(+), 22 deletions(-)
arch/s390/kernel/asm-offsets.c +6 -1
@@ -7,12 +7,15 @@#define ASM_OFFSETS_C #include <linux/kbuild.h> -#include <linux/kvm_host.h> #include <linux/sched.h> #include <asm/idle.h> #include <asm/vdso.h> #include <asm/pgtable.h> +#if IS_ENABLED (CONFIG_KVM ) +#include <linux/kvm_host.h> +#endif +/* * Make sure that the compiler is new enough. We want a compiler that * is known to work with the "Q" assembler constraint.
@@ -182,8 +185,10 @@ int main(void)DEFINE (__LC_PGM_TDB, offsetof(struct _lowcore , pgm_tdb)); DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, thread.trap_tdb));DEFINE (__GMAP_ASCE, offsetof(struct gmap , asce)); +#if IS_ENABLED (CONFIG_KVM )DEFINE (__SIE_PROG0C, offsetof(struct kvm_s390_sie_block , prog0c));DEFINE (__SIE_PROG20, offsetof(struct kvm_s390_sie_block , prog20)); +#endif /* CONFIG_KVM */ #endif /* CONFIG_32BIT */ return 0 ; }
include/linux/notifier.h +27 -20
94 lines not on this page · raw message
include/linux/srcu.h +5 -1
@@ -26,6 +26,8 @@* */ +#ifdef CONFIG_SRCU +#ifndef _LINUX_SRCU_H#define _LINUX_SRCU_H
@@ -249,4 +251,6 @@ static inline void smp_mb__after_srcu_read_unlock(void)/* __srcu_read_unlock has smp_mb() internally so nothing to do here. */ } -#endif +#endif /* _LINUX_SRCU_H */ + +#endif /* CONFIG_SRCU */
Signature · 1 line
1.9.1
Mathieu Desnoyers
reviewer----- Original Message -----
Quoted 39 lines
From: "Pranith Kumar" <[email protected]>
To: "Martin Schwidefsky" <[email protected]>, "Heiko Carstens" <[email protected]>, "supporter:S390" <[email protected]>, "Lai Jiangshan" <[email protected]>, "Paul E. McKenney" <[email protected]>, "Josh Triplett" <[email protected]>, "Steven Rostedt" <[email protected]>, "Mathieu Desnoyers" <[email protected]>, "Christian Borntraeger" <[email protected]>, "Jens Freimann" <[email protected]>, "open list:S390" <[email protected]>, "open list" <[email protected]>
Sent: Tuesday, December 9, 2014 1:48:21 PM
Subject: [PATCH] srcu: Isolate srcu sections usingCONFIG_SRCUIsolate the SRCU functions and data structures within
CONFIG_SRCUso that there
is a compile time failure if srcu is used when not enabled. This was decided to
be better than waiting until link time for a failure to occur.Also make including
kvm_host.hconditional onCONFIG_KVMbeing enabled. This prevents build failures as KVM is dependent on SRCU.Signed-off-by Pranith Kumar <[email protected]>CC Paul E. McKenney <[email protected]>CC Josh Triplett <[email protected]>CC Lai Jiangshan <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>--- arch/s390/kernel/asm-offsets.c | 7 ++++++- include/linux/notifier.h | 47 ++++++++++++++++++++++++------------------ include/linux/srcu.h | 6 +++++- 3 files changed, 38 insertions(+), 22 deletions(-)arch/s390/kernel/asm-offsets.c +0
-0@@ -7,12 +7,15 @@#define ASM_OFFSETS_C #include <linux/kbuild.h>
arch/s390/kernel/asm-offsets.c line 18
Quoted 10 lines
arch/s390/kernel/asm-offsets.c +4
-1-#include <linux/kvm_host.h> #include <linux/sched.h> #include <asm/idle.h> #include <asm/vdso.h> #include <asm/pgtable.h> +#if IS_ENABLED (CONFIG_KVM ) +#include <linux/kvm_host.h> +#endif +
Seeing this kind of conditional include makes me cringe. Is there some way to hide this within linux/kvm_host.h instead ?
Thanks,
Mathieu
Quoted 149 lines
arch/s390/kernel/asm-offsets.c +2
-0/* * Make sure that the compiler is new enough. We want a compiler that * is known to work with the "Q" assembler constraint. @@ -182,8 +185,10 @@ int main(void)DEFINE (__LC_PGM_TDB, offsetof(struct _lowcore , pgm_tdb)); DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, thread.trap_tdb));DEFINE (__GMAP_ASCE, offsetof(struct gmap , asce)); +#if IS_ENABLED (CONFIG_KVM )DEFINE (__SIE_PROG0C, offsetof(struct kvm_s390_sie_block , prog0c));DEFINE (__SIE_PROG20, offsetof(struct kvm_s390_sie_block , prog20)); +#endif /* CONFIG_KVM */ #endif /* CONFIG_32BIT */ return 0 ; }include/linux/notifier.h +2
-12@@ -47,6 +47,8 @@* runtime initialization. */ +struct notifier_block ; +typedef int (*notifier_fn_t )(struct notifier_block *nb,unsigned long action,void *data);@@ -70,12 +72,6 @@ struct raw_notifier_head {struct notifier_block __rcu *head; }; -struct srcu_notifier_head { -struct mutex mutex; -struct srcu_struct srcu; -struct notifier_block __rcu *head; -}; -#define ATOMIC_INIT_NOTIFIER_HEAD (name) do { \ spin_lock_init(&(name)->lock); \ (name)->head = NULL; \@@ -88,11 +84,6 @@ struct srcu_notifier_head { (name)->head =NULL ; \ } while (0) -/* srcu_notifier_heads must be initialized and cleaned up dynamically */ -extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); -#define srcu_cleanup_notifier_head (name) \ - cleanup_srcu_struct(&(name)->srcu); -#define ATOMIC_NOTIFIER_INIT (name) { \ .lock = __SPIN_LOCK_UNLOCKED(name.lock), \ .head = NULL }@@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); .head = NULL }#define RAW_NOTIFIER_INIT (name) { \ .head = NULL } -/* srcu_notifier_heads cannot be initialized statically */ #define ATOMIC_NOTIFIER_HEAD (name) \include/linux/notifier.h +0
-2struct atomic_notifier_head name = \@@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(structblocking_notifier_head *nh, struct notifier_block *nb);extern int raw_notifier_chain_register (struct raw_notifier_head *nh,struct notifier_block *nb); -extern int srcu_notifier_chain_register (struct srcu_notifier_head *nh, -struct notifier_block *nb); extern int blocking_notifier_chain_cond_register(include/linux/notifier.h +0
-2struct blocking_notifier_head *nh,@@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(structblocking_notifier_head *nh, struct notifier_block *nb);extern int raw_notifier_chain_unregister (struct raw_notifier_head *nh,struct notifier_block *nb); -extern int srcu_notifier_chain_unregister (struct srcu_notifier_head *nh, -struct notifier_block *nb); extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,include/linux/notifier.h +0
-4unsigned long val, void *v);@@ -149,10 +135,6 @@ extern int raw_notifier_call_chain(structraw_notifier_head *nh, unsigned long val, void *v);extern int __raw_notifier_call_chain (struct raw_notifier_head *nh,unsigned long val,void *v,int nr_to_call,int *nr_calls); -extern int srcu_notifier_call_chain (struct srcu_notifier_head *nh, -unsigned long val,void *v); -extern int __srcu_notifier_call_chain (struct srcu_notifier_head *nh, -unsigned long val,void *v,int nr_to_call,int *nr_calls);#define NOTIFY_DONE 0x0000/* Don't care */ #define
NOTIFY_OK0x0001/* Suits me */include/linux/notifier.h +25
-0@@ -211,5 +193,30 @@ static inline int notifier_to_errno(int ret)extern struct blocking_notifier_head reboot_notifier_list; +#ifdef CONFIG_SRCU + +struct srcu_notifier_head { +struct mutex mutex; +struct srcu_struct srcu; +struct notifier_block __rcu *head; +}; + +/* srcu_notifier_heads must be initialized and cleaned up dynamically +* srcu_notifier_heads cannot be initialized statically +*/ +extern void srcu_init_notifier_head (struct srcu_notifier_head *nh); +#define srcu_cleanup_notifier_head (name) cleanup_srcu_struct(&(name)->srcu) + +extern int srcu_notifier_chain_register (struct srcu_notifier_head *nh, +struct notifier_block *nb); +extern int srcu_notifier_chain_unregister (struct srcu_notifier_head *nh, +struct notifier_block *nb); +extern int srcu_notifier_call_chain (struct srcu_notifier_head *nh, +unsigned long val,void *v); +extern int __srcu_notifier_call_chain (struct srcu_notifier_head *nh, +unsigned long val,void *v,int nr_to_call,int *nr_calls); + +#endif /* CONFIG_SRCU */ +#endif /* __KERNEL__ */ #endif /* _LINUX_NOTIFIER_H */ include/linux/srcu.h +5
-2@@ -26,6 +26,8 @@* */ +#ifdef CONFIG_SRCU +#ifndef _LINUX_SRCU_H#define _LINUX_SRCU_H@@ -249,4 +251,6 @@ static inline void smp_mb__after_srcu_read_unlock(void)/* __srcu_read_unlock has smp_mb() internally so nothing to do here. */ } -#endif +#endif /* _LINUX_SRCU_H */ + +#endif /* CONFIG_SRCU */ --1.9.1
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
Quoted 4 lines · Pranith Kumar
Isolate the SRCU functions and data structures within
CONFIG_SRCUso that there is a compile time failure if srcu is used when not enabled. This was decided to be better than waiting until link time for a failure to occur.
Quoted 8 lines
Also make including
kvm_host.hconditional onCONFIG_KVMbeing enabled. This prevents build failures as KVM is dependent on SRCU.Signed-off-by Pranith Kumar <[email protected]>CC Paul E. McKenney <[email protected]>CC Josh Triplett <[email protected]>CC Lai Jiangshan <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>
Queued for testing (finally), replacing the earlier patch. ;-)
Thanx, Paul
Quoted 168 lines
--- arch/s390/kernel/asm-offsets.c | 7 ++++++- include/linux/notifier.h | 47 ++++++++++++++++++++++++------------------ include/linux/srcu.h | 6 +++++- 3 files changed, 38 insertions(+), 22 deletions(-)arch/s390/kernel/asm-offsets.c +6
-1@@ -7,12 +7,15 @@#define ASM_OFFSETS_C #include <linux/kbuild.h> -#include <linux/kvm_host.h> #include <linux/sched.h> #include <asm/idle.h> #include <asm/vdso.h> #include <asm/pgtable.h> +#if IS_ENABLED (CONFIG_KVM ) +#include <linux/kvm_host.h> +#endif +/* * Make sure that the compiler is new enough. We want a compiler that * is known to work with the "Q" assembler constraint. @@ -182,8 +185,10 @@ int main(void)DEFINE (__LC_PGM_TDB, offsetof(struct _lowcore , pgm_tdb)); DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, thread.trap_tdb));DEFINE (__GMAP_ASCE, offsetof(struct gmap , asce)); +#if IS_ENABLED (CONFIG_KVM )DEFINE (__SIE_PROG0C, offsetof(struct kvm_s390_sie_block , prog0c));DEFINE (__SIE_PROG20, offsetof(struct kvm_s390_sie_block , prog20)); +#endif /* CONFIG_KVM */ #endif /* CONFIG_32BIT */ return 0 ; }include/linux/notifier.h +27
-20@@ -47,6 +47,8 @@* runtime initialization. */ +struct notifier_block ; +typedef int (*notifier_fn_t )(struct notifier_block *nb,unsigned long action,void *data);@@ -70,12 +72,6 @@ struct raw_notifier_head {struct notifier_block __rcu *head; }; -struct srcu_notifier_head { -struct mutex mutex; -struct srcu_struct srcu; -struct notifier_block __rcu *head; -}; -#define ATOMIC_INIT_NOTIFIER_HEAD (name) do { \ spin_lock_init(&(name)->lock); \ (name)->head = NULL; \@@ -88,11 +84,6 @@ struct srcu_notifier_head { (name)->head =NULL ; \ } while (0) -/* srcu_notifier_heads must be initialized and cleaned up dynamically */ -extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); -#define srcu_cleanup_notifier_head (name) \ - cleanup_srcu_struct(&(name)->srcu); -#define ATOMIC_NOTIFIER_INIT (name) { \ .lock = __SPIN_LOCK_UNLOCKED(name.lock), \ .head = NULL }@@ -101,7 +92,6 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); .head = NULL }#define RAW_NOTIFIER_INIT (name) { \ .head = NULL } -/* srcu_notifier_heads cannot be initialized statically */ #define ATOMIC_NOTIFIER_HEAD (name) \ struct atomic_notifier_head name = \@@ -121,8 +111,6 @@ extern int blocking_notifier_chain_register(struct blocking_notifier_head *nh, struct notifier_block *nb);extern int raw_notifier_chain_register (struct raw_notifier_head *nh,struct notifier_block *nb); -extern int srcu_notifier_chain_register (struct srcu_notifier_head *nh, -struct notifier_block *nb); extern int blocking_notifier_chain_cond_register( struct blocking_notifier_head *nh,@@ -134,8 +122,6 @@ extern int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh, struct notifier_block *nb);extern int raw_notifier_chain_unregister (struct raw_notifier_head *nh,struct notifier_block *nb); -extern int srcu_notifier_chain_unregister (struct srcu_notifier_head *nh, -struct notifier_block *nb);extern int atomic_notifier_call_chain (struct atomic_notifier_head *nh,unsigned long val,void *v);@@ -149,10 +135,6 @@ extern int raw_notifier_call_chain(struct raw_notifier_head *nh, unsigned long val, void *v);extern int __raw_notifier_call_chain (struct raw_notifier_head *nh,unsigned long val,void *v,int nr_to_call,int *nr_calls); -extern int srcu_notifier_call_chain (struct srcu_notifier_head *nh, -unsigned long val,void *v); -extern int __srcu_notifier_call_chain (struct srcu_notifier_head *nh, -unsigned long val,void *v,int nr_to_call,int *nr_calls);#define NOTIFY_DONE 0x0000/* Don't care */ #define NOTIFY_OK 0x0001/* Suits me */ @@ -211,5 +193,30 @@ static inline int notifier_to_errno(int ret)extern struct blocking_notifier_head reboot_notifier_list; +#ifdef CONFIG_SRCU + +struct srcu_notifier_head { +struct mutex mutex; +struct srcu_struct srcu; +struct notifier_block __rcu *head; +}; + +/* srcu_notifier_heads must be initialized and cleaned up dynamically +* srcu_notifier_heads cannot be initialized statically +*/ +extern void srcu_init_notifier_head (struct srcu_notifier_head *nh); +#define srcu_cleanup_notifier_head (name) cleanup_srcu_struct(&(name)->srcu) + +extern int srcu_notifier_chain_register (struct srcu_notifier_head *nh, +struct notifier_block *nb); +extern int srcu_notifier_chain_unregister (struct srcu_notifier_head *nh, +struct notifier_block *nb); +extern int srcu_notifier_call_chain (struct srcu_notifier_head *nh, +unsigned long val,void *v); +extern int __srcu_notifier_call_chain (struct srcu_notifier_head *nh, +unsigned long val,void *v,int nr_to_call,int *nr_calls); + +#endif /* CONFIG_SRCU */ +#endif /* __KERNEL__ */ #endif /* _LINUX_NOTIFIER_H */ include/linux/srcu.h +5
-1@@ -26,6 +26,8 @@* */ +#ifdef CONFIG_SRCU +#ifndef _LINUX_SRCU_H#define _LINUX_SRCU_H@@ -249,4 +251,6 @@ static inline void smp_mb__after_srcu_read_unlock(void)/* __srcu_read_unlock has smp_mb() internally so nothing to do here. */ } -#endif +#endif /* _LINUX_SRCU_H */ + +#endif /* CONFIG_SRCU */ Signature · 1 line
1.9.1