Hi - Forwarded from ananth, whose emails are not hitting utrace-devel for some reason:
Date: Wed, 22 Jul 2009 13:21:43 +0530 From: Ananth N Mavinakayanahalli <ana...@in.ibm.com> To: utrace-devel@redhat.com Subject: Q: attaching engines to all threads Roland, Oleg, What do you think is the best model to attach engines to all threads of a process safely using utrace? Uprobes implements it in a slightly convoluted fashion, while I wrote (assuming 'task' is a valid task_struct, corresponding to the tgid of the multi-threaded process): + rcu_read_lock(); + do { + get_task_struct(t); + rcu_read_unlock(); + ret = <attach_your_engine_and_set_events>(t); + if (ret && (ret != EINPROGRESS)) + goto err; + rcu_read_lock(); + put_task_struct(t); + ret = 0; + t = next_thread(t); + } while (t != task); + + rcu_read_unlock(); But this is still not 'safe' as there are still races/possibility of t dying within the unlock/lock in the loop. And its not possible to hold the rcu_read_lock all the way since the routine that attaches the engine will need to do a kzalloc and the like for housekeeping. What is your preferred approach for this? Ananth PS: I believe getting a feature/callback implemented in utrace so not every user of the infrastructure needs to reinvent the wheel is a good idea. In fact, it may be a better thing to have simply to avoid buggy implementations.