mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: steve@digidescorp.com
To: linux-kernel@vger.kernel.org
Cc: xiyou.wangcong@gmail.com, "Steven J. Magnani" <steve@digidescorp.com>
Subject: [PATCH v2] procfs: Use proper units for noMMU statm
Date: Mon, 16 Nov 2009 08:50:53 -0600	[thread overview]
Message-ID: <1258383053-3425-1-git-send-email-steve@digidescorp.com> (raw)
In-Reply-To: <1258382853.3019.0.camel@iscandar.digidescorp.com>

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;
 }


      reply	other threads:[~2009-11-16 14:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-14  1:52 [PATCH] " steve
2009-11-14  4:41 ` Américo Wang
2009-11-16 14:47   ` Steven J. Magnani
2009-11-16 14:50     ` steve [this message]

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=1258383053-3425-1-git-send-email-steve@digidescorp.com \
    --to=steve@digidescorp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.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

Powered by JetHome