mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Clifford Wolf <clifford@clifford.at>
To: serge@hallyn.com
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rlim in proc/<pid>/status (2nd rev.)
Date: Wed, 16 Jan 2008 08:03:46 +0100	[thread overview]
Message-ID: <20080116070346.GA24106@clifford.at> (raw)
In-Reply-To: <20080115203659.GA5404@vino.hallyn.com>

Hi,

On Tue, Jan 15, 2008 at 02:36:59PM -0600, serge@hallyn.com wrote:
> > +	rcu_read_lock();
> > +	if (lock_task_sighand(p, &flags)) {
> > +		for (i=0; i<RLIM_NLIMITS; i++)
> > +			rlim[i] = p->signal->rlim[i];
> 
> I'm confused - where do you unlock_task_sighand()?

oh fsck! thanks for that pointer..

Here is a new version of the patch which solves this issue and the issues
adressed earlier in this thread by kosaki.

yours,
 - clifford

Signed-off-by: Clifford Wolf <clifford@clifford.at>

--- linux/fs/proc/array.c	(revision 750)
+++ linux/fs/proc/array.c	(revision 764)
@@ -239,6 +239,58 @@
 	}
 }
 
+static char *rlim_names[RLIM_NLIMITS] = {
+	[RLIMIT_CPU]        = "CPU",
+	[RLIMIT_FSIZE]      = "FSize",
+	[RLIMIT_DATA]       = "Data",
+	[RLIMIT_STACK]      = "Stack",
+	[RLIMIT_CORE]       = "Core",
+	[RLIMIT_RSS]        = "RSS",
+	[RLIMIT_NPROC]      = "NProc",
+	[RLIMIT_NOFILE]     = "NoFile",
+	[RLIMIT_MEMLOCK]    = "MemLock",
+	[RLIMIT_AS]         = "AddrSpace",
+	[RLIMIT_LOCKS]      = "Locks",
+	[RLIMIT_SIGPENDING] = "SigPending",
+	[RLIMIT_MSGQUEUE]   = "MsgQueue",
+	[RLIMIT_NICE]       = "Nice",
+	[RLIMIT_RTPRIO]     = "RTPrio"
+};
+
+#if RLIM_NLIMITS != 15
+#  error Value of RLIM_NLIMITS changed. \
+         Please update rlim_names in fs/proc/array.c
+#endif
+
+static inline char *task_rlim(struct task_struct *p, char *buffer)
+{
+	unsigned long flags;
+	struct rlimit rlim[RLIM_NLIMITS];
+	int i;
+	
+	rcu_read_lock();
+	if (lock_task_sighand(p, &flags)) {
+		for (i=0; i<RLIM_NLIMITS; i++)
+			rlim[i] = p->signal->rlim[i];
+		unlock_task_sighand(p, &flags);
+	}
+	rcu_read_unlock();
+
+	for (i=0; i<RLIM_NLIMITS; i++) {
+		buffer += sprintf(buffer, "Rlim%s:\t", rlim_names[i]);
+		if (rlim[i].rlim_cur != RLIM_INFINITY)
+			buffer += sprintf(buffer, "%lu\t", rlim[i].rlim_cur);
+		else
+			buffer += sprintf(buffer, "inf\t");
+		if (rlim[i].rlim_max != RLIM_INFINITY)
+			buffer += sprintf(buffer, "%lu\n", rlim[i].rlim_max);
+		else
+			buffer += sprintf(buffer, "inf\n");
+	}
+
+	return buffer;
+}
+
 static inline char *task_sig(struct task_struct *p, char *buffer)
 {
 	unsigned long flags;
@@ -310,6 +362,7 @@
 		buffer = task_mem(mm, buffer);
 		mmput(mm);
 	}
+	buffer = task_rlim(task, buffer);
 	buffer = task_sig(task, buffer);
 	buffer = task_cap(task, buffer);
 	buffer = cpuset_task_status_allowed(task, buffer);

-- 
perl -le '$_=1;(1x$_)!~/^(11+)\1+$/&&print${_}while$_++<1000'|fmt

  reply	other threads:[~2008-01-16  7:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-15 10:06 [PATCH] rlim in proc/<pid>/status Clifford Wolf
2008-01-15 10:47 ` KOSAKI Motohiro
2008-01-15 12:15   ` Clifford Wolf
2008-01-15 20:36 ` [PATCH] " serge
2008-01-16  7:03   ` Clifford Wolf [this message]
2008-01-16  7:33     ` [PATCH] rlim in proc/<pid>/status (2nd rev.) KOSAKI Motohiro
2008-01-16 10:04       ` Clifford Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080116070346.GA24106@clifford.at \
    --to=clifford@clifford.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serge@hallyn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®