Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754124AbZFIPOb (ORCPT ); Tue, 9 Jun 2009 11:14:31 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751231AbZFIPOX (ORCPT ); Tue, 9 Jun 2009 11:14:23 -0400 Received: from mail-ew0-f210.google.com ([209.85.219.210]:36558 "EHLO mail-ew0-f210.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751493AbZFIPOW (ORCPT ); Tue, 9 Jun 2009 11:14:22 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:message-id:from:to:subject:in-reply-to:references:user-agent :mime-version:content-type; b=j5b1JH09gFrl8xMZPLWzlM0VWxemDGFFDwm9hS8aDeWg61rs0dhr9CZ5C8wcn5eNSl Tv9iTik5TQf3BBnkzmRXm8JKhg8tiK+/YhA8Tntww6ATx2cJYGJ+oeWszPWFegU0yCb2 MCJTIXqPqzOpcB3jeYWx2C+fX/mR1I5msHbUY= Date: Tue, 09 Jun 2009 17:14:25 +0200 Message-ID: <873aa9wib2.wl%vmayatsk@redhat.com> From: Vitaly Mayatskikh To: Andrew Morton , Oleg Nesterov , Ingo Molnar , Roland McGrath , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] Split wait_noreap_copyout() In-Reply-To: <1242048349-2766-2-git-send-email-v.mayatskih@gmail.com> References: <1242048349-2766-1-git-send-email-v.mayatskih@gmail.com> <1242048349-2766-2-git-send-email-v.mayatskih@gmail.com> User-Agent: Wanderlust/2.15.6 (Almost Unreal) Emacs/22.3 Mule/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3425 Lines: 99 Hi, Andrew! Can you, please, update description of wait_task_-cleanups-split-wait_noreap_copyout.patch? New description: ---------------------------------------------------------------------- Move getrusage() and put_user() code from wait_noreap_copyout() to copy_wait_opts_to_user(). The same code is spreaded across all wait_task_*() routines, it's better to reuse one copy. User visible change: previously, waitid() was doing unconditional put_user() in wait_noreap_copyout(), and was returning EFAULT if infop pointer, provided by user, was NULL *and* WCONTINUED was not set in options. Now all variants of wait() function use the same generic copy_wait_opts_to_user(), and, thus, have the same behaviour regarding to filling of siginfo structure. Starting from this commit waitid() returns NULL if infop argument is NULL. ---------------------------------------------------------------------- Thanks! > > Move getrusage() and put_user() code from wait_noreap_copyout() > to copy_wait_opts_to_user(). The same code is spreaded across all > wait_task_*() routines, it's better to reuse one copy. > > Signed-off-by: Vitaly Mayatskikh > --- > kernel/exit.c | 39 +++++++++++++++++++++++---------------- > 1 files changed, 23 insertions(+), 16 deletions(-) > > diff --git a/kernel/exit.c b/kernel/exit.c > index 25782da..9546362 100644 > --- a/kernel/exit.c > +++ b/kernel/exit.c > @@ -1123,27 +1123,34 @@ static int eligible_child(struct wait_opts *wo, struct task_struct *p) > return 1; > } > > -static int wait_noreap_copyout(struct wait_opts *wo, struct task_struct *p, > - pid_t pid, uid_t uid, int why, int status) > +static int copy_wait_opts_to_user(struct wait_opts *wo, struct task_struct *p, > + pid_t pid, uid_t uid, int why, int status, int signal) > { > - struct siginfo __user *infop; > + struct siginfo __user *infop = wo->wo_info; > int retval = wo->wo_rusage > ? getrusage(p, RUSAGE_BOTH, wo->wo_rusage) : 0; > > + if (!retval && infop) { > + retval = put_user(signal, &infop->si_signo); > + if (!retval) > + retval = put_user(0, &infop->si_errno); > + if (!retval) > + retval = put_user((short)why, &infop->si_code); > + if (!retval) > + retval = put_user(pid, &infop->si_pid); > + if (!retval) > + retval = put_user(uid, &infop->si_uid); > + if (!retval) > + retval = put_user(status, &infop->si_status); > + } > + return retval; > +} > + > +static int wait_noreap_copyout(struct wait_opts *wo, struct task_struct *p, > + pid_t pid, uid_t uid, int why, int status) > +{ > + int retval = copy_wait_opts_to_user(wo, p, pid, uid, why, status, SIGCHLD); > put_task_struct(p); > - infop = wo->wo_info; > - if (!retval) > - retval = put_user(SIGCHLD, &infop->si_signo); > - if (!retval) > - retval = put_user(0, &infop->si_errno); > - if (!retval) > - retval = put_user((short)why, &infop->si_code); > - if (!retval) > - retval = put_user(pid, &infop->si_pid); > - if (!retval) > - retval = put_user(uid, &infop->si_uid); > - if (!retval) > - retval = put_user(status, &infop->si_status); > if (!retval) > retval = pid; > return retval; > -- > 1.6.2.2 > > -- wbr, Vitaly -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/