lkml.org 
[lkml]   [2020]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 1/2] sched: Fix exit_mm vs membarrier
----- On Aug 4, 2020, at 12:51 PM, Peter Zijlstra peterz@infradead.org wrote:

> On Tue, Aug 04, 2020 at 10:48:41AM -0400, Mathieu Desnoyers wrote:
>> Here is the scenario I have in mind:
>
>> Userspace variables:
>>
>> int x = 0, y = 0;
>>
>> CPU 0 CPU 1
>> Thread A Thread B
>> (in thread group A) (in thread group B)
>>
>> x = 1
>> barrier()
>> y = 1
>> exit()
>> exit_mm()
>> current->mm = NULL;
>> r1 = load y
>> membarrier()
>> skips CPU 0 (no IPI) because its current mm is NULL
>> r2 = load x
>> BUG_ON(r1 == 1 && r2 == 0)
>>
>
> Ah, yes of course.
>
> We really should have a bunch of these scenarios in membarrier.c.

Good point.

>
>
>
> Now, the above cannot happen because we have an unconditional
> atomic_dec_and_test() in do_exit() before exit_mm(), but I'm sure
> relying on that is a wee bit dodgy.

I am not against using this already existing barrier to provide the
guarantee we need, but it would have to be documented in the code.

Thanks,

Mathieu

--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

\
 
 \ /
  Last update: 2020-08-04 19:25    [W:0.057 / U:0.912 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site