
From: Roland McGrath <roland@redhat.com>

As I explained in the waitid patches, I added the si_rusage field to
siginfo_t with the idea of having the siginfo_t waitid fills in contain all
the information that wait4 or any such call could ever tell you.  Nowhere
in POSIX nor anywhere else specifies this field in siginfo_t.  

When Ulrich and I hashed out the system call interface we wanted, we looked
at siginfo_t and decided there was plenty of space to throw in si_rusage. 
Well, it turns out we didn't check the 64-bit platforms.  There struct
rusage is ridiculously large (lots of longs for things that are never in a
million years going to hit 2^32), and my changes bumped up the size of
siginfo_t.  Changing that size is more trouble than it's worth.

This patch reverts the changes to the siginfo_t structure types, and no
longer provides the rusage details in SIGCHLD signal data.  Instead, I
added a fifth argument to the waitid system call to fill in rusage.

waitid is the name of the POSIX function with four arguments.  It might
make sense to rename the system call `waitsys' to follow SGI's system call
with the same arguments, or `wait5' in the mindless tradition.  But, feh. 
I just added the argument to sys_waitid, rather than worrying about
changing the name in all the tables (and choosing a new stupid name).

Signed-off-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/sparc64/kernel/signal32.c |    3 ---
 25-akpm/arch/x86_64/ia32/ia32_signal.c |    2 --
 25-akpm/include/asm-generic/siginfo.h  |    2 --
 25-akpm/include/asm-ia64/siginfo.h     |    1 -
 25-akpm/include/asm-x86_64/ia32.h      |    1 -
 25-akpm/kernel/exit.c                  |   17 ++++++++++-------
 25-akpm/kernel/signal.c                |    4 ----
 7 files changed, 10 insertions(+), 20 deletions(-)

diff -puN arch/sparc64/kernel/signal32.c~back-out-siginfo_tsi_rusage-from-waitid-changes arch/sparc64/kernel/signal32.c
--- 25/arch/sparc64/kernel/signal32.c~back-out-siginfo_tsi_rusage-from-waitid-changes	2004-09-15 20:29:28.143956488 -0700
+++ 25-akpm/arch/sparc64/kernel/signal32.c	2004-09-15 20:29:28.156954512 -0700
@@ -122,7 +122,6 @@ struct siginfo32 {
 			int _status;			/* exit code */
 			compat_clock_t _utime;
 			compat_clock_t _stime;
-			struct compat_rusage _rusage;
 		} _sigchld;
 
 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
