Re: [PATCH 4/4] exit: Lockless iteration over task list in mm_update_next_owner()

2018-04-26 Thread Kirill Tkhai
On 26.04.2018 18:29, Andrea Parri wrote: > On Thu, Apr 26, 2018 at 04:52:39PM +0300, Kirill Tkhai wrote: >> On 26.04.2018 15:35, Andrea Parri wrote: > > [...] > >>> >>> Mmh, it's possible that I am misunderstanding this statement but it does >>> not seem quite correct to me; a counter-example wou

Re: [PATCH 4/4] exit: Lockless iteration over task list in mm_update_next_owner()

2018-04-26 Thread Kirill Tkhai
On 26.04.2018 18:20, Peter Zijlstra wrote: > On Thu, Apr 26, 2018 at 04:52:39PM +0300, Kirill Tkhai wrote: 1)for_each_process(g)copy_process() p->mm = mm smp_rmb(); smp_wmb() implied by alloc_pid() i

Re: [PATCH 4/4] exit: Lockless iteration over task list in mm_update_next_owner()

2018-04-26 Thread Kirill Tkhai
On 26.04.2018 18:20, Peter Zijlstra wrote: > On Thu, Apr 26, 2018 at 04:52:39PM +0300, Kirill Tkhai wrote: >> In the patch I used the logic, that the below code: >> >> x = A; >> spin_lock(); >> spin_unlock(); >> spin_lock(); >> spin_unlock(); >> y = B; >> >> cannot reo

Re: [PATCH 4/4] exit: Lockless iteration over task list in mm_update_next_owner()

2018-04-26 Thread Andrea Parri
On Thu, Apr 26, 2018 at 04:52:39PM +0300, Kirill Tkhai wrote: > On 26.04.2018 15:35, Andrea Parri wrote: [...] > > > > Mmh, it's possible that I am misunderstanding this statement but it does > > not seem quite correct to me; a counter-example would be provided by the > > test at "tools/memory-m

Re: [PATCH 4/4] exit: Lockless iteration over task list in mm_update_next_owner()

2018-04-26 Thread Peter Zijlstra
On Thu, Apr 26, 2018 at 04:52:39PM +0300, Kirill Tkhai wrote: > >> > >> 1)for_each_process(g)copy_process() > >>p->mm = mm > >> smp_rmb(); smp_wmb() implied by alloc_pid() > >> if (g->flags & PF_KTHREAD) list_add_tail_r

Re: [PATCH 4/4] exit: Lockless iteration over task list in mm_update_next_owner()

2018-04-26 Thread Peter Zijlstra
On Thu, Apr 26, 2018 at 04:52:39PM +0300, Kirill Tkhai wrote: > In the patch I used the logic, that the below code: > > x = A; > spin_lock(); > spin_unlock(); > spin_lock(); > spin_unlock(); > y = B; > > cannot reorder much than: > > spin_lock(); >

Re: [PATCH 4/4] exit: Lockless iteration over task list in mm_update_next_owner()

2018-04-26 Thread Kirill Tkhai
On 26.04.2018 15:35, Andrea Parri wrote: > Hi Kirill, > > On Thu, Apr 26, 2018 at 02:01:07PM +0300, Kirill Tkhai wrote: >> The patch finalizes the series and makes mm_update_next_owner() >> to iterate over task list using RCU instead of tasklist_lock. >> This is possible because of rules of inheri

Re: [PATCH 4/4] exit: Lockless iteration over task list in mm_update_next_owner()

2018-04-26 Thread Andrea Parri
Hi Kirill, On Thu, Apr 26, 2018 at 02:01:07PM +0300, Kirill Tkhai wrote: > The patch finalizes the series and makes mm_update_next_owner() > to iterate over task list using RCU instead of tasklist_lock. > This is possible because of rules of inheritance of mm: it may be > propagated to a child onl

[PATCH 4/4] exit: Lockless iteration over task list in mm_update_next_owner()

2018-04-26 Thread Kirill Tkhai
The patch finalizes the series and makes mm_update_next_owner() to iterate over task list using RCU instead of tasklist_lock. This is possible because of rules of inheritance of mm: it may be propagated to a child only, while only kernel thread can obtain someone else's mm via use_mm(). Also, all