[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20120301151714.72434a0a.akpm@linux-foundation.org>
Date: Thu, 1 Mar 2012 15:17:14 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Siddhesh Poyarekar <siddhesh.poyarekar@...il.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@...il.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
Jamie Lokier <jamie@...reable.org>,
Mike Frysinger <vapier@...too.org>,
Alexey Dobriyan <adobriyan@...il.com>,
Matt Mackall <mpm@...enic.com>, linux-kernel@...r.kernel.org,
Oleg Nesterov <oleg@...hat.com>
Subject: Re: [PATCH 2/2] procfs: Mark stack vma with pid of the owning task
On Thu, 1 Mar 2012 10:50:59 +0530
Siddhesh Poyarekar <siddhesh.poyarekar@...il.com> wrote:
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -262,8 +262,14 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
> if (vma->vm_start <= mm->brk &&
> vma->vm_end >= mm->start_brk) {
> name = "[heap]";
> - } else if (vm_is_stack(task, vma, is_pid)) {
> - name = "[stack]";
> + } else {
> + pid_t tid =
> + vm_is_stack(task, vma, is_pid);
> + if (tid != 0) {
> + pad_len_spaces(m, len);
> + seq_printf(m, "[stack:%d]",
> + tid);
> + }
Well, the 80-column police police will get you there, and it is pretty silly-looking.
We can avoid the first line break by doing
pid_t tid;
tid = vm_is_stack(task, vma, is_pid);
nice and easy!
And we can avoid the other by saving a whole tabstop:
--- a/fs/proc/task_mmu.c~procfs-mark-stack-vma-with-pid-of-the-owning-task-fix
+++ a/fs/proc/task_mmu.c
@@ -222,6 +222,7 @@ show_map_vma(struct seq_file *m, struct
unsigned long start, end;
dev_t dev = 0;
int len;
+ const char *name;
if (file) {
struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
@@ -255,31 +256,33 @@ show_map_vma(struct seq_file *m, struct
if (file) {
pad_len_spaces(m, len);
seq_path(m, &file->f_path, "\n");
- } else {
- const char *name = arch_vma_name(vma);
- if (!name) {
- if (mm) {
- if (vma->vm_start <= mm->brk &&
- vma->vm_end >= mm->start_brk) {
- name = "[heap]";
- } else {
- pid_t tid =
- vm_is_stack(task, vma, is_pid);
- if (tid != 0) {
- pad_len_spaces(m, len);
- seq_printf(m, "[stack:%d]",
- tid);
- }
- }
+ goto out;
+ }
+
+ name = arch_vma_name(vma);
+ if (!name) {
+ if (mm) {
+ if (vma->vm_start <= mm->brk &&
+ vma->vm_end >= mm->start_brk) {
+ name = "[heap]";
} else {
- name = "[vdso]";
+ pid_t tid;
+
+ tid = vm_is_stack(task, vma, is_pid);
+ if (tid != 0) {
+ pad_len_spaces(m, len);
+ seq_printf(m, "[stack:%d]", tid);
+ }
}
- }
- if (name) {
- pad_len_spaces(m, len);
- seq_puts(m, name);
+ } else {
+ name = "[vdso]";
}
}
+ if (name) {
+ pad_len_spaces(m, len);
+ seq_puts(m, name);
+ }
+out:
seq_putc(m, '\n');
}
Which is not the prettiest thing in the world, but it gets the job done.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists