From: Arve Hjønnevåg Date: Thu, 11 Dec 2008 04:06:28 +0000 (-0800) Subject: sched: Enable might_sleep before initializing drivers. X-Git-Tag: firefly_0821_release~9833^2~5^2~352 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a69de5bf21baf09c6039586a560b5ec679979c00;p=firefly-linux-kernel-4.4.55.git sched: Enable might_sleep before initializing drivers. This allows detection of init bugs in built-in drivers. Signed-off-by: Arve Hjønnevåg --- diff --git a/kernel/sched.c b/kernel/sched.c index dc85ceb90832..2aa4e56acd89 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -7891,13 +7891,24 @@ static inline int preempt_count_equals(int preempt_offset) return (nested == PREEMPT_INATOMIC_BASE + preempt_offset); } +static int __might_sleep_init_called; +int __init __might_sleep_init(void) +{ + __might_sleep_init_called = 1; + return 0; +} +early_initcall(__might_sleep_init); + void __might_sleep(const char *file, int line, int preempt_offset) { #ifdef in_atomic static unsigned long prev_jiffy; /* ratelimiting */ if ((preempt_count_equals(preempt_offset) && !irqs_disabled()) || - system_state != SYSTEM_RUNNING || oops_in_progress) + oops_in_progress) + return; + if (system_state != SYSTEM_RUNNING && + (!__might_sleep_init_called || system_state != SYSTEM_BOOTING)) return; if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy) return;