mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: uclinux-dev@uclinux.org, David Howells <dhowells@redhat.com>,
	David McCullough <davidm@snapgear.com>,
	Greg Ungerer <gerg@uclinux.org>, Paul Mundt <lethal@linux-sh.org>
Cc: uclinux-dist-devel@blackfin.uclinux.org, linux-kernel@vger.kernel.org
Subject: [PATCH] NOMMU: add [stack] label to per-process maps output
Date: Tue, 15 Dec 2009 18:55:50 -0500	[thread overview]
Message-ID: <1260921350-6539-1-git-send-email-vapier@gentoo.org> (raw)

Add support to the NOMMU per-process proc maps file to show which mapping
is the stack.  This is largely based on the MMU code.

root:/> cat /proc/self/maps
02064000-02067ccc rw-p 0004d000 00:01 22         /bin/busybox
0206e000-0206f35c rw-p 00006000 00:01 295        /lib/ld-uClibc.so.0
025f0000-025f6f0c r-xs 00000000 00:01 295        /lib/ld-uClibc.so.0
02680000-026ba6b0 r-xs 00000000 00:01 297        /lib/libc.so.0
02700000-0274d384 r-xs 00000000 00:01 22         /bin/busybox
02816000-02817000 rw-p 00000000 00:00 0
02848000-0284c0d8 rw-p 00000000 00:00 0
02860000-02880000 rw-p 00000000 00:00 0          [stack]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
it'd be cool if the global /proc/maps could display something like
[stack/<pid>], but i can't quite divine how to get a mm_struct out
of a vm_region without having to walk the entire process list.

 fs/proc/task_nommu.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 5d9fd64..283b5c0 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -121,11 +121,20 @@ int task_statm(struct mm_struct *mm, int *shared, int *text,
 	return size;
 }
 
+static void pad_len_spaces(struct seq_file *m, int len)
+{
+	len = 25 + sizeof(void*) * 6 - len;
+	if (len < 1)
+		len = 1;
+	seq_printf(m, "%*c", len, ' ');
+}
+
 /*
  * display a single VMA to a sequenced file
  */
 static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma)
 {
+	struct mm_struct *mm = vma->vm_mm;
 	unsigned long ino = 0;
 	struct file *file;
 	dev_t dev = 0;
@@ -154,11 +163,14 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma)
 		   MAJOR(dev), MINOR(dev), ino, &len);
 
 	if (file) {
-		len = 25 + sizeof(void *) * 6 - len;
-		if (len < 1)
-			len = 1;
-		seq_printf(m, "%*c", len, ' ');
+		pad_len_spaces(m, len);
 		seq_path(m, &file->f_path, "");
+	} else if (mm) {
+		if (vma->vm_start <= mm->start_brk &&
+				vma->vm_end >= mm->brk) {
+			pad_len_spaces(m, len);
+			seq_puts(m, "[stack]");
+		}
 	}
 
 	seq_putc(m, '\n');
-- 
1.6.5.5


             reply	other threads:[~2009-12-15 23:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-15 23:55 Mike Frysinger [this message]
2009-12-16  8:54 ` David Howells
2009-12-16 16:59 ` David Howells
2009-12-16 19:36   ` [uClinux-dev] " Mike Frysinger
2009-12-17 22:49   ` Mike Frysinger
2009-12-17 23:27   ` David Howells
2009-12-21 14:35   ` [PATCH v2] " Mike Frysinger
2009-12-22 15:58   ` David Howells
2010-05-24  5:35     ` Mike Frysinger

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=1260921350-6539-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=davidm@snapgear.com \
    --cc=dhowells@redhat.com \
    --cc=gerg@uclinux.org \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=uclinux-dev@uclinux.org \
    --cc=uclinux-dist-devel@blackfin.uclinux.org \
    /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®