diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 24719eaa1209f5c68dda24bbbf0ec46a8e234598..4c7e2e5087662bf6b2d975c5ead41ab77ebd5508 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -193,13 +193,10 @@ extern int _cond_resched(void); (__x < 0) ? -__x : __x; \ }) -#ifdef CONFIG_PROVE_LOCKING +#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP) void might_fault(void); #else -static inline void might_fault(void) -{ - __might_sleep(__FILE__, __LINE__, 0); -} +static inline void might_fault(void) { } #endif extern struct atomic_notifier_head panic_notifier_list; diff --git a/mm/memory.c b/mm/memory.c index c1f190f51f6f2d2ff62a4851e2fd37cbdcaacdc7..d7d54a11477372b605b34af65c233f206a7bd982 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4210,7 +4210,7 @@ void print_vma_addr(char *prefix, unsigned long ip) up_read(&mm->mmap_sem); } -#ifdef CONFIG_PROVE_LOCKING +#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP) void might_fault(void) { /* @@ -4222,14 +4222,17 @@ void might_fault(void) if (segment_eq(get_fs(), KERNEL_DS)) return; - __might_sleep(__FILE__, __LINE__, 0); - /* * it would be nicer only to annotate paths which are not under * pagefault_disable, however that requires a larger audit and * providing helpers like get_user_atomic. */ - if (!in_atomic() && current->mm) + if (in_atomic()) + return; + + __might_sleep(__FILE__, __LINE__, 0); + + if (current->mm) might_lock_read(¤t->mm->mmap_sem); } EXPORT_SYMBOL(might_fault);