On Wed, Feb 19, 2020 at 02:12:13PM -0800, Andy Lutomirski wrote: > On Wed, Feb 19, 2020 at 9:34 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote: > > Do you really want to create code that unwinds enough of nmi_enter() to > > get you to a preemptible context? *shudder* > > Well, there's another way to approach this: > > void notrace nonothing do_machine_check(struct pt_regs *regs) > { > if (user_mode(regs)) > do_sane_machine_check(regs); > else > do_awful_machine_check(regs); > } > > void do_sane_machine_check(regs) > { > nothing special here. just a regular exception, more or less. > } > > void do_awful_macine_check(regs) > { > basically an NMI. No funny business, no recovery possible. > task_work_add() not allowed. > } Right, that looks like major surgery to the current code though; I'd much prefer someone that knows that code do that. > I suppose the general consideration I'm trying to get at is: is > task_work_add() actually useful at all here? For the case when a > kernel thread does memcpy_mcsafe() or similar, task work registered > using task_work_add() will never run. task_work isn't at all useful when we didn't come from userspace. In that case irq_work is the best option, but that doesn't provide a preemptible context.