[PATCH] Add rlimits to /proc/<PID>/status

Previous thread: "BUG: unable to handle kernel paging request" on shutdown or killing NetworkManager in latest wireless-testing (with rt73usb wireless adapter) by Stefanik Gábor on Friday, May 30, 2008 - 1:36 pm. (2 messages)

Next thread: [git patches] libata fixes by Jeff Garzik on Friday, May 30, 2008 - 3:13 pm. (1 message)
From: Clifford Wolf
Date: Friday, May 30, 2008 - 1:11 pm

Signed-off-by: Clifford Wolf &lt;clifford@clifford.at&gt;
---
 fs/proc/array.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index 9e3b8c3..3cb2ad3 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -242,6 +242,62 @@ static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign,
 	}
 }
 
+static const char *rlim_names[RLIM_NLIMITS] = {
+	[RLIMIT_CPU]        = &quot;CPU&quot;,
+	[RLIMIT_FSIZE]      = &quot;FSize&quot;,
+	[RLIMIT_DATA]       = &quot;Data&quot;,
+	[RLIMIT_STACK]      = &quot;Stack&quot;,
+	[RLIMIT_CORE]       = &quot;Core&quot;,
+	[RLIMIT_RSS]        = &quot;RSS&quot;,
+	[RLIMIT_NPROC]      = &quot;NProc&quot;,
+	[RLIMIT_NOFILE]     = &quot;NoFile&quot;,
+	[RLIMIT_MEMLOCK]    = &quot;MemLock&quot;,
+	[RLIMIT_AS]         = &quot;AddrSpace&quot;,
+	[RLIMIT_LOCKS]      = &quot;Locks&quot;,
+	[RLIMIT_SIGPENDING] = &quot;SigPending&quot;,
+	[RLIMIT_MSGQUEUE]   = &quot;MsgQueue&quot;,
+	[RLIMIT_NICE]       = &quot;Nice&quot;,
+	[RLIMIT_RTPRIO]     = &quot;RTPrio&quot;,
+	[RLIMIT_RTTIME]     = &quot;RTTime&quot;
+};
+
+#if RLIM_NLIMITS != 16
+#  error Value of RLIM_NLIMITS changed. \
+         Please update rlim_names in fs/proc/array.c
+#endif
+
+static inline void task_rlim(struct seq_file *m, struct task_struct *p)
+{
+	unsigned long flags;
+	struct rlimit rlim[RLIM_NLIMITS];
+	int i;
+
+	for (i=0; i&lt;RLIM_NLIMITS; i++) {
+		rlim[i].rlim_cur = 0;
+		rlim[i].rlim_max = 0;
+	}
+
+	rcu_read_lock();
+	if (lock_task_sighand(p, &amp;flags)) {
+		for (i=0; i&lt;RLIM_NLIMITS; i++)
+			rlim[i] = p-&gt;signal-&gt;rlim[i];
+		unlock_task_sighand(p, &amp;flags);
+	}
+	rcu_read_unlock();
+
+	for (i=0; i&lt;RLIM_NLIMITS; i++) {
+		seq_printf(m, &quot;Rlim%s:\t&quot;, rlim_names[i]);
+		if (rlim[i].rlim_cur != RLIM_INFINITY)
+			seq_printf(m, &quot;%lu\t&quot;, rlim[i].rlim_cur);
+		else
+			seq_printf(m, &quot;inf\t&quot;);
+		if (rlim[i].rlim_max != RLIM_INFINITY)
+			seq_printf(m, &quot;%lu\n&quot;, rlim[i].rlim_max);
+		else
+			seq_printf(m, &quot;inf\n&quot;);
+	}
+}
+
 static inline void task_sig(struct seq_file *m, struct task_struct *p)
 {
 ...
From: Hugh Dickins
Date: Friday, May 30, 2008 - 2:35 pm

Aren't they better staying in /proc/&lt;PID&gt;/limits?

Hugh
--

From: Clifford Wolf
Date: Friday, May 30, 2008 - 3:50 pm

Hi,


this was a cleanup of a patch I've sent to lkml about 6 months ago
when there was no yet-released (non-rc) kernel with /proc/&lt;PID&gt;/limits ...

my patch is a more or less duplicate of commit d85f50d5. oops.
please simply ignore it..  ;-)

yours,
 - clifford

-- 
A byte walks into a bar and orders a pint. Bartender asks him &quot;What's wrong?&quot;
Byte says &quot;Parity error.&quot; Bartender nods and says &quot;Yeah, I thought you looked
a bit off.&quot;
--

From: Peter Zijlstra
Date: Friday, May 30, 2008 - 2:46 pm

fs/proc/base.c already has an array with strings in it

--

Previous thread: "BUG: unable to handle kernel paging request" on shutdown or killing NetworkManager in latest wireless-testing (with rt73usb wireless adapter) by Stefanik Gábor on Friday, May 30, 2008 - 1:36 pm. (2 messages)

Next thread: [git patches] libata fixes by Jeff Garzik on Friday, May 30, 2008 - 3:13 pm. (1 message)