lkml.org 
[lkml]   [2018]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 4/4] exit: Lockless iteration over task list in mm_update_next_owner()
From
Date
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()
>>>> if (g->flags & PF_KTHREAD) list_add_tail_rcu(&p->tasks, &init_task.tasks)
>>>>
>>>> 2)for_each_thread(g, c) copy_process()
>>>> p->mm = mm
>>>> smp_rmb(); smp_wmb() implied by alloc_pid()
>>>> tmp = READ_ONCE(c->mm) list_add_tail_rcu(&p->thread_node, ...)
>
> For these two; what's the purpose of the smp_rmb()? which loads are
> ordered?

(1) and (2) make visible g->flags and c->mm in case we see process is linked
to the task list.

It seems in mm_update_next_owner() we may see result of list_add_tail_rcu(&p->thread_node, ...),
but p->mm = mm will not be visible.

Hm, also I've dived into list_add_tail_rcu() and it contains smp_wmb(). So, it seems
we do not need the barrier implied by alloc_pid().

Kirill

\
 
 \ /
  Last update: 2018-04-26 18:04    [W:0.183 / U:4.952 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site