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
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.