This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: about thread_info in task_struct


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]