about thread_info in task_struct

Stone, Joshua I joshua.i.stone@intel.com
Mon Jul 30 18:05:00 GMT 2007


Wenji Huang wrote:
> Another, I wrote function for returning task addr in case of only
> knowing pid:
> 
> /*return task addr according to process id*/
> function get_task: long (pid:long) %{
>         struct task_struct *p;
>         pid_t pid;
>         pid = (pid_t)(long)THIS->pid;
>         rcu_read_lock();
>         p = find_task_by_pid(pid);
>         rcu_read_unlock();
>         THIS->__retvalue = (long) p;
>         CATCH_DEREF_FAULT();
> %}

Mike Mason had something similar in the recent thread "Proposed task.stp additions".  The problem is that without calling get_task_struct(), you can't guarantee that the task pointer will remain valid.  We can possibly live with this, but scripts that use it might experience random dereference errors.

Also, you don't need CATCH_DEREF_FAULT(), because you aren't dereferencing any parameters with kread().

Josh


More information about the Systemtap mailing list