From: "Nippun Goel" <nippung@calsoftinc.com>
To: Christoph Lameter <clameter@engr.sgi.com>
Cc: Ravikiran G Thirumalai <kiran@scalex86.org>,
Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org,
"Shai Fultheim (Shai@scalex86.org)" <shai@scalex86.org>,
Nippun Goel <nippung@calsoftinc.com>
Subject: Re: [rfc][patch] Avoid taking global tasklist_lock for single threaded process at getrusage()
Date: Fri, 23 Dec 2005 21:34:48 -0800 [thread overview]
Message-ID: <1135402488.3684@cyclone.he.net> (raw)
On 12/24/05, Christoph Lameter <clameter@engr.sgi.com> wrote:
> Please put the copy_to_user() invocation into sys_getrusage. That is the
> only function that needs to deal with user space issues includding
> the transfer of the contents of struct rusage. Define
> a local rusage in sys_getrusage. Pass that address to the other functions
> and only copy on success to user space.
rusage_both is called at various places in exit.c, all of which are in
turn called from sys_wait4 through do_wait. They pass a user space
rusage struct pointer and expect the results to be copied there.
Similarly, rusage_self and rusage_children are called from sysirix.c
which also seemingly passes a user space pointer to them. Hence, the
copy to user in all three functions.
n.
> copy_to_user occurs repeatedly:
>
> On Fri, 23 Dec 2005, Ravikiran G Thirumalai wrote:
>
>
> > if (unlikely(!p->signal))
> > - return;
> > + return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
> >
> > + cputime_to_timeval(utime, &r.ru_utime);
> > + cputime_to_timeval(stime, &r.ru_stime);
> > +
> > + return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
> > +}
> > +
> > +
> > + return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
> > }
> >
> > + if (unlikely(!p->signal))
> > + return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
> > +
>
> But its only needed here:
>
> > asmlinkage long sys_getrusage(int who, struct rusage __user *ru)
> > {
> > - if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
> > - return -EINVAL;
> > - return getrusage(current, who, ru);
> > + switch (who) {
> > + case RUSAGE_SELF:
> > + return getrusage_self(ru);
> > + case RUSAGE_CHILDREN:
> > + return getrusage_children(ru);
> > + default:
> > + break;
> > + }
> > + return -EINVAL;
> > }
>
>
next reply other threads:[~2005-12-24 5:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-24 5:34 Nippun Goel [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-12-24 17:52 [rfc][patch] Avoid taking global tasklist_lock for single threaded process at getrusage() Oleg Nesterov
2005-12-27 20:21 ` Christoph Lameter
2005-12-21 18:23 Ravikiran G Thirumalai
2005-12-21 20:20 ` Christoph Lameter
2005-12-21 21:11 ` Ravikiran G Thirumalai
2005-12-21 21:22 ` Christoph Lameter
2005-12-21 21:35 ` Ravikiran G Thirumalai
2005-12-23 23:15 ` Ravikiran G Thirumalai
2005-12-24 0:13 ` Christoph Lameter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1135402488.3684@cyclone.he.net \
--to=nippung@calsoftinc.com \
--cc=akpm@osdl.org \
--cc=clameter@engr.sgi.com \
--cc=kiran@scalex86.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shai@scalex86.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.