From: edjard@ufam.edu.br
To: linux-kernel@vger.kernel.org
Cc: torvads@osdl.org
Subject: [Fwd: Re:Re: [PATCH 2.6.0-test11] Resident memory info in fs/proc/task_mmu.c]
Date: Tue, 2 Dec 2003 17:15:24 -0200 (BRST) [thread overview]
Message-ID: <56090.200.212.156.130.1070392524.squirrel@webmail.ufam.edu.br> (raw)
[-- Attachment #1: Type: text/plain, Size: 3173 bytes --]
Hi,
Thanks to Christian who helped us pointing some text mistyping.
We attached the file just in case.
>
> Why are you breaking the Coding style? Can you keep the standard
indentation
> please? This will make your patch much smaller and easier to see what
you actually changed.
>
> cheers
>
> Christian
>
We would appreciate any comments.
BR,
Edjard
--- linux-2.6.0-test11/fs/proc/task_mmu.c 2003-11-26 18:43:07.000000000 -0200
+++ linux/fs/proc/task_mmu.c 2003-12-02 13:58:10.000000000 -0200
@@ -3,42 +3,83 @@
#include <linux/seq_file.h>
#include <asm/uaccess.h>
+/**
+* Allan Bezerra (ajsb@dcc.fua.br) &
+* Bruna Moreira (brunampm@bol.com.br) &
+* Edjard Mota (edjard@ufam.edu.br) &
+* Mauricio Lin (mauriciolin@bol.com.br) &
+* Include a process PID physical memory size info in the /proc/PID/status
+*/
+
+void resident_mem_size(struct mm_struct *mm, unsigned long start_address,
unsigned long end_address, unsigned long *size)
+{
+ pgd_t *my_pgd;
+ pmd_t *my_pmd;
+ pte_t *my_pte;
+ unsigned long page;
+
+ for (page = start_address; page < end_address; page += PAGE_SIZE) {
+ my_pgd = pgd_offset(mm, page);
+ if (pgd_none(*my_pgd) || pgd_bad(*my_pgd)) continue;
+ my_pmd = pmd_offset(my_pgd, page);
+ if (pmd_none(*my_pmd) || pmd_bad(*my_pmd)) continue;
+ my_pte = pte_offset_map(my_pmd, page);
+ if (pte_present(*my_pte))
+ *size += PAGE_SIZE;
+ }
+}
+
char *task_mem(struct mm_struct *mm, char *buffer)
{
unsigned long data = 0, stack = 0, exec = 0, lib = 0;
struct vm_area_struct *vma;
-
+ unsigned long phys_data = 0, phys_stack = 0, phys_exec = 0, phys_lib =
0, phys_brk = 0;
down_read(&mm->mmap_sem);
for (vma = mm->mmap; vma; vma = vma->vm_next) {
unsigned long len = (vma->vm_end - vma->vm_start) >> 10;
if (!vma->vm_file) {
data += len;
- if (vma->vm_flags & VM_GROWSDOWN)
+ resident_mem_size(mm, vma->vm_start, vma->vm_end, &phys_data);
+ if (vma->vm_flags & VM_GROWSDOWN){
stack += len;
+ resident_mem_size(mm, vma->vm_start, vma->vm_end, &phys_stack);
+ }
continue;
}
if (vma->vm_flags & VM_WRITE)
continue;
if (vma->vm_flags & VM_EXEC) {
exec += len;
+ resident_mem_size(mm, vma->vm_start, vma->vm_end, &phys_exec);
if (vma->vm_flags & VM_EXECUTABLE)
continue;
lib += len;
+ resident_mem_size(mm, vma->vm_start, vma->vm_end, &phys_lib);
}
}
+ resident_mem_size(mm, mm->start_brk, mm->brk, &phys_brk);
buffer += sprintf(buffer,
"VmSize:\t%8lu kB\n"
"VmLck:\t%8lu kB\n"
"VmRSS:\t%8lu kB\n"
"VmData:\t%8lu kB\n"
+ "RssData:\t%8lu kB\n"
"VmStk:\t%8lu kB\n"
+ "RssStk:\t%8lu kB\n"
"VmExe:\t%8lu kB\n"
- "VmLib:\t%8lu kB\n",
+ "RssExe:\t%8lu kB\n"
+ "VmLib:\t%8lu kB\n"
+ "RssLib:\t%8lu kB\n"
+ "VmHeap:\t%8lu KB\n"
+ "RssHeap:\t%8lu KB\n",
mm->total_vm << (PAGE_SHIFT-10),
mm->locked_vm << (PAGE_SHIFT-10),
mm->rss << (PAGE_SHIFT-10),
- data - stack, stack,
- exec - lib, lib);
+ data - stack, (phys_data - phys_stack) >> 10,
+ stack, phys_stack >> 10,
+ exec - lib, (phys_exec - phys_lib) >> 10,
+ lib, phys_lib >> 10,
+ (mm->brk - mm->start_brk) >> 10, phys_brk >> 10);
up_read(&mm->mmap_sem);
return buffer;
}
[-- Attachment #2: physical_mem_status.patch --]
[-- Type: application/octet-stream, Size: 2822 bytes --]
--- linux-2.6.0-test11/fs/proc/task_mmu.c 2003-11-26 18:43:07.000000000 -0200
+++ linux/fs/proc/task_mmu.c 2003-12-02 13:58:10.000000000 -0200
@@ -3,42 +3,83 @@
#include <linux/seq_file.h>
#include <asm/uaccess.h>
+/**
+* Allan Bezerra (ajsb@dcc.fua.br) &
+* Bruna Moreira (brunampm@bol.com.br) &
+* Edjard Mota (edjard@ufam.edu.br) &
+* Mauricio Lin (mauriciolin@bol.com.br) &
+* Include a process PID physical memory size info in the /proc/PID/status
+*/
+
+void resident_mem_size(struct mm_struct *mm, unsigned long start_address, unsigned long end_address, unsigned long *size)
+{
+ pgd_t *my_pgd;
+ pmd_t *my_pmd;
+ pte_t *my_pte;
+ unsigned long page;
+
+ for (page = start_address; page < end_address; page += PAGE_SIZE) {
+ my_pgd = pgd_offset(mm, page);
+ if (pgd_none(*my_pgd) || pgd_bad(*my_pgd)) continue;
+ my_pmd = pmd_offset(my_pgd, page);
+ if (pmd_none(*my_pmd) || pmd_bad(*my_pmd)) continue;
+ my_pte = pte_offset_map(my_pmd, page);
+ if (pte_present(*my_pte))
+ *size += PAGE_SIZE;
+ }
+}
+
char *task_mem(struct mm_struct *mm, char *buffer)
{
unsigned long data = 0, stack = 0, exec = 0, lib = 0;
struct vm_area_struct *vma;
-
+ unsigned long phys_data = 0, phys_stack = 0, phys_exec = 0, phys_lib = 0, phys_brk = 0;
down_read(&mm->mmap_sem);
for (vma = mm->mmap; vma; vma = vma->vm_next) {
unsigned long len = (vma->vm_end - vma->vm_start) >> 10;
if (!vma->vm_file) {
data += len;
- if (vma->vm_flags & VM_GROWSDOWN)
+ resident_mem_size(mm, vma->vm_start, vma->vm_end, &phys_data);
+ if (vma->vm_flags & VM_GROWSDOWN){
stack += len;
+ resident_mem_size(mm, vma->vm_start, vma->vm_end, &phys_stack);
+ }
continue;
}
if (vma->vm_flags & VM_WRITE)
continue;
if (vma->vm_flags & VM_EXEC) {
exec += len;
+ resident_mem_size(mm, vma->vm_start, vma->vm_end, &phys_exec);
if (vma->vm_flags & VM_EXECUTABLE)
continue;
lib += len;
+ resident_mem_size(mm, vma->vm_start, vma->vm_end, &phys_lib);
}
}
+ resident_mem_size(mm, mm->start_brk, mm->brk, &phys_brk);
buffer += sprintf(buffer,
"VmSize:\t%8lu kB\n"
"VmLck:\t%8lu kB\n"
"VmRSS:\t%8lu kB\n"
"VmData:\t%8lu kB\n"
+ "RssData:\t%8lu kB\n"
"VmStk:\t%8lu kB\n"
+ "RssStk:\t%8lu kB\n"
"VmExe:\t%8lu kB\n"
- "VmLib:\t%8lu kB\n",
+ "RssExe:\t%8lu kB\n"
+ "VmLib:\t%8lu kB\n"
+ "RssLib:\t%8lu kB\n"
+ "VmHeap:\t%8lu KB\n"
+ "RssHeap:\t%8lu KB\n",
mm->total_vm << (PAGE_SHIFT-10),
mm->locked_vm << (PAGE_SHIFT-10),
mm->rss << (PAGE_SHIFT-10),
- data - stack, stack,
- exec - lib, lib);
+ data - stack, (phys_data - phys_stack) >> 10,
+ stack, phys_stack >> 10,
+ exec - lib, (phys_exec - phys_lib) >> 10,
+ lib, phys_lib >> 10,
+ (mm->brk - mm->start_brk) >> 10, phys_brk >> 10);
up_read(&mm->mmap_sem);
return buffer;
}
reply other threads:[~2003-12-02 20:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=56090.200.212.156.130.1070392524.squirrel@webmail.ufam.edu.br \
--to=edjard@ufam.edu.br \
--cc=linux-kernel@vger.kernel.org \
--cc=torvads@osdl.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;
as well as URLs for NNTP newsgroup(s).