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

From: Peter Xu
Date: Tue Dec 17 2019 - 15:48:47 EST


On Tue, Dec 17, 2019 at 09:23:52PM +0100, Peter Zijlstra wrote:
> > > 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")
> >
> > Yes that makes sense. Thanks for the pointer.
> >
> > However, then my next confusion is why they can't provide a common
> > solution to the smp code again... I feel like it could be even easier
> > (please see below). I'm not very familiar with smp code yet, but if
> > it works it should benefit all callers imho.
>
> Ah, so going to sleep on wait_for_completion() is _much_ more expensive
> than a short spin. So it all depends on the expected behaviour of the
> IPI I suppose.
>
> In general we expect these IPIs to be 'quick'.
>
> Also, as is, you're allowed to use the smp_call_function*() family with
> preemption disabled, which pretty much precludes using
> wait_for_completion().

Yes you are right, thanks!

Though I feel like previous small patch could still be an small
enhancement in that it at least shortened the get_cpu() period of
smp_call_function_single() without losing anything - so that could
still give the caller a chance to be scheduled out of the spinning at
some point when the IPI conditionally takes time to finish, imho.

--
Peter Xu