Hello Ravikiran,
Ravikiran G Thirumalai wrote:
>
> Following patch avoids taking the global tasklist_lock when possible,
> if a process is single threaded during getrusage(). Any avoidance of
> tasklist_lock is good for NUMA boxes (and possibly for large SMPs).
>
> ...
>
> static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
> @@ -1681,14 +1697,22 @@ static void k_getrusage(struct task_stru
> struct task_struct *t;
> unsigned long flags;
> cputime_t utime, stime;
> + int need_lock = 0;
>
> memset((char *) r, 0, sizeof *r);
> -
> - if (unlikely(!p->signal))
> - return;
> -
> utime = stime = cputime_zero;
>
> + need_lock = (p != current || !thread_group_empty(p));
> + if (need_lock) {
> + read_lock(&tasklist_lock);
> + if (unlikely(!p->signal)) {
> + read_unlock(&tasklist_lock);
> + return;
> + }
> + } else
> + /* See locking comments above */
> + smp_rmb();
> +
I think now it is possible to improve this patch.
Could you look at these patches?
[PATCH] introduce lock_task_sighand() helper
http://marc.theaimsgroup.com/?l=linux-kernel&m=114028190927763
[PATCH 0/3] make threads traversal ->siglock safe
http://marc.theaimsgroup.com/?l=linux-kernel&m=114064825626496
I think we can forget about tasklist_lock in k_getrusage() completely
and just use lock_task_sighand().
What do you think?
Oleg.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]