lkml.org 
[lkml]   [2001]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Subject[PATCH] processes with shared vm
From
Date
I figured out that it's difficult to find out from /proc
which processes that share VM (created with clone(CLONE_VM)).

made a patch that adds in /proc/<pid>/status a VmClones field that tells
how many proc that uses the same VM (mm_struct). if there are clones I
add another field VmFirstClone with the pid of clone with the lowest
pid.

Needed for things like gtop that adds mem usage of groups of proc, or
else they add up the usage of SIZE and RSS of threads.

The patch need to be applied to linux/fs/proc/array.c

NB: developed on 2.4.3

TJ

--
_________________________________________________________________________

Terje Eggestad terje.eggestad@scali.no
Scali Scalable Linux Systems http://www.scali.com

Olaf Helsets Vei 6 tel: +47 22 62 89 61 (OFFICE)
P.O.Box 70 Bogerud +47 975 31 574 (MOBILE)
N-0621 Oslo fax: +47 22 62 89 51
NORWAY
_________________________________________________________________________
*** array.c Thu Aug 16 16:33:56 2001
--- array.c.orig Mon Mar 19 21:34:55 2001
***************
*** 50,61 ****
* Al Viro & Jeff Garzik : moved most of the thing into base.c and
* : proc_misc.c. The rest may eventually go into
* : base.c too.
- *
- * Terje Eggestad : added in /proc/<pid>/status a VmClones: n
- * : that tells how many proc that uses the same VM (mm_struct).
- * : if there are clones add another field VmFirstClone with the
- * : clone with the lowest pid. Needed for things like gtop that adds
- * : mem usage of groups of proc, or else they add up the usage of threads.
*/

#include <linux/config.h>
--- 50,55 ----
***************
*** 184,190 ****
static inline char * task_mem(struct mm_struct *mm, char *buffer)
{
struct vm_area_struct * vma;
! unsigned long data = 0, stack = 0;
unsigned long exec = 0, lib = 0;

down_read(&mm->mmap_sem);
--- 178,184 ----
static inline char * task_mem(struct mm_struct *mm, char *buffer)
{
struct vm_area_struct * vma;
! unsigned long data = 0, stack = 0;
unsigned long exec = 0, lib = 0;

down_read(&mm->mmap_sem);
***************
*** 212,235 ****
"VmData:\t%8lu kB\n"
"VmStk:\t%8lu kB\n"
"VmExe:\t%8lu kB\n"
! "VmLib:\t%8lu kB\n"
! "VmClones:\t%d\n",
mm->total_vm << (PAGE_SHIFT-10),
mm->locked_vm << (PAGE_SHIFT-10),
mm->rss << (PAGE_SHIFT-10),
data - stack, stack,
! exec - lib, lib,
! mm->mm_users.counter-2);
! /* if we've vm clones, find the lowest/first pid of the clones */
! if (mm->mm_users.counter > 2) {
! struct task_struct *p;
! read_lock(&tasklist_lock);
! for_each_task(p) {
! if (p->mm == mm) break;
! };
! buffer += sprintf(buffer, "VmFirstClone:\t%d\n", p->pid);
! read_unlock(&tasklist_lock);
! };
up_read(&mm->mmap_sem);
return buffer;
}
--- 206,217 ----
"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;
}
\
 
 \ /
  Last update: 2005-03-22 13:17    [W:0.062 / U:1.840 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site