This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
RE: about thread_info in task_struct
- From: "Stone, Joshua I" <joshua dot i dot stone at intel dot com>
- To: "Wenji Huang" <wenji dot huang at oracle dot com>, <systemtap at sourceware dot org>
- Date: Mon, 30 Jul 2007 10:10:02 -0700
- Subject: RE: about thread_info in task_struct
- References: <46ADB6BC.3090803@oracle.com>
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