mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: edjard@ufam.edu.br
To: gene.heskett@verizon.net
Cc: edjard@ufam.edu.br, linux-kernel@vger.kernel.org, torvalds@osdl.org
Subject: Re: [PATCH] detailed physical memory info in fs/proc/task_mmu.c     [2.6.0-test9]
Date: Sat, 22 Nov 2003 10:45:02 -0200 (BRST)	[thread overview]
Message-ID: <37029.200.212.156.130.1069505102.squirrel@webmail.ufam.edu.br> (raw)
In-Reply-To: <200311220151.51069.gene.heskett@verizon.net>

[-- Attachment #1: Type: text/plain, Size: 874 bytes --]

I think it is this webamail editor. He it goes as attached, sorry about
that :-(. If it doesn't work I'll send it from a decent terminal.

BR,

Edjard

>>Hi,
>>
>>The piece of code below gives a richer information
>>at /proc/PID/status for a process PID.
>>
>>BR,
>>
>>Edjard
>
> Your editors line wrapping function ate the patch.
>
> --
> Cheers, Gene
> AMD K6-III@500mhz 320M
> Athlon1600XP@1400mhz  512M
> 99.27% setiathome rank, not too shabby for a WV hillbilly
> Yahoo.com attornies please note, additions to this message
> by Gene Heskett are:
> Copyright 2003 by Maurice Eugene Heskett, all rights reserved.
>
> -
> 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/
>

[-- Attachment #2: 10LE-PhysicalMem.patch --]
[-- Type: application/octet-stream, Size: 4325 bytes --]

--- linux-2.6.0-test9/fs/proc/task_mmu.c	2003-10-25 14:43:00.000000000 -0400
+++ linux/fs/proc/task_mmu.c	2003-11-22 10:26:59.000000000 -0400
@@ -3,44 +3,105 @@
 #include <linux/seq_file.h>
 #include <asm/uaccess.h>
 
+/**
+* Allan Bezerra (ajsb@dcc.fua.br) &
+* Mauricio Lin  (mauriciolin@bol.com.br) &
+* Edjard Mota   (edjard@ufam.edu.br) :   include a process PID physical memory size allocation
+*                                        info in the /proc/PID/status
+*/
+void phys_size_10LE(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;
+    }
+  }
+}
+
+/*
+void shared_size_10LE(struct vm_area_struct *vma, unsigned long len, unsigned long *shared) {
+   if (is_vm_hugetlb_page(vma)) {
+      if (!(vma->vm_flags & VM_DONTCOPY))
+	*shared += len;
+    }
+    
+    if (vma->vm_flags & VM_SHARED || !list_empty(&vma->shared))
+      *shared += len;
+} 
+*/
+
 char *task_mem(struct mm_struct *mm, char *buffer)
 {
-	unsigned long data = 0, stack = 0, exec = 0, lib = 0;
-	struct vm_area_struct *vma;
-
-	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)
-				stack += len;
-			continue;
-		}
-		if (vma->vm_flags & VM_WRITE)
-			continue;
-		if (vma->vm_flags & VM_EXEC) {
-			exec += len;
-			if (vma->vm_flags & VM_EXECUTABLE)
-				continue;
-			lib += len;
-		}
-	}
-	buffer += sprintf(buffer,
-		"VmSize:\t%8lu kB\n"
-		"VmLck:\t%8lu kB\n"
-		"VmRSS:\t%8lu kB\n"
-		"VmData:\t%8lu kB\n"
-		"VmStk:\t%8lu kB\n"
-		"VmExe:\t%8lu kB\n"
-		"VmLib:\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);
-	up_read(&mm->mmap_sem);
-	return buffer;
+  unsigned long data = 0, stack = 0, exec = 0, lib = 0;
+  unsigned long phys_data = 0, phys_stack = 0, phys_exec = 0, phys_lib = 0;
+  unsigned long phys_brk = 0, my_rss=0;
+  struct vm_area_struct *vma;
+  down_read(&mm->mmap_sem);
+  for (vma = mm->mmap; vma; vma = vma->vm_next) {
+    unsigned long len = (vma->vm_end - vma->vm_start) >> 10;
+    phys_size_10LE(mm, vma->vm_start, vma->vm_end, &my_rss);
+    if (!vma->vm_file) {
+      phys_size_10LE(mm, vma->vm_start, vma->vm_end, &phys_data);
+      if (vma->vm_flags & VM_GROWSDOWN) {
+	stack += len;
+	phys_size_10LE(mm, vma->vm_start, vma->vm_end, &phys_stack);
+      }
+      else {
+	data += len;
+      }
+      continue;
+    }
+
+    if (vma->vm_flags & VM_WRITE)
+      continue;
+
+    if (vma->vm_flags & VM_EXEC) {
+      exec += len;
+      phys_size_10LE(mm, vma->vm_start, vma->vm_end, &phys_exec);
+      if (vma->vm_flags & VM_EXECUTABLE) {
+	continue;
+      }
+      lib += len;
+      phys_size_10LE(mm, vma->vm_start, vma->vm_end, &phys_lib);
+    }
+  }
+  phys_size_10LE(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"
+		    "PhysicalData:\t%8lu kB\n"
+		    "VmStk:\t%8lu kB\n"
+		    "PhysicalStk:\t%8lu kB\n"
+		    "VmExe:\t%8lu kB\n"
+		    "PhysicalExe:\t%8lu kB\n"
+		    "VmLib:\t%8lu kB\n"
+		    "PhysicalLib:\t%8lu kB\n"
+		    "VmHeap: \t%8lu KB\n"
+		    "PhysicalHeap: \t%8lu KB\n"
+		    "MyRSS: \t%8lu KB\n",		   
+		    mm->total_vm << (PAGE_SHIFT-10),
+		    mm->locked_vm << (PAGE_SHIFT-10),
+		    mm->rss << (PAGE_SHIFT-10),
+		    data, (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, my_rss >> 10
+		    );
+  up_read(&mm->mmap_sem);
+  return buffer;
 }
 
 unsigned long task_vsize(struct mm_struct *mm)

  reply	other threads:[~2003-11-22 14:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-22  2:15 edjard
2003-11-22  6:51 ` Gene Heskett
2003-11-22 12:45   ` edjard [this message]
2003-11-22 13:52   ` Edjard de Souza Mota

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=37029.200.212.156.130.1069505102.squirrel@webmail.ufam.edu.br \
    --to=edjard@ufam.edu.br \
    --cc=gene.heskett@verizon.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@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

all inboxes | Powered by JetHome®