(add utrace-devel) On 03/30, Roland McGrath wrote: > > * ptracer (parent) data structures cleanup > ** move ptraced list into ptracer sub-struct > ** add mutex locking ptracer > *** locks ptraced list, not tasklist_lock > *** locks ptrace_do_wait vs SIGCHLD/wakeup > *** locks tracees' ptrace flags, not task_lock/tasklist_lock
I tried to think about the first steps in ptrace-cleanup, and I need your help. To simplify, let's forget about task->ptrace/etc, let's say we just want to add the new ->ptrace_lock which protects ->ptraced list (instead of tasklist_lock). How should it nest with tasklist_lock? I don't think we should take ->ptrace_lock under tasklist. Instead, tasklist_lock should nest inside ->ptrace_lock, this means it could be ->ptrace_mutex. Otherwise, for example, it is not clear how can exit_ptrace() change tracee->exit_state. But, looking at do_wait(), I can't understand what can we do right now. Looks like we we have to move ptrace_do_wait() to another loop. But this doesn't look as a cleanup, this will complicate the code even more. Perhaps, we can simplify things if we add ->ptrace_mutex to signal_struct, not to task_struct. (actually, I think ->ptraced and ->children should go to signal_struct too). But even in this case I don't see the cleanup, without additional changes we should ptrace_do_wait() should take tasklist unconditionally. And this adds races. Unless we just add lock/unlock ->ptrace_mutex above the whole "do while_each_thread()" block. Not good! Thoughts? Oleg.