lkml.org 
[lkml]   [2015]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] change current_is_single_threaded() to use for_each_thread()
On 10/07, David Howells wrote:
>
> Oleg Nesterov <oleg@redhat.com> wrote:
>
> > Change current_is_single_threaded() to use for_each_thread() rather
> > than deprecated while_each_thread().
>
> Wouldn't the old way be more efficient, given there's always going to be at
> least one thread?

Yes, unfortunately. Before this change (in the likely case) we never
do next_thread(), after this patch we always do list_first_entry().

> Granted, it's not much of an efficiency boost...

Yes, and while_each_thread() is buggy. See the changelog in 0c740d0afc
"introduce for_each_thread() to replace the buggy while_each_thread().

Yes, the race is almost purely theoretical, but still.

To clarify, we had some "real" bugs fixed by s/while_each_thread/
for_each_thread/, but only because while_each_thread() was used wrongly.
for_each_thread() is more safe, it only needs the stable task_struct.

Oleg.



\
 
 \ /
  Last update: 2015-10-07 14:21    [W:0.159 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site