Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-05 Thread David Rientjes
On Thu, 5 Dec 2013, Oleg Nesterov wrote: > > Minor: should the definitions of thread_{head,node} be annotated with > > __rcu for users of CONFIG_SPARSE_RCU_POINTER? > > Perhaps. And perhaps task_struct->tasks. And perhaps we should add > rcu_read_lock_held() || lockdep_is_held(tasklist) ||

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-05 Thread Oleg Nesterov
On 12/04, David Rientjes wrote: > > Acked-by: David Rientjes Thanks! > Minor: should the definitions of thread_{head,node} be annotated with > __rcu for users of CONFIG_SPARSE_RCU_POINTER? Perhaps. And perhaps task_struct->tasks. And perhaps we should add rcu_read_lock_held() ||

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-05 Thread Oleg Nesterov
On 12/04, David Rientjes wrote: Acked-by: David Rientjes rient...@google.com Thanks! Minor: should the definitions of thread_{head,node} be annotated with __rcu for users of CONFIG_SPARSE_RCU_POINTER? Perhaps. And perhaps task_struct-tasks. And perhaps we should add rcu_read_lock_held() ||

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-05 Thread David Rientjes
On Thu, 5 Dec 2013, Oleg Nesterov wrote: Minor: should the definitions of thread_{head,node} be annotated with __rcu for users of CONFIG_SPARSE_RCU_POINTER? Perhaps. And perhaps task_struct-tasks. And perhaps we should add rcu_read_lock_held() || lockdep_is_held(tasklist) ||

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-04 Thread David Rientjes
On Wed, 4 Dec 2013, Oleg Nesterov wrote: > while_each_thread() and next_thread() should die, almost every > lockless usage is wrong. > > 1. Unless g == current, the lockless while_each_thread() is not safe. > >while_each_thread(g, t) can loop forever if g exits, next_thread() >can't

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-04 Thread Oleg Nesterov
On 12/04, Frederic Weisbecker wrote: > > On Wed, Dec 04, 2013 at 02:49:17PM +0100, Oleg Nesterov wrote: > > > > Yes, perhaps we will need for_each_thread_continue(). I am not sure > > yet. And note that, say, check_hung_uninterruptible_tasks() already > > does _continue if fact, although it is

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-04 Thread Frederic Weisbecker
On Wed, Dec 04, 2013 at 02:49:17PM +0100, Oleg Nesterov wrote: > On 12/04, Frederic Weisbecker wrote: > > > > On Wed, Dec 04, 2013 at 02:04:09PM +0100, Oleg Nesterov wrote: > > > > > For example, do/while_each_thread() always > > > sees at least one task, while for_each_thread() can do nothing if

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-04 Thread Oleg Nesterov
On 12/04, Frederic Weisbecker wrote: > > On Wed, Dec 04, 2013 at 02:04:09PM +0100, Oleg Nesterov wrote: > > > For example, do/while_each_thread() always > > sees at least one task, while for_each_thread() can do nothing if > > the whole thread group has died. > > Would it be safe to have

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-04 Thread Frederic Weisbecker
On Wed, Dec 04, 2013 at 02:04:09PM +0100, Oleg Nesterov wrote: > while_each_thread() and next_thread() should die, almost every > lockless usage is wrong. > > 1. Unless g == current, the lockless while_each_thread() is not safe. > >while_each_thread(g, t) can loop forever if g exits,

[PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-04 Thread Oleg Nesterov
while_each_thread() and next_thread() should die, almost every lockless usage is wrong. 1. Unless g == current, the lockless while_each_thread() is not safe. while_each_thread(g, t) can loop forever if g exits, next_thread() can't reach the unhashed thread in this case. Note that this can

[PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-04 Thread Oleg Nesterov
while_each_thread() and next_thread() should die, almost every lockless usage is wrong. 1. Unless g == current, the lockless while_each_thread() is not safe. while_each_thread(g, t) can loop forever if g exits, next_thread() can't reach the unhashed thread in this case. Note that this can

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-04 Thread Frederic Weisbecker
On Wed, Dec 04, 2013 at 02:04:09PM +0100, Oleg Nesterov wrote: while_each_thread() and next_thread() should die, almost every lockless usage is wrong. 1. Unless g == current, the lockless while_each_thread() is not safe. while_each_thread(g, t) can loop forever if g exits, next_thread()

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-04 Thread Oleg Nesterov
On 12/04, Frederic Weisbecker wrote: On Wed, Dec 04, 2013 at 02:04:09PM +0100, Oleg Nesterov wrote: For example, do/while_each_thread() always sees at least one task, while for_each_thread() can do nothing if the whole thread group has died. Would it be safe to have

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-04 Thread Frederic Weisbecker
On Wed, Dec 04, 2013 at 02:49:17PM +0100, Oleg Nesterov wrote: On 12/04, Frederic Weisbecker wrote: On Wed, Dec 04, 2013 at 02:04:09PM +0100, Oleg Nesterov wrote: For example, do/while_each_thread() always sees at least one task, while for_each_thread() can do nothing if the whole

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-04 Thread Oleg Nesterov
On 12/04, Frederic Weisbecker wrote: On Wed, Dec 04, 2013 at 02:49:17PM +0100, Oleg Nesterov wrote: Yes, perhaps we will need for_each_thread_continue(). I am not sure yet. And note that, say, check_hung_uninterruptible_tasks() already does _continue if fact, although it is still not

Re: [PATCH v2 1/4] introduce for_each_thread() to replace the buggy while_each_thread()

2013-12-04 Thread David Rientjes
On Wed, 4 Dec 2013, Oleg Nesterov wrote: while_each_thread() and next_thread() should die, almost every lockless usage is wrong. 1. Unless g == current, the lockless while_each_thread() is not safe. while_each_thread(g, t) can loop forever if g exits, next_thread() can't reach the