public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] procfs: Use proper units for noMMU statm
@ 2009-11-14  1:52 steve
  2009-11-14  4:41 ` Américo Wang
  0 siblings, 1 reply; 4+ messages in thread
From: steve @ 2009-11-14  1:52 UTC (permalink / raw)
  To: linux-kernel; +Cc: Steven J. Magnani

On no-MMU systems, sizes reported in /proc/n/statm have units of bytes. 
Per Documentation/filesystems/proc.txt, these values should be in pages.

Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
---
diff -uprN a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
--- a/fs/proc/task_nommu.c	2009-11-13 16:48:14.000000000 -0600
+++ b/fs/proc/task_nommu.c	2009-11-13 16:51:09.000000000 -0600
@@ -110,8 +110,11 @@ int task_statm(struct mm_struct *mm, int
 		}
 	}
 
-	size += (*text = mm->end_code - mm->start_code);
-	size += (*data = mm->start_stack - mm->start_data);
+	size >>= PAGE_SHIFT;
+	*text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK))
+		>> PAGE_SHIFT;
+	*data = (mm->start_stack - mm->start_data) >> PAGE_SHIFT;
+	size += *text + *data;
 	up_read(&mm->mmap_sem);
 	*resident = size;
 	return size;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] procfs: Use proper units for noMMU statm
  2009-11-14  1:52 [PATCH] procfs: Use proper units for noMMU statm steve
@ 2009-11-14  4:41 ` Américo Wang
  2009-11-16 14:47   ` Steven J. Magnani
  0 siblings, 1 reply; 4+ messages in thread
From: Américo Wang @ 2009-11-14  4:41 UTC (permalink / raw)
  To: steve; +Cc: linux-kernel

On Fri, Nov 13, 2009 at 07:52:14PM -0600, steve@digidescorp.com wrote:
>On no-MMU systems, sizes reported in /proc/n/statm have units of bytes. 
>Per Documentation/filesystems/proc.txt, these values should be in pages.
>
>Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
>---
>diff -uprN a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
>--- a/fs/proc/task_nommu.c	2009-11-13 16:48:14.000000000 -0600
>+++ b/fs/proc/task_nommu.c	2009-11-13 16:51:09.000000000 -0600
>@@ -110,8 +110,11 @@ int task_statm(struct mm_struct *mm, int
> 		}
> 	}
> 
>-	size += (*text = mm->end_code - mm->start_code);
>-	size += (*data = mm->start_stack - mm->start_data);
>+	size >>= PAGE_SHIFT;
>+	*text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK))
>+		>> PAGE_SHIFT;
>+	*data = (mm->start_stack - mm->start_data) >> PAGE_SHIFT;

Are '->start_stack' and '->start_data' already page aligned on NOMMU arch?

If yes, this patch looks good.


>+	size += *text + *data;
> 	up_read(&mm->mmap_sem);
> 	*resident = size;
> 	return size;
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/

-- 
Live like a child, think like the god.
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] procfs: Use proper units for noMMU statm
  2009-11-14  4:41 ` Américo Wang
@ 2009-11-16 14:47   ` Steven J. Magnani
  2009-11-16 14:50     ` [PATCH v2] " steve
  0 siblings, 1 reply; 4+ messages in thread
From: Steven J. Magnani @ 2009-11-16 14:47 UTC (permalink / raw)
  To: Américo Wang; +Cc: linux-kernel

On Sat, 2009-11-14 at 12:41 +0800, Américo Wang wrote:
> On Fri, Nov 13, 2009 at 07:52:14PM -0600, steve@digidescorp.com wrote:
> >On no-MMU systems, sizes reported in /proc/n/statm have units of bytes. 
> >Per Documentation/filesystems/proc.txt, these values should be in pages.
> >
> > ...
> >
> >+	*data = (mm->start_stack - mm->start_data) >> PAGE_SHIFT;
> 
> Are '->start_stack' and '->start_data' already page aligned on NOMMU arch?
> 

In looking over binfmt_flat.c (main executable type for noMMU systems),
I don't think there's a guarantee of more than 32- or 64-bit alignment.
Thanks for the suggestion, I'll submit an updated patch.

------------------------------------------------------------------------
 Steven J. Magnani               "I claim this network for MARS!
 www.digidescorp.com              Earthling, return my space modulator!"

 #include <standard.disclaimer>




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] procfs: Use proper units for noMMU statm
  2009-11-16 14:47   ` Steven J. Magnani
@ 2009-11-16 14:50     ` steve
  0 siblings, 0 replies; 4+ messages in thread
From: steve @ 2009-11-16 14:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: xiyou.wangcong, Steven J. Magnani

Reworked to guarantee page alignment of terms used in data size calculation
and to reduce time spent with mmap_sem held.

On no-MMU systems, sizes reported in /proc/n/statm have units of bytes. 
Per Documentation/filesystems/proc.txt, these values should be in pages.

Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
---

diff -uprN a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
--- a/fs/proc/task_nommu.c	2009-11-13 16:48:14.000000000 -0600
+++ b/fs/proc/task_nommu.c	2009-11-14 12:17:00.000000000 -0600
@@ -110,9 +110,13 @@ int task_statm(struct mm_struct *mm, int
 		}
 	}
 
-	size += (*text = mm->end_code - mm->start_code);
-	size += (*data = mm->start_stack - mm->start_data);
+	*text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK))
+		>> PAGE_SHIFT;
+	*data = (PAGE_ALIGN(mm->start_stack) - (mm->start_data & PAGE_MASK))
+		>> PAGE_SHIFT;
 	up_read(&mm->mmap_sem);
+	size >>= PAGE_SHIFT;
+	size += *text + *data;
 	*resident = size;
 	return size;
 }


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-16 14:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-14  1:52 [PATCH] procfs: Use proper units for noMMU statm steve
2009-11-14  4:41 ` Américo Wang
2009-11-16 14:47   ` Steven J. Magnani
2009-11-16 14:50     ` [PATCH v2] " steve

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox