Re: [PATCH] smp: Allow smp_call_function_single_async() to insert locked csd

From: Peter Zijlstra
Date: Tue Dec 17 2019 - 04:52:06 EST


On Mon, Dec 16, 2019 at 03:58:33PM -0500, Peter Xu wrote:
> On Mon, Dec 16, 2019 at 09:37:05PM +0100, Peter Zijlstra wrote:
> > On Wed, Dec 11, 2019 at 11:29:25AM -0500, Peter Xu wrote:

> > > (3) Others:
> > >
> > > *** arch/mips/kernel/process.c:
> > > raise_backtrace[713] smp_call_function_single_async(cpu, csd);
> >
> > per-cpu csd data, seems perfectly fine usage.
>
> I'm not sure whether I get the point, I just feel like it could still
> trigger as long as we do it super fast, before IPI handled,
> disregarding whether it's per-cpu csd or not.

No, I wasn't paying attention last night. I'm thinking this one might
maybe be in 1). It does the state check using that bitmap.

> > > *** arch/x86/kernel/cpuid.c:
> > > cpuid_read[85] err = smp_call_function_single_async(cpu, &csd);
> > > *** arch/x86/lib/msr-smp.c:
> > > rdmsr_safe_on_cpu[182] err = smp_call_function_single_async(cpu, &csd);
> >
> > These two have csd on stack and wait with a completion. seems fine.
>
> Yeh this is true, then I'm confused why they don't use the sync()
> helpers..

I suspect to be nice for virt. Both CPUID and MSR accesses can trap. but
now I'm confused, because it is mostly WRMSR that traps.

Anyway, see the commit here: 07cde313b2d2 ("x86/msr: Allow rdmsr_safe_on_cpu() to schedule")