Commit d8888069 authored by Roland McGrath's avatar Roland McGrath Committed by Linus Torvalds

[PATCH] Remove RUSAGE_GROUP

After my cleanup of the rusage semantics was so quickly taken in by Andrew
and Linus without comment, I wonder if I should not have tried to be so
accommodating of potential objections as I was.  :-)

In my original posting, I solicited comment on whether introducing
RUSAGE_GROUP as distinct from RUSAGE_SELF was warranted.  Note that we've
now changed the behavior of the times system call when using CLONE_THREAD,
so changing getrusage RUSAGE_SELF to match would be consistent.  I think
that changing the meaning of the old RUSAGE_SELF value is preferable to
introducing the new value for the proper POSIX getrusage behavior.  This
patch against Linus's current tree dumps RUSAGE_GROUP and makes RUSAGE_SELF
have the fixed behavior.

If there is interest in having a new explicit interface to sample a single
thread's stats alone, then I think that would be better done by introducing
a new value for RUSAGE_THREAD.  This is trivial to implement, but I won't
offer patches bloating the interface if noone is actually interested in
using it.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fad0738b
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#define RUSAGE_SELF 0 #define RUSAGE_SELF 0
#define RUSAGE_CHILDREN (-1) #define RUSAGE_CHILDREN (-1)
#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */ #define RUSAGE_BOTH (-2) /* sys_wait4() uses this */
#define RUSAGE_GROUP (-3) /* thread group sum + dead threads */
struct rusage { struct rusage {
struct timeval ru_utime; /* user time used */ struct timeval ru_utime; /* user time used */
......
...@@ -1561,7 +1561,7 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim) ...@@ -1561,7 +1561,7 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
* This expects to be called with tasklist_lock read-locked or better, * This expects to be called with tasklist_lock read-locked or better,
* and the siglock not locked. It may momentarily take the siglock. * and the siglock not locked. It may momentarily take the siglock.
* *
* When sampling multiple threads for RUSAGE_GROUP, under SMP we might have * When sampling multiple threads for RUSAGE_SELF, under SMP we might have
* races with threads incrementing their own counters. But since word * races with threads incrementing their own counters. But since word
* reads are atomic, we either get new values or old values and we don't * reads are atomic, we either get new values or old values and we don't
* care which for the sums. We always take the siglock to protect reading * care which for the sums. We always take the siglock to protect reading
...@@ -1582,14 +1582,6 @@ void k_getrusage(struct task_struct *p, int who, struct rusage *r) ...@@ -1582,14 +1582,6 @@ void k_getrusage(struct task_struct *p, int who, struct rusage *r)
return; return;
switch (who) { switch (who) {
case RUSAGE_SELF:
jiffies_to_timeval(p->utime, &r->ru_utime);
jiffies_to_timeval(p->stime, &r->ru_stime);
r->ru_nvcsw = p->nvcsw;
r->ru_nivcsw = p->nivcsw;
r->ru_minflt = p->min_flt;
r->ru_majflt = p->maj_flt;
break;
case RUSAGE_CHILDREN: case RUSAGE_CHILDREN:
spin_lock_irqsave(&p->sighand->siglock, flags); spin_lock_irqsave(&p->sighand->siglock, flags);
utime = p->signal->cutime; utime = p->signal->cutime;
...@@ -1602,7 +1594,7 @@ void k_getrusage(struct task_struct *p, int who, struct rusage *r) ...@@ -1602,7 +1594,7 @@ void k_getrusage(struct task_struct *p, int who, struct rusage *r)
jiffies_to_timeval(utime, &r->ru_utime); jiffies_to_timeval(utime, &r->ru_utime);
jiffies_to_timeval(stime, &r->ru_stime); jiffies_to_timeval(stime, &r->ru_stime);
break; break;
case RUSAGE_GROUP: case RUSAGE_SELF:
spin_lock_irqsave(&p->sighand->siglock, flags); spin_lock_irqsave(&p->sighand->siglock, flags);
utime = stime = 0; utime = stime = 0;
goto sum_group; goto sum_group;
...@@ -1651,8 +1643,7 @@ int getrusage(struct task_struct *p, int who, struct rusage __user *ru) ...@@ -1651,8 +1643,7 @@ int getrusage(struct task_struct *p, int who, struct rusage __user *ru)
asmlinkage long sys_getrusage(int who, struct rusage __user *ru) asmlinkage long sys_getrusage(int who, struct rusage __user *ru)
{ {
if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
&& who != RUSAGE_GROUP)
return -EINVAL; return -EINVAL;
return getrusage(current, who, ru); return getrusage(current, who, ru);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment