Skip to content

Commit cec6937

Browse files
committed
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: 466e4d8 ("task_work: Add TWA_NMI_CURRENT as an additional notify mode") Reported-by: Naresh Kamboju <[email protected]> Reported-by: kernelci.org bot <[email protected]> Reported-by: Guenter Roeck <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2accfdb commit cec6937

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernel/task_work.c

+6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
static struct callback_head work_exited; /* all we need is ->next == NULL */
88

9+
#ifdef CONFIG_IRQ_WORK
910
static void task_work_set_notify_irq(struct irq_work *entry)
1011
{
1112
test_and_set_tsk_thread_flag(current, TIF_NOTIFY_RESUME);
1213
}
1314
static DEFINE_PER_CPU(struct irq_work, irq_work_NMI_resume) =
1415
IRQ_WORK_INIT_HARD(task_work_set_notify_irq);
16+
#endif
1517

1618
/**
1719
* task_work_add - ask the @task to execute @work->func()
@@ -57,6 +59,8 @@ int task_work_add(struct task_struct *task, struct callback_head *work,
5759
if (notify == TWA_NMI_CURRENT) {
5860
if (WARN_ON_ONCE(task != current))
5961
return -EINVAL;
62+
if (!IS_ENABLED(CONFIG_IRQ_WORK))
63+
return -EINVAL;
6064
} else {
6165
/* record the work call stack in order to print it in KASAN reports */
6266
kasan_record_aux_stack(work);
@@ -81,9 +85,11 @@ int task_work_add(struct task_struct *task, struct callback_head *work,
8185
case TWA_SIGNAL_NO_IPI:
8286
__set_notify_signal(task);
8387
break;
88+
#ifdef CONFIG_IRQ_WORK
8489
case TWA_NMI_CURRENT:
8590
irq_work_queue(this_cpu_ptr(&irq_work_NMI_resume));
8691
break;
92+
#endif
8793
default:
8894
WARN_ON_ONCE(1);
8995
break;

0 commit comments

Comments
 (0)