Re: [RFC 06/18] limits: present RLIMIT_CPU and RLIMIT_RTTIMER current status

From: Alexey Dobriyan
Date: Tue Jun 14 2016 - 05:15:01 EST


On Mon, Jun 13, 2016 at 10:44 PM, Topi Miettinen <toiwoton@xxxxxxxxx> wrote:
> Present current cputimer status in /proc/self/limits.

> --- 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,
> + 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;

Let's keep rlimits file for rlimits.