Confused.
Let's return to
do
printk("%d\n", t->pid);
while_each_thread(g, t);
for the moment.
In that case, if g != 2910 (the exiting thread) we will print all pids,
except we can miss 2910. With or without next_thread_careful().
Only if we start at g == 2910, then
current code: print 2910, then spin forever printing
other pids
next_thread_careful: stop printing when we notice that 2910
was unhashed.
So, yes, in this case we can miss all
other threads.
As for "ls"ing the relevant /proc entry. proc_task_readdir() is complicated,
it can drop rcu lock, sleep, etc. But basically it mimics while_each_thread()
logic. Let's assume that proc_task_fill_cache() never fails.
proc_task_readdir() always starts at the group_leader, 2908. So, with or
without next_thread_careful() we can only miss the exiting 2910.
But (again, unless I missed something) the current code can race with exec,
and s/next_thread/next_thread_careful/ in first_tid() can fix the race.
(just in case, we can fix it differently).
But, of course, if you do "ls /proc/2910/task" instead of "ls /proc/2908/task"
you can miss _all_ threads if 2910 exits before proc_task_readdir() finds
its leader, 2908. Again, this is with or without next_thread_careful().
Paul, please let me know if I misunderstood your concerns, or if I missed
something.
Oleg.
--