From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423765AbcFMTqY (ORCPT ); Mon, 13 Jun 2016 15:46:24 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34792 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423235AbcFMTqV (ORCPT ); Mon, 13 Jun 2016 15:46:21 -0400 From: Topi Miettinen To: linux-kernel@vger.kernel.org Cc: Topi Miettinen , Andrew Morton , Kees Cook , Al Viro , Alexey Dobriyan , John Stultz , Janis Danisevskis , Calvin Owens , Jann Horn Subject: [RFC 06/18] limits: present RLIMIT_CPU and RLIMIT_RTTIMER current status Date: Mon, 13 Jun 2016 22:44:13 +0300 Message-Id: <1465847065-3577-7-git-send-email-toiwoton@gmail.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1465847065-3577-1-git-send-email-toiwoton@gmail.com> References: <1465847065-3577-1-git-send-email-toiwoton@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Present current cputimer status in /proc/self/limits. Signed-off-by: Topi Miettinen --- 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