diff options
Diffstat (limited to 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index ea5c3bcac881..ebcb15611728 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -1338,6 +1338,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1338 | unsigned long flags; | 1338 | unsigned long flags; |
1339 | cputime_t utime, stime; | 1339 | cputime_t utime, stime; |
1340 | struct task_cputime cputime; | 1340 | struct task_cputime cputime; |
1341 | unsigned long maxrss = 0; | ||
1341 | 1342 | ||
1342 | memset((char *) r, 0, sizeof *r); | 1343 | memset((char *) r, 0, sizeof *r); |
1343 | utime = stime = cputime_zero; | 1344 | utime = stime = cputime_zero; |
@@ -1346,6 +1347,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1346 | utime = task_utime(current); | 1347 | utime = task_utime(current); |
1347 | stime = task_stime(current); | 1348 | stime = task_stime(current); |
1348 | accumulate_thread_rusage(p, r); | 1349 | accumulate_thread_rusage(p, r); |
1350 | maxrss = p->signal->maxrss; | ||
1349 | goto out; | 1351 | goto out; |
1350 | } | 1352 | } |
1351 | 1353 | ||
@@ -1363,6 +1365,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1363 | r->ru_majflt = p->signal->cmaj_flt; | 1365 | r->ru_majflt = p->signal->cmaj_flt; |
1364 | r->ru_inblock = p->signal->cinblock; | 1366 | r->ru_inblock = p->signal->cinblock; |
1365 | r->ru_oublock = p->signal->coublock; | 1367 | r->ru_oublock = p->signal->coublock; |
1368 | maxrss = p->signal->cmaxrss; | ||
1366 | 1369 | ||
1367 | if (who == RUSAGE_CHILDREN) | 1370 | if (who == RUSAGE_CHILDREN) |
1368 | break; | 1371 | break; |
@@ -1377,6 +1380,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1377 | r->ru_majflt += p->signal->maj_flt; | 1380 | r->ru_majflt += p->signal->maj_flt; |
1378 | r->ru_inblock += p->signal->inblock; | 1381 | r->ru_inblock += p->signal->inblock; |
1379 | r->ru_oublock += p->signal->oublock; | 1382 | r->ru_oublock += p->signal->oublock; |
1383 | if (maxrss < p->signal->maxrss) | ||
1384 | maxrss = p->signal->maxrss; | ||
1380 | t = p; | 1385 | t = p; |
1381 | do { | 1386 | do { |
1382 | accumulate_thread_rusage(t, r); | 1387 | accumulate_thread_rusage(t, r); |
@@ -1392,6 +1397,15 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1392 | out: | 1397 | out: |
1393 | cputime_to_timeval(utime, &r->ru_utime); | 1398 | cputime_to_timeval(utime, &r->ru_utime); |
1394 | cputime_to_timeval(stime, &r->ru_stime); | 1399 | cputime_to_timeval(stime, &r->ru_stime); |
1400 | |||
1401 | if (who != RUSAGE_CHILDREN) { | ||
1402 | struct mm_struct *mm = get_task_mm(p); | ||
1403 | if (mm) { | ||
1404 | setmax_mm_hiwater_rss(&maxrss, mm); | ||
1405 | mmput(mm); | ||
1406 | } | ||
1407 | } | ||
1408 | r->ru_maxrss = maxrss * (PAGE_SIZE / 1024); /* convert pages to KBs */ | ||
1395 | } | 1409 | } |
1396 | 1410 | ||
1397 | int getrusage(struct task_struct *p, int who, struct rusage __user *ru) | 1411 | int getrusage(struct task_struct *p, int who, struct rusage __user *ru) |