Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

task_work: make TWA_NMI_CURRENT handling conditional on IRQ_WORK

The TWA_NMI_CURRENT handling very much depends on IRQ_WORK, but that
isn't universally enabled everywhere.

Maybe the IRQ_WORK infrastructure should just be unconditional - x86
ends up indirectly enabling it through unconditionally enabling
PERF_EVENTS, for example. But it also gets enabled by having SMP
support, or even if you just have PRINTK enabled.

But in the meantime TWA_NMI_CURRENT causes tons of build failures on
various odd minimal configs. Which did show up in linux-next, but
despite that nobody bothered to fix it or even inform me until -rc1 was
out.

Fixes: 466e4d801cd4 ("task_work: Add TWA_NMI_CURRENT as an additional notify mode")
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Reported-by: kernelci.org bot <bot@kernelci.org>
Reported-by: Guenter Roeck <linux@roeck-us.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+6
+6
kernel/task_work.c
··· 6 6 7 7 static struct callback_head work_exited; /* all we need is ->next == NULL */ 8 8 9 + #ifdef CONFIG_IRQ_WORK 9 10 static void task_work_set_notify_irq(struct irq_work *entry) 10 11 { 11 12 test_and_set_tsk_thread_flag(current, TIF_NOTIFY_RESUME); 12 13 } 13 14 static DEFINE_PER_CPU(struct irq_work, irq_work_NMI_resume) = 14 15 IRQ_WORK_INIT_HARD(task_work_set_notify_irq); 16 + #endif 15 17 16 18 /** 17 19 * task_work_add - ask the @task to execute @work->func() ··· 59 57 if (notify == TWA_NMI_CURRENT) { 60 58 if (WARN_ON_ONCE(task != current)) 61 59 return -EINVAL; 60 + if (!IS_ENABLED(CONFIG_IRQ_WORK)) 61 + return -EINVAL; 62 62 } else { 63 63 /* record the work call stack in order to print it in KASAN reports */ 64 64 kasan_record_aux_stack(work); ··· 85 81 case TWA_SIGNAL_NO_IPI: 86 82 __set_notify_signal(task); 87 83 break; 84 + #ifdef CONFIG_IRQ_WORK 88 85 case TWA_NMI_CURRENT: 89 86 irq_work_queue(this_cpu_ptr(&irq_work_NMI_resume)); 90 87 break; 88 + #endif 91 89 default: 92 90 WARN_ON_ONCE(1); 93 91 break;