Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr()
From: Linus Torvalds
Date: Tue Oct 17 2023 - 17:53:58 EST
On Tue, 17 Oct 2023 at 14:06, Uros Bizjak <ubizjak@xxxxxxxxx> wrote:
>
> But adding the attached patch on top of both patches boots OK.
Funky.
Mind adding a
WARN_ON_ONCE(!active_mm);
to there to give a nice backtrace for the odd NULL case.
That code *is* related to 'current', in how we do
tsk = current;
...
local_irq_disable();
active_mm = tsk->active_mm;
tsk->active_mm = mm;
tsk->mm = mm;
...
activate_mm(active_mm, mm);
...
mmdrop_lazy_tlb(active_mm);
but I don't see how 'active_mm' could *poossibly* be validly NULL
here, and why caching 'current' would matter and change it.
Strange.
Hmm. We do set
tsk->active_mm = NULL;
in copy_mm(), and then we have that odd kernel thread case:
/*
* Are we cloning a kernel thread?
*
* We need to steal a active VM for that..
*/
oldmm = current->mm;
if (!oldmm)
return 0;
but none of this should even matter, because by the time we actually
*schedule* that thread, we'll set active_mm to the right thing.
Can anybody see what's up?
Linus