Re: [rfc][patch] Avoid taking global tasklist_lock for single threadedprocess at getrusage()

Oleg Nesterov
2005-12-28T11:23:11Z

Christoph Lameter wrote:
>
> On Sat, 24 Dec 2005, Oleg Nesterov wrote:
>
> > I can't understand this. 'p' can do clone(CLONE_THREAD) immediately
> > after 'if (!thread_group_empty(p))' check.
>
> Only if p != current. As discussed later the lockless approach is
> intened to only be used if p == current.

Unless I missed something this function (getrusage_both) is called
from wait_noreap_copyout,

> +++ linux-2.6.15-rc6/kernel/exit.c 2005-12-23 10:42:16.000000000 -0800
> @@ -38,7 +38,7 @@
> extern void sem_exit (void);
> extern struct task_struct *child_reaper;
>
> -int getrusage(struct task_struct *, int, struct rusage __user *);
> +int getrusage_both(struct task_struct *, struct rusage __user *);
>
> static void exit_mm(struct task_struct * tsk);
>
> @@ -994,7 +994,7 @@
> struct siginfo __user *infop,
> struct rusage __user *rusagep)
> {
> - int retval = rusagep ? getrusage(p, RUSAGE_BOTH, rusagep) : 0;
> + int retval = rusagep ? getrusage_both(p, rusagep) : 0;
> put_task_struct(p);

(the diff lacks '-p' parameter)

So p != current.

Oleg.