[RFC 06/18] limits: present RLIMIT_CPU and RLIMIT_RTTIMER current status
From: Topi Miettinen
Date: Mon Jun 13 2016 - 15:46:28 EST
Present current cputimer status in /proc/self/limits.
Signed-off-by: Topi Miettinen <toiwoton@xxxxxxxxx>
---
fs/proc/base.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 227997b..1df4fc8 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -650,8 +650,30 @@ static int proc_pid_limits(struct seq_file *m, struct pid_namespace *ns,
seq_printf(m, "%-10s", lnames[i].unit);
else
seq_printf(m, "%-10s", "");
- seq_printf(m, "%-20lu\n",
- task->signal->rlim_curmax[i]);
+
+ switch (i) {
+ case RLIMIT_RTTIME:
+ case RLIMIT_CPU:
+ if (rlim[i].rlim_max == RLIM_INFINITY)
+ seq_printf(m, "%-20s\n", "-");
+ else {
+ unsigned long long utime, ptime;
+ unsigned long psecs;
+ struct task_cputime cputime;
+
+ thread_group_cputimer(task, &cputime);
+ utime = cputime_to_expires(cputime.utime);
+ ptime = utime + cputime_to_expires(cputime.stime);
+ psecs = cputime_to_secs(ptime);
+ if (i == RLIMIT_RTTIME)
+ psecs *= USEC_PER_SEC;
+ seq_printf(m, "%-20lu\n", psecs);
+ }
+ break;
+ default:
+ seq_printf(m, "%-20lu\n",
+ task->signal->rlim_curmax[i]);
+ }
}
return 0;
--
2.8.1