From 8ec9399fea7540a67b41e1544114dd846f6c2795 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 15 Sep 2004 17:12:54 -0700 Subject: [PATCH] [PATCH] back out siginfo_t.si_rusage from waitid changes 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 Signed-off-by: Linus Torvalds --- arch/sparc64/kernel/signal32.c | 3 --- arch/x86_64/ia32/ia32_signal.c | 2 -- include/asm-generic/siginfo.h | 2 -- include/asm-ia64/siginfo.h | 1 - include/asm-x86_64/ia32.h | 1 - kernel/exit.c | 17 ++++++++++------- kernel/signal.c | 4 ---- 7 files changed, 10 insertions(+), 20 deletions(-) diff --git a/arch/sparc64/kernel/signal32.c b/arch/sparc64/kernel/signal32.c index f8bf70233fe74..ef51de605ff90 100644 --- a/arch/sparc64/kernel/signal32.c +++ b/arch/sparc64/kernel/signal32.c @@ -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 siginfo32 __user *to, siginfo_t *from) 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 --git a/arch/x86_64/ia32/ia32_signal.c b/arch/x86_64/ia32/ia32_signal.c index 432c8fa8d0e50..5fb7d173b9136 100644 --- a/arch/x86_64/ia32/ia32_signal.c +++ b/arch/x86_64/ia32/ia32_signal.c @@ -74,8 +74,6 @@ int ia32_copy_siginfo_to_user(siginfo_t32 __user *to, siginfo_t *from) 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 --git a/include/asm-generic/siginfo.h b/include/asm-generic/siginfo.h index eaacc06baec30..3a3f35d75af27 100644 --- a/include/asm-generic/siginfo.h +++ b/include/asm-generic/siginfo.h @@ -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 --git a/include/asm-ia64/siginfo.h b/include/asm-ia64/siginfo.h index cdaff790197f7..52cce1d3dad86 100644 --- a/include/asm-ia64/siginfo.h +++ b/include/asm-ia64/siginfo.h @@ -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 --git a/include/asm-x86_64/ia32.h b/include/asm-x86_64/ia32.h index e5fb979694280..73319a9a8ca5d 100644 --- a/include/asm-x86_64/ia32.h +++ b/include/asm-x86_64/ia32.h @@ -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 --git a/kernel/exit.c b/kernel/exit.c index bfdcb19d871bd..258964cbdbbde 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -949,9 +949,10 @@ static int eligible_child(pid_t pid, int options, task_t *p) 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, int noreap, 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, int delayed_group_leader, int noreap, 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, pid_t pid, 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 --git a/kernel/signal.c b/kernel/signal.c index 0897da772a05c..df2cd4216838c 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1500,7 +1500,6 @@ void do_notify_parent(struct task_struct *tsk, int sig) /* 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_struct *tsk, struct task_struct *parent, /* 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 __user *to, siginfo_t *from) 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 */ -- 2.53.0