Skip to content

Commit a88f79f

Browse files
committed
dtrace: cyclics taking lock in atomic context
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 <[email protected]> Reviewed-by: Nick Alcock <[email protected]>
1 parent 508457e commit a88f79f

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

kernel/dtrace/cyclic.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <linux/spinlock.h>
2626
#include <linux/workqueue.h>
2727

28-
static DEFINE_SPINLOCK(cyclic_lock);
2928
static int omni_enabled = 0;
3029

3130
#define _CYCLIC_CPU_UNDEF (-1)
@@ -345,15 +344,6 @@ cyclic_id_t cyclic_add_omni(cyc_omni_handler_t *omni)
345344
for_each_online_cpu(cpu)
346345
cyclic_omni_start(cyc, cpu);
347346

348-
#ifdef CONFIG_HOTPLUG_CPU
349-
spin_lock_irqsave(&cyclic_lock, flags);
350-
if (!omni_enabled) {
351-
register_cpu_notifier(&cpu_notifier);
352-
omni_enabled = 1;
353-
}
354-
spin_unlock_irqrestore(&cyclic_lock, flags);
355-
#endif
356-
357347
return (cyclic_id_t)cyc;
358348
}
359349
EXPORT_SYMBOL(cyclic_add_omni);
@@ -542,9 +532,17 @@ static const struct file_operations proc_cyclicinfo_ops = {
542532
.release = seq_release,
543533
};
544534

545-
static int __init proc_cyclicinfo_init(void)
535+
static int __init cyclic_init(void)
546536
{
547537
proc_create("cyclicinfo", S_IRUSR, NULL, &proc_cyclicinfo_ops);
538+
539+
#ifdef CONFIG_HOTPLUG_CPU
540+
if (!omni_enabled) {
541+
register_cpu_notifier(&cpu_notifier);
542+
omni_enabled = 1;
543+
}
544+
#endif
545+
548546
return 0;
549547
}
550-
module_init(proc_cyclicinfo_init);
548+
module_init(cyclic_init);

0 commit comments

Comments
 (0)