diff options
Diffstat (limited to 'kernel/sys.c')
| -rw-r--r-- | kernel/sys.c | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index b3f1097c76fa..255475d163e0 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | #include <linux/prctl.h> | 14 | #include <linux/prctl.h> |
| 15 | #include <linux/highuid.h> | 15 | #include <linux/highuid.h> |
| 16 | #include <linux/fs.h> | 16 | #include <linux/fs.h> |
| 17 | #include <linux/perf_counter.h> | 17 | #include <linux/perf_event.h> |
| 18 | #include <linux/resource.h> | 18 | #include <linux/resource.h> |
| 19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/kexec.h> | 20 | #include <linux/kexec.h> |
| @@ -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) |
| @@ -1511,11 +1525,11 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, | |||
| 1511 | case PR_SET_TSC: | 1525 | case PR_SET_TSC: |
| 1512 | error = SET_TSC_CTL(arg2); | 1526 | error = SET_TSC_CTL(arg2); |
| 1513 | break; | 1527 | break; |
| 1514 | case PR_TASK_PERF_COUNTERS_DISABLE: | 1528 | case PR_TASK_PERF_EVENTS_DISABLE: |
| 1515 | error = perf_counter_task_disable(); | 1529 | error = perf_event_task_disable(); |
| 1516 | break; | 1530 | break; |
| 1517 | case PR_TASK_PERF_COUNTERS_ENABLE: | 1531 | case PR_TASK_PERF_EVENTS_ENABLE: |
| 1518 | error = perf_counter_task_enable(); | 1532 | error = perf_event_task_enable(); |
| 1519 | break; | 1533 | break; |
| 1520 | case PR_GET_TIMERSLACK: | 1534 | case PR_GET_TIMERSLACK: |
| 1521 | error = current->timer_slack_ns; | 1535 | error = current->timer_slack_ns; |
| @@ -1528,6 +1542,28 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, | |||
| 1528 | current->timer_slack_ns = arg2; | 1542 | current->timer_slack_ns = arg2; |
| 1529 | error = 0; | 1543 | error = 0; |
| 1530 | break; | 1544 | break; |
| 1545 | case PR_MCE_KILL: | ||
| 1546 | if (arg4 | arg5) | ||
| 1547 | return -EINVAL; | ||
| 1548 | switch (arg2) { | ||
| 1549 | case 0: | ||
| 1550 | if (arg3 != 0) | ||
| 1551 | return -EINVAL; | ||
| 1552 | current->flags &= ~PF_MCE_PROCESS; | ||
| 1553 | break; | ||
| 1554 | case 1: | ||
| 1555 | current->flags |= PF_MCE_PROCESS; | ||
| 1556 | if (arg3 != 0) | ||
| 1557 | current->flags |= PF_MCE_EARLY; | ||
| 1558 | else | ||
| 1559 | current->flags &= ~PF_MCE_EARLY; | ||
| 1560 | break; | ||
| 1561 | default: | ||
| 1562 | return -EINVAL; | ||
| 1563 | } | ||
| 1564 | error = 0; | ||
| 1565 | break; | ||
| 1566 | |||
| 1531 | default: | 1567 | default: |
| 1532 | error = -EINVAL; | 1568 | error = -EINVAL; |
| 1533 | break; | 1569 | break; |
