All of lore.kernel.org
 help / color / mirror / Atom feed
* getrusage(RUSAGE_BOTH)
@ 2020-01-18 16:48 Rasmus Villemoes
  2020-01-18 17:17 ` getrusage(RUSAGE_BOTH) Cyrill Gorcunov
  0 siblings, 1 reply; 2+ messages in thread
From: Rasmus Villemoes @ 2020-01-18 16:48 UTC (permalink / raw)
  To: LKML; +Cc: Andrew Morton, Cyrill Gorcunov, Kees Cook

RUSAGE_BOTH exists in the uapi header, but currently sys_getrusage
rejects it with -EINVAL:

SYSCALL_DEFINE2(getrusage, int, who, struct rusage __user *, ru)
{
        struct rusage r;

        if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN &&
            who != RUSAGE_THREAD)
                return -EINVAL;

getrusage(RUSAGE_BOTH) is used by the exit code in various places. But
is there any good reason not to allow userspace to use it? Of course one
can get the same info with two calls using RUSAGE_CHILDREN +
RUSAGE_SELF, but that seems a bit silly when the kernel already has the
code to do the summation.

Apart from the obvious addition above, I think the only thing needed is
to adjust the conditions where mm_highwater_rss gets updated:

        if (who != RUSAGE_CHILDREN && who != RUSAGE_BOTH) {
                struct mm_struct *mm = get_task_mm(p);

                if (mm) {
                        setmax_mm_hiwater_rss(&maxrss, mm);
                        mmput(mm);
                }



If RUSAGE_BOTH is not supposed to be used, perhaps it should be removed
from the uapi header?

Rasmus

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: getrusage(RUSAGE_BOTH)
  2020-01-18 16:48 getrusage(RUSAGE_BOTH) Rasmus Villemoes
@ 2020-01-18 17:17 ` Cyrill Gorcunov
  0 siblings, 0 replies; 2+ messages in thread
From: Cyrill Gorcunov @ 2020-01-18 17:17 UTC (permalink / raw)
  To: Rasmus Villemoes; +Cc: LKML, Andrew Morton, Kees Cook

On Sat, Jan 18, 2020 at 05:48:20PM +0100, Rasmus Villemoes wrote:
...
> 
> If RUSAGE_BOTH is not supposed to be used, perhaps it should be removed
> from the uapi header?

Hi Rasmus! I don't remember from scratch the RUSAGE_BOTH context
(out of sources right now), but dropping it from uapi is definitely
a wrong way -- since it is used inside kernel we should consider
it as reserved value thus it should better live in uapi.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-18 17:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-18 16:48 getrusage(RUSAGE_BOTH) Rasmus Villemoes
2020-01-18 17:17 ` getrusage(RUSAGE_BOTH) Cyrill Gorcunov

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.