Re: [PATCH, RESEND] getrusage: fill ru_maxrss value
flat view
From: Oleg Nesterov <hidden>
Date: 2008-12-16 15:23:25
Also in:
lkml
On 12/16, Jiri Pirko wrote:
This patch makes ->ru_maxrss value in struct rusage filled accordingly to rss hiwater mark. This struct is filled as a parameter to getrusage syscall. ->ru_maxrss value is set to pages which might be correct as "time" application converts it to KBs. To make this happen we extend struct signal_struct by two fields. The first one is ->maxrss which we use to store rss hiwater of the task. The second one is ->cmaxrss which we use to store highest rss hiwater of all task childs. These values are used in k_getrusage() to actually fill ->ru_maxrss. k_getrusage() uses current rss hiwater value directly if mm struct exists. We clear the ->maxrss as a part of flush_old_exec() to be consistent because bprm_mm_init() does not copy ->hiwater_rss.
Imho the patch is fine, but
quoted hunk ↗ jump to hunk
@@ -1598,6 +1601,15 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) out: cputime_to_timeval(utime, &r->ru_utime); cputime_to_timeval(stime, &r->ru_stime); + + task_lock(p); + if (p->mm) { + unsigned long maxrss = get_mm_hiwater_rss(p->mm); + + if (r->ru_maxrss < maxrss) + r->ru_maxrss = maxrss; + } + task_unlock(p);
I think the code above should check "if (who != RUSAGE_CHILDREN) ? Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html