Re: smp_mb__after_spinlock requirement too strong?

焦晓冬
2018-03-12T09:13:05Z

On Mon, Mar 12, 2018 at 4:56 PM, Peter Zijlstra <peterz@infradead.org> wrote:
> 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.

Hi, Peter,
If the fixed comment could point out where this RCsc is used, it will be great.