]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: cyclics taking lock in atomic context
authorTomas Jedlicka <tomas.jedlicka@oracle.com>
Fri, 25 Aug 2017 13:46:26 +0000 (09:46 -0400)
committerTomas Jedlicka <tomas.jedlicka@oracle.com>
Thu, 14 Sep 2017 09:13:37 +0000 (11:13 +0200)
The spin_lock_irqsave() makes cpu notifier addition run in atomic
context which may block.  The fix is to move this to module init time
that should be run only once and before DTrace comes around during
kernel boot.

Orabug: 26782572

Signed-off-by: Tomas Jedlicka <tomas.jedlicka@oracle.com>
Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
kernel/dtrace/cyclic.c

index 953245b6ee67f827738099774291f235de041d94..822bb3c6fbeaf9c3fd26b52508d7848b718ac81d 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 
-static DEFINE_SPINLOCK(cyclic_lock);
 static int             omni_enabled = 0;
 
 #define _CYCLIC_CPU_UNDEF              (-1)
@@ -345,15 +344,6 @@ cyclic_id_t cyclic_add_omni(cyc_omni_handler_t *omni)
        for_each_online_cpu(cpu)
                cyclic_omni_start(cyc, cpu);
 
-#ifdef CONFIG_HOTPLUG_CPU
-       spin_lock_irqsave(&cyclic_lock, flags);
-       if (!omni_enabled) {
-               register_cpu_notifier(&cpu_notifier);
-               omni_enabled = 1;
-       }
-       spin_unlock_irqrestore(&cyclic_lock, flags);
-#endif
-
        return (cyclic_id_t)cyc;
 }
 EXPORT_SYMBOL(cyclic_add_omni);
@@ -542,9 +532,17 @@ static const struct file_operations        proc_cyclicinfo_ops = {
        .release        = seq_release,
 };
 
-static int __init proc_cyclicinfo_init(void)
+static int __init cyclic_init(void)
 {
        proc_create("cyclicinfo", S_IRUSR, NULL, &proc_cyclicinfo_ops);
+
+#ifdef CONFIG_HOTPLUG_CPU
+       if (!omni_enabled) {
+               register_cpu_notifier(&cpu_notifier);
+               omni_enabled = 1;
+       }
+#endif
+
        return 0;
 }
-module_init(proc_cyclicinfo_init);
+module_init(cyclic_init);