Re: smp_mb__after_spinlock requirement too strong?

From: Peter Zijlstra
Date: Mon Mar 12 2018 - 04:57:01 EST


On Mon, Mar 12, 2018 at 04:56:00PM +0800, Boqun Feng wrote:
> So I think the purpose of smp_mb__after_spinlock() is to provide RCsc
> locks, it's just the comments before that may be misleading. We want
> RCsc locks in schedule code because we want writes in different critical
> section are ordered even outside the critical sections, for case like:
>
> CPU 0 CPU 1 CPU 2
>
> {A =0 , B = 0}
> lock(rq0);
> write A=1;
> unlock(rq0);
>
> lock(rq0);
> read A=1;
> write B=2;
> unlock(rq0);
>
> read B=2;
> smp_rmb();
> read A=1;
>
> I think we need to fix the comments rather than loose the requirement.
> Peter?

Yes, ISTR people relying on schedule() being RCsc, and I just picked a
bad exmaple.