@@ -188,8 +187,6 @@ int copy_siginfo_to_user32(struct siginf
 			err |= __put_user(from->si_utime, &to->si_utime);
 			err |= __put_user(from->si_stime, &to->si_stime);
 			err |= __put_user(from->si_status, &to->si_status);
-			err |= put_compat_rusage(&from->si_rusage,
-						 &to->si_rusage);
 		default:
 			err |= __put_user(from->si_pid, &to->si_pid);
 			err |= __put_user(from->si_uid, &to->si_uid);
diff -puN arch/x86_64/ia32/ia32_signal.c~back-out-siginfo_tsi_rusage-from-waitid-changes arch/x86_64/ia32/ia32_signal.c
--- 25/arch/x86_64/ia32/ia32_signal.c~back-out-siginfo_tsi_rusage-from-waitid-changes	2004-09-15 20:29:28.144956336 -0700
+++ 25-akpm/arch/x86_64/ia32/ia32_signal.c	2004-09-15 20:29:28.157954360 -0700
@@ -74,8 +74,6 @@ int ia32_copy_siginfo_to_user(siginfo_t3
 			err |= __put_user(from->si_utime, &to->si_utime);
 			err |= __put_user(from->si_stime, &to->si_stime);
 			err |= __put_user(from->si_status, &to->si_status);
-			err |= put_compat_rusage(&from->si_rusage,
-						 &to->si_rusage);
 		default:
 		case __SI_KILL >> 16:
 			err |= __put_user(from->si_uid, &to->si_uid);
diff -puN include/asm-generic/siginfo.h~back-out-siginfo_tsi_rusage-from-waitid-changes include/asm-generic/siginfo.h
--- 25/include/asm-generic/siginfo.h~back-out-siginfo_tsi_rusage-from-waitid-changes	2004-09-15 20:29:28.146956032 -0700
+++ 25-akpm/include/asm-generic/siginfo.h	2004-09-15 20:29:28.158954208 -0700
@@ -75,7 +75,6 @@ typedef struct siginfo {
 			int _status;		/* exit code */
 			clock_t _utime;
 			clock_t _stime;
-			struct rusage _rusage;
 		} _sigchld;
 
 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
@@ -107,7 +106,6 @@ typedef struct siginfo {
 #define si_status	_sifields._sigchld._status
 #define si_utime	_sifields._sigchld._utime
 #define si_stime	_sifields._sigchld._stime
-#define si_rusage	_sifields._sigchld._rusage
 #define si_value	_sifields._rt._sigval
 #define si_int		_sifields._rt._sigval.sival_int
 #define si_ptr		_sifields._rt._sigval.sival_ptr
diff -puN include/asm-ia64/siginfo.h~back-out-siginfo_tsi_rusage-from-waitid-changes include/asm-ia64/siginfo.h
--- 25/include/asm-ia64/siginfo.h~back-out-siginfo_tsi_rusage-from-waitid-changes	2004-09-15 20:29:28.148955728 -0700
+++ 25-akpm/include/asm-ia64/siginfo.h	2004-09-15 20:29:28.158954208 -0700
@@ -56,7 +56,6 @@ typedef struct siginfo {
 			int _status;		/* exit code */
 			clock_t _utime;
 			clock_t _stime;
-			struct rusage _rusage;
 		} _sigchld;
 
 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
diff -puN include/asm-x86_64/ia32.h~back-out-siginfo_tsi_rusage-from-waitid-changes include/asm-x86_64/ia32.h
--- 25/include/asm-x86_64/ia32.h~back-out-siginfo_tsi_rusage-from-waitid-changes	2004-09-15 20:29:28.149955576 -0700
+++ 25-akpm/include/asm-x86_64/ia32.h	2004-09-15 20:29:28.158954208 -0700
@@ -115,7 +115,6 @@ typedef struct siginfo32 {
 			int _status;		/* exit code */
 			compat_clock_t _utime;
 			compat_clock_t _stime;
-			struct compat_rusage _rusage;
 		} _sigchld;
 
 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
diff -puN kernel/exit.c~back-out-siginfo_tsi_rusage-from-waitid-changes kernel/exit.c
--- 25/kernel/exit.c~back-out-siginfo_tsi_rusage-from-waitid-changes	2004-09-15 20:29:28.151955272 -0700
+++ 25-akpm/kernel/exit.c	2004-09-15 20:29:28.160953904 -0700
@@ -949,9 +949,10 @@ static int eligible_child(pid_t pid, int
 
 static int wait_noreap_copyout(task_t *p, pid_t pid, uid_t uid,
 			       int why, int status,
-			       struct siginfo __user *infop)
+			       struct siginfo __user *infop,
+			       struct rusage __user *rusagep)
 {
-	int retval = getrusage(p, RUSAGE_BOTH, &infop->si_rusage);
+	int retval = rusagep ? getrusage(p, RUSAGE_BOTH, rusagep) : 0;
 	put_task_struct(p);
 	if (!retval)
 		retval = put_user(SIGCHLD, &infop->si_signo);
@@ -1003,7 +1004,8 @@ static int wait_task_zombie(task_t *p, i
 			why = (exit_code & 0x80) ? CLD_DUMPED : CLD_KILLED;
 			status = exit_code & 0x7f;
 		}
-		return wait_noreap_copyout(p, pid, uid, why, status, infop);
+		return wait_noreap_copyout(p, pid, uid, why,
+					   status, infop, ru);
 	}
 
 	/*
@@ -1161,7 +1163,7 @@ static int wait_task_stopped(task_t *p, 
 			goto bail_ref;
 		return wait_noreap_copyout(p, pid, uid,
 					   why, (exit_code << 8) | 0x7f,
-					   infop);
+					   infop, ru);
 	}
 
 	write_lock_irq(&tasklist_lock);
@@ -1304,7 +1306,7 @@ check_continued:
 					read_unlock(&tasklist_lock);
 					retval = wait_noreap_copyout(p, pid,
 							uid, CLD_CONTINUED,
-							SIGCONT, infop);
+							SIGCONT, infop, ru);
 					BUG_ON(retval == 0);
 					goto end;
 				}
@@ -1371,7 +1373,8 @@ end:
 }
 
 asmlinkage long sys_waitid(int which, pid_t pid,
-			   struct siginfo __user *infop, int options)
+			   struct siginfo __user *infop, int options,
+			   struct rusage __user *ru)
 {
 	if (options & ~(WNOHANG|WNOWAIT|WEXITED|WSTOPPED|WCONTINUED))
 		return -EINVAL;
@@ -1395,7 +1398,7 @@ asmlinkage long sys_waitid(int which, pi
 		return -EINVAL;
 	}
 
-	return do_wait(pid, options, infop, NULL, &infop->si_rusage);
+	return do_wait(pid, options, infop, NULL, ru);
 }
 
 asmlinkage long sys_wait4(pid_t pid, unsigned int __user *stat_addr,
diff -puN kernel/signal.c~back-out-siginfo_tsi_rusage-from-waitid-changes kernel/signal.c
--- 25/kernel/signal.c~back-out-siginfo_tsi_rusage-from-waitid-changes	2004-09-15 20:29:28.152955120 -0700
+++ 25-akpm/kernel/signal.c	2004-09-15 20:29:28.162953600 -0700
@@ -1500,7 +1500,6 @@ void do_notify_parent(struct task_struct
 	/* FIXME: find out whether or not this is supposed to be c*time. */
 	info.si_utime = tsk->utime + tsk->signal->utime;
 	info.si_stime = tsk->stime + tsk->signal->stime;
-	k_getrusage(tsk, RUSAGE_BOTH, &info.si_rusage);
 
 	info.si_status = tsk->exit_code & 0x7f;
 	if (tsk->exit_code & 0x80)
@@ -1558,7 +1557,6 @@ do_notify_parent_cldstop(struct task_str
 	/* FIXME: find out whether or not this is supposed to be c*time. */
 	info.si_utime = tsk->utime;
 	info.si_stime = tsk->stime;
-	k_getrusage(tsk, RUSAGE_BOTH, &info.si_rusage);
 
  	info.si_code = why;
  	switch (why) {
@@ -2170,8 +2168,6 @@ int copy_siginfo_to_user(siginfo_t __use
 		err |= __put_user(from->si_status, &to->si_status);
 		err |= __put_user(from->si_utime, &to->si_utime);
 		err |= __put_user(from->si_stime, &to->si_stime);
-		err |= __copy_to_user(&to->si_rusage, &from->si_rusage,
-				      sizeof(to->si_rusage));
 		break;
 	case __SI_RT: /* This is not generated by the kernel as of now. */
 	case __SI_MESGQ: /* But this is */
_
