diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2017-03-25 13:42:07 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2017-04-18 14:38:22 -0400 |
commit | dde8da6cffe73dab81aca3855e717e40db35178c (patch) | |
tree | 8ba4ae7673a0106448a442033127669d8ea3658c | |
parent | f60d231a87c5c9f23f10e69996f396d46f5bf901 (diff) |
mm: Use static initialization for "srcu"
The MM-notifier code currently dynamically initializes the srcu_struct
named "srcu" at subsys_initcall() time, and includes a BUG_ON() to check
this initialization in do_mmu_notifier_register(). Unfortunately, there
is no foolproof way to verify that an srcu_struct has been initialized,
given the possibility of an srcu_struct being allocated on the stack or
on the heap. This means that creating an srcu_struct_is_initialized()
function is not a reasonable course of action. Nor is peppering
do_mmu_notifier_register() with SRCU-specific #ifdefs an attractive
alternative.
This commit therefore uses DEFINE_STATIC_SRCU() to initialize
this srcu_struct at compile time, thus eliminating both the
subsys_initcall()-time initialization and the runtime BUG_ON().
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: <linux-mm@kvack.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Vegard Nossum <vegard.nossum@oracle.com>
-rw-r--r-- | mm/mmu_notifier.c | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index a7652acd2ab9..54ca54562928 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | 22 | ||
23 | /* global SRCU for all MMs */ | 23 | /* global SRCU for all MMs */ |
24 | static struct srcu_struct srcu; | 24 | DEFINE_STATIC_SRCU(srcu); |
25 | 25 | ||
26 | /* | 26 | /* |
27 | * This function allows mmu_notifier::release callback to delay a call to | 27 | * This function allows mmu_notifier::release callback to delay a call to |
@@ -252,12 +252,6 @@ static int do_mmu_notifier_register(struct mmu_notifier *mn, | |||
252 | 252 | ||
253 | BUG_ON(atomic_read(&mm->mm_users) <= 0); | 253 | BUG_ON(atomic_read(&mm->mm_users) <= 0); |
254 | 254 | ||
255 | /* | ||
256 | * Verify that mmu_notifier_init() already run and the global srcu is | ||
257 | * initialized. | ||
258 | */ | ||
259 | BUG_ON(!srcu.per_cpu_ref); | ||
260 | |||
261 | ret = -ENOMEM; | 255 | ret = -ENOMEM; |
262 | mmu_notifier_mm = kmalloc(sizeof(struct mmu_notifier_mm), GFP_KERNEL); | 256 | mmu_notifier_mm = kmalloc(sizeof(struct mmu_notifier_mm), GFP_KERNEL); |
263 | if (unlikely(!mmu_notifier_mm)) | 257 | if (unlikely(!mmu_notifier_mm)) |
@@ -406,9 +400,3 @@ void mmu_notifier_unregister_no_release(struct mmu_notifier *mn, | |||
406 | mmdrop(mm); | 400 | mmdrop(mm); |
407 | } | 401 | } |
408 | EXPORT_SYMBOL_GPL(mmu_notifier_unregister_no_release); | 402 | EXPORT_SYMBOL_GPL(mmu_notifier_unregister_no_release); |
409 | |||
410 | static int __init mmu_notifier_init(void) | ||
411 | { | ||
412 | return init_srcu_struct(&srcu); | ||
413 | } | ||
414 | subsys_initcall(mmu_notifier_init); | ||