diff options
author | Martin Baulig <martin@home-of-linux.org> | 1998-08-12 20:16:24 +0000 |
---|---|---|
committer | Martin Baulig <martin@src.gnome.org> | 1998-08-12 20:16:24 +0000 |
commit | 9248d72018249f8a1388a4d760bbddfc0cb84219 (patch) | |
tree | 344642635ad1f221a7abf0dfb3c2a195e78e59f6 | |
parent | da622f70c7f6067b0f55ab098ebd24c8d8a8963e (diff) | |
download | libgtop-9248d72018249f8a1388a4d760bbddfc0cb84219.tar.gz |
Using `text_rss', `shlib_rss', `data_rss' and `dirty_size' instead of
1998-08-12 Martin Baulig <martin@home-of-linux.org>
* include/glibtop/procsegment.h (glibtop_proc_segment): Using
`text_rss', `shlib_rss', `data_rss' and `dirty_size' instead of
`tsr', `lrs', `drs' and `dt'. New field `stack_rss'.
* sysdeps/linux/procmem.c: Memory sizes now correctly in bytes.
* sysdeps/linux/procsegment.c: Dito.
* sysdeps/kernel/procsegment.c: Stack pages are reported via
`stack_rss' and no longer count towards `data_rss'
* kernel/table.h (table_proc_segment): Added `srs' field.
* kernel/table21/module.c (TBL_PROC_SEGMENT): Added kernel support
for this.
* sysdeps/{linux, kernel, stub}/procmap.c: New files.
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | examples/first.c | 87 | ||||
-rw-r--r-- | examples/procmap.c | 5 | ||||
-rw-r--r-- | examples/second.c | 27 | ||||
-rw-r--r-- | features.def | 2 | ||||
-rw-r--r-- | guile/reference.sgml | 28 | ||||
-rw-r--r-- | include/glibtop/proclist.h | 4 | ||||
-rw-r--r-- | include/glibtop/procsegment.h | 26 | ||||
-rw-r--r-- | kernel/table.h | 4 | ||||
-rw-r--r-- | kernel/table21/module.c | 31 | ||||
-rw-r--r-- | sysdeps/guile/names/guile-names.awk | 2 | ||||
-rw-r--r-- | sysdeps/kernel/Makefile.am | 2 | ||||
-rw-r--r-- | sysdeps/kernel/glibtop_server.h | 1 | ||||
-rw-r--r-- | sysdeps/kernel/kernel.s | 2 | ||||
-rw-r--r-- | sysdeps/kernel/prockernel.c | 4 | ||||
-rw-r--r-- | sysdeps/kernel/proclist.c | 3 | ||||
-rw-r--r-- | sysdeps/kernel/procmap.c | 47 | ||||
-rw-r--r-- | sysdeps/kernel/procsegment.c | 19 | ||||
-rw-r--r-- | sysdeps/linux/Makefile.am | 2 | ||||
-rw-r--r-- | sysdeps/linux/glibtop_server.h | 1 | ||||
-rw-r--r-- | sysdeps/linux/proclist.c | 3 | ||||
-rw-r--r-- | sysdeps/linux/procmap.c | 47 | ||||
-rw-r--r-- | sysdeps/linux/procmem.c | 26 | ||||
-rw-r--r-- | sysdeps/linux/procsegment.c | 38 | ||||
-rw-r--r-- | sysdeps/names/procsegment.c | 16 | ||||
-rw-r--r-- | sysdeps/stub/Makefile.am | 2 | ||||
-rw-r--r-- | sysdeps/stub/procmap.c | 47 |
27 files changed, 369 insertions, 124 deletions
@@ -1,3 +1,20 @@ +1998-08-12 Martin Baulig <martin@home-of-linux.org> + + * include/glibtop/procsegment.h (glibtop_proc_segment): Using + `text_rss', `shlib_rss', `data_rss' and `dirty_size' instead of + `tsr', `lrs', `drs' and `dt'. New field `stack_rss'. + + * sysdeps/linux/procmem.c: Memory sizes now correctly in bytes. + * sysdeps/linux/procsegment.c: Dito. + + * sysdeps/kernel/procsegment.c: Stack pages are reported via + `stack_rss' and no longer count towards `data_rss' + * kernel/table.h (table_proc_segment): Added `srs' field. + * kernel/table21/module.c (TBL_PROC_SEGMENT): Added kernel support + for this. + + * sysdeps/{linux, kernel, stub}/procmap.c: New files. + 1998-08-11 Martin Baulig <martin@home-of-linux.org> * guile/features.awk: New file. diff --git a/examples/first.c b/examples/first.c index cd83dbcf..3f9714d1 100644 --- a/examples/first.c +++ b/examples/first.c @@ -257,6 +257,21 @@ main (int argc, char *argv []) (unsigned long) data.proc_mem.rss, (unsigned long) data.proc_mem.rss_rlim); + for (c = 0; c < PROFILE_COUNT; c++) + glibtop_get_proc_segment (&data.proc_segment, pid); + + printf ("Proc_Segment PID %5u (0x%08lx): " + "%lu %lu %lu %lu %lu %lu %lu %lu\n", pid, + (unsigned long) data.proc_segment.flags, + (unsigned long) data.proc_segment.text_rss, + (unsigned long) data.proc_segment.shlib_rss, + (unsigned long) data.proc_segment.data_rss, + (unsigned long) data.proc_segment.stack_rss, + (unsigned long) data.proc_segment.dirty_size, + (unsigned long) data.proc_segment.start_code, + (unsigned long) data.proc_segment.end_code, + (unsigned long) data.proc_segment.start_stack); + getrusage (RUSAGE_SELF, &ru); fprintf (stderr, "GETRUSAGE: (%ld, %ld) - (%ld, %ld)\n", @@ -306,20 +321,6 @@ main (int argc, char *argv []) (unsigned long) data.proc_kernel.nwchan, data.proc_kernel.wchan); - for (c = 0; c < PROFILE_COUNT; c++) - glibtop_get_proc_segment (&data.proc_segment, pid); - - printf ("Proc_Segment PID %5u (0x%08lx): " - "%lu %lu %lu %lu %lu %lu %lu\n", pid, - (unsigned long) data.proc_segment.flags, - (unsigned long) data.proc_segment.trs, - (unsigned long) data.proc_segment.lrs, - (unsigned long) data.proc_segment.drs, - (unsigned long) data.proc_segment.dt, - (unsigned long) data.proc_segment.start_code, - (unsigned long) data.proc_segment.end_code, - (unsigned long) data.proc_segment.start_stack); - printf ("\n"); for (c = 0; c < PROFILE_COUNT; c++) @@ -357,6 +358,21 @@ main (int argc, char *argv []) (unsigned long) data.proc_mem.rss_rlim); for (c = 0; c < PROFILE_COUNT; c++) + glibtop_get_proc_segment (&data.proc_segment, ppid); + + printf ("Proc_Segment PPID %5u (0x%08lx): " + "%lu %lu %lu %lu %lu %lu %lu %lu\n", ppid, + (unsigned long) data.proc_segment.flags, + (unsigned long) data.proc_segment.text_rss, + (unsigned long) data.proc_segment.shlib_rss, + (unsigned long) data.proc_segment.data_rss, + (unsigned long) data.proc_segment.stack_rss, + (unsigned long) data.proc_segment.dirty_size, + (unsigned long) data.proc_segment.start_code, + (unsigned long) data.proc_segment.end_code, + (unsigned long) data.proc_segment.start_stack); + + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_time (&data.proc_time, ppid); printf ("Proc_Time PPID %5u (0x%08lx): " @@ -398,20 +414,6 @@ main (int argc, char *argv []) (unsigned long) data.proc_kernel.nwchan, data.proc_kernel.wchan); - for (c = 0; c < PROFILE_COUNT; c++) - glibtop_get_proc_segment (&data.proc_segment, ppid); - - printf ("Proc_Segment PPID %5u (0x%08lx): " - "%lu %lu %lu %lu %lu %lu %lu\n", ppid, - (unsigned long) data.proc_segment.flags, - (unsigned long) data.proc_segment.trs, - (unsigned long) data.proc_segment.lrs, - (unsigned long) data.proc_segment.drs, - (unsigned long) data.proc_segment.dt, - (unsigned long) data.proc_segment.start_code, - (unsigned long) data.proc_segment.end_code, - (unsigned long) data.proc_segment.start_stack); - printf ("\n"); for (c = 0; c < PROFILE_COUNT; c++) @@ -449,6 +451,21 @@ main (int argc, char *argv []) (unsigned long) data.proc_mem.rss_rlim); for (c = 0; c < PROFILE_COUNT; c++) + glibtop_get_proc_segment (&data.proc_segment, 1); + + printf ("Proc_Segment INIT %5u (0x%08lx): " + "%lu %lu %lu %lu %lu %lu %lu %lu\n", 1, + (unsigned long) data.proc_segment.flags, + (unsigned long) data.proc_segment.text_rss, + (unsigned long) data.proc_segment.shlib_rss, + (unsigned long) data.proc_segment.data_rss, + (unsigned long) data.proc_segment.stack_rss, + (unsigned long) data.proc_segment.dirty_size, + (unsigned long) data.proc_segment.start_code, + (unsigned long) data.proc_segment.end_code, + (unsigned long) data.proc_segment.start_stack); + + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_time (&data.proc_time, 1); printf ("Proc_Time INIT %5u (0x%08lx): " @@ -491,20 +508,6 @@ main (int argc, char *argv []) (unsigned long) data.proc_kernel.nwchan, data.proc_kernel.wchan); - for (c = 0; c < PROFILE_COUNT; c++) - glibtop_get_proc_segment (&data.proc_segment, 1); - - printf ("Proc_Segment INIT %5u (0x%08lx): " - "%lu %lu %lu %lu %lu %lu %lu\n", 1, - (unsigned long) data.proc_segment.flags, - (unsigned long) data.proc_segment.trs, - (unsigned long) data.proc_segment.lrs, - (unsigned long) data.proc_segment.drs, - (unsigned long) data.proc_segment.dt, - (unsigned long) data.proc_segment.start_code, - (unsigned long) data.proc_segment.end_code, - (unsigned long) data.proc_segment.start_stack); - glibtop_close (); exit (0); diff --git a/examples/procmap.c b/examples/procmap.c index 33514227..0be8ebc6 100644 --- a/examples/procmap.c +++ b/examples/procmap.c @@ -80,12 +80,11 @@ main (int argc, char *argv []) maps = glibtop_get_proc_map (&procmap, pid); for (i = 0; i < procmap.number; i++) { - fprintf (stderr, "%08x - %08x - %08lu - %08lu - '%s'\n", + fprintf (stderr, "%08x - %08x - %08lu - %08lu\n", (unsigned long) maps [i].start, (unsigned long) maps [i].end, (unsigned long) maps [i].device, - (unsigned long) maps [i].inode, - devname (maps [i].device, S_IFBLK)); + (unsigned long) maps [i].inode); } glibtop_free (maps); diff --git a/examples/second.c b/examples/second.c index 6963bf98..7e4a8264 100644 --- a/examples/second.c +++ b/examples/second.c @@ -115,6 +115,20 @@ main (int argc, char *argv []) (unsigned long) data.proc_mem.rss, (unsigned long) data.proc_mem.rss_rlim); + glibtop_get_proc_segment (&data.proc_segment, pid); + + printf ("Proc_Segment PID %5u (0x%08lx): " + "%lu %lu %lu %lu %lu %lu %lu %lu\n", pid, + (unsigned long) data.proc_segment.flags, + (unsigned long) data.proc_segment.text_rss, + (unsigned long) data.proc_segment.shlib_rss, + (unsigned long) data.proc_segment.data_rss, + (unsigned long) data.proc_segment.stack_rss, + (unsigned long) data.proc_segment.dirty_size, + (unsigned long) data.proc_segment.start_code, + (unsigned long) data.proc_segment.end_code, + (unsigned long) data.proc_segment.start_stack); + glibtop_get_proc_time (&data.proc_time, pid); printf ("Proc_Time PID %5u (0x%08lx): " @@ -155,19 +169,6 @@ main (int argc, char *argv []) (unsigned long) data.proc_kernel.nwchan, data.proc_kernel.wchan); - glibtop_get_proc_segment (&data.proc_segment, pid); - - printf ("Proc_Segment PID %5u (0x%08lx): " - "%lu %lu %lu %lu %lu %lu %lu\n", pid, - (unsigned long) data.proc_segment.flags, - (unsigned long) data.proc_segment.trs, - (unsigned long) data.proc_segment.lrs, - (unsigned long) data.proc_segment.drs, - (unsigned long) data.proc_segment.dt, - (unsigned long) data.proc_segment.start_code, - (unsigned long) data.proc_segment.end_code, - (unsigned long) data.proc_segment.start_stack); - printf ("\n"); } diff --git a/features.def b/features.def index abdf6be4..22be401c 100644 --- a/features.def +++ b/features.def @@ -13,7 +13,7 @@ void|proc_mem|long(size,vsize,resident,share,rss,rss_rlim)|pid_t(pid) void|proc_time|long(start_time,rtime,utime,stime,cutime,cstime,timeout,it_real_value,frequency)|pid_t(pid) void|proc_signal|ulong(signal,blocked,sigignore,sigcatch)|pid_t(pid) void|proc_kernel|ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,nwchan):str(wchan)|pid_t(pid) -void|proc_segment|long(trs,lrs,drs,dt):ulong(start_code,end_code,start_stack)|pid_t(pid) +void|proc_segment|ulong(text_rss,shlib_rss,data_rss,stack_rss,dirty_size,start_code,end_code,start_stack)|pid_t(pid) glibtop_map_entry *|proc_map|ulong(number,size,total)|pid_t(pid) glibtop_mountentry *|@mountlist|ulong(number,size,total)|pid_t(all_fs) void|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|string|mount_dir diff --git a/guile/reference.sgml b/guile/reference.sgml index a0826aef..2dffd33d 100644 --- a/guile/reference.sgml +++ b/guile/reference.sgml @@ -1457,13 +1457,14 @@ typedef struct _glibtop_proc_segment glibtop_proc_segment; struct _glibtop_proc_segment { u_int64_t flags; - u_int64_t start_code, /* GLIBTOP_PROC_SEGMENT_START_CODE */ + u_int64_t text_rss, /* GLIBTOP_PROC_SEGMENT_TEXT_RSS */ + shlib_rss, /* GLIBTOP_PROC_SEGMENT_SHLIB_RSS */ + data_rss, /* GLIBTOP_PROC_SEGMENT_DATA_RSS */ + stack_rss, /* GLIBTOP_PROC_SEGMENT_STACK_RSS */ + dirty_size, /* GLIBTOP_PROC_SEGMENT_DIRTY_SIZE */ + start_code, /* GLIBTOP_PROC_SEGMENT_START_CODE */ end_code, /* GLIBTOP_PROC_SEGMENT_END_CODE */ start_stack; /* GLIBTOP_PROC_SEGMENT_START_STACK */ - int64_t trs, /* GLIBTOP_PROC_SEGMENT_TRS */ - lrs, /* GLIBTOP_PROC_SEGMENT_LRS */ - drs, /* GLIBTOP_PROC_SEGMENT_DRS */ - dt; /* GLIBTOP_PROC_SEGMENT_DT */ }; </literallayout> </blockquote> @@ -1472,32 +1473,39 @@ struct _glibtop_proc_segment <variablelist> <varlistentry> -<term><parameter>trs</parameter></term> +<term><parameter>text_rss</parameter></term> <listitem> <para> Text resident set size <varlistentry> -<term><parameter>lrs</parameter></term> +<term><parameter>shlib_rss</parameter></term> <listitem> <para> Shared-Lib resident set size <varlistentry> -<term><parameter>drs</parameter></term> +<term><parameter>data_rss</parameter></term> <listitem> <para> Data resident set size <varlistentry> -<term><parameter>dt</parameter></term> +<term><parameter>stack_rss</parameter></term> <listitem> <para> -Dirty pages +Stack resident set size + +<varlistentry> +<term><parameter>dirty_size</parameter></term> + +<listitem> +<para> +Total size of dirty pages <varlistentry> <term><parameter>start_code</parameter></term> diff --git a/include/glibtop/proclist.h b/include/glibtop/proclist.h index b64d445f..d7c859b9 100644 --- a/include/glibtop/proclist.h +++ b/include/glibtop/proclist.h @@ -44,6 +44,10 @@ __BEGIN_DECLS #define GLIBTOP_KERN_PROC_UID 5 #define GLIBTOP_KERN_PROC_RUID 6 +#define GLIBTOP_EXCLUDE_IDLE 0x1000 +#define GLIBTOP_EXCLUDE_SYSTEM 0x2000 +#define GLIBTOP_EXCLUDE_NOTTY 0x4000 + typedef struct _glibtop_proclist glibtop_proclist; struct _glibtop_proclist diff --git a/include/glibtop/procsegment.h b/include/glibtop/procsegment.h index b140f63f..23ec7d39 100644 --- a/include/glibtop/procsegment.h +++ b/include/glibtop/procsegment.h @@ -27,15 +27,16 @@ __BEGIN_DECLS -#define GLIBTOP_PROC_SEGMENT_TRS 0 -#define GLIBTOP_PROC_SEGMENT_LRS 1 -#define GLIBTOP_PROC_SEGMENT_DRS 2 -#define GLIBTOP_PROC_SEGMENT_DT 3 -#define GLIBTOP_PROC_SEGMENT_START_CODE 4 -#define GLIBTOP_PROC_SEGMENT_END_CODE 5 -#define GLIBTOP_PROC_SEGMENT_START_STACK 6 +#define GLIBTOP_PROC_SEGMENT_TEXT_RSS 0 +#define GLIBTOP_PROC_SEGMENT_SHLIB_RSS 1 +#define GLIBTOP_PROC_SEGMENT_DATA_RSS 2 +#define GLIBTOP_PROC_SEGMENT_STACK_RSS 3 +#define GLIBTOP_PROC_SEGMENT_DIRTY_SIZE 4 +#define GLIBTOP_PROC_SEGMENT_START_CODE 5 +#define GLIBTOP_PROC_SEGMENT_END_CODE 6 +#define GLIBTOP_PROC_SEGMENT_START_STACK 7 -#define GLIBTOP_MAX_PROC_SEGMENT 7 +#define GLIBTOP_MAX_PROC_SEGMENT 8 typedef struct _glibtop_proc_segment glibtop_proc_segment; @@ -44,10 +45,11 @@ typedef struct _glibtop_proc_segment glibtop_proc_segment; struct _glibtop_proc_segment { u_int64_t flags, - trs, /* text resident set size */ - lrs, /* shared-lib resident set size */ - drs, /* data resident set size */ - dt, /* dirty pages */ + text_rss, /* text resident set size */ + shlib_rss, /* shared-lib resident set size */ + data_rss, /* data resident set size */ + stack_rss, /* stack resident set size */ + dirty_size, /* size of dirty pages */ start_code, /* address of beginning of code segment */ end_code, /* address of end of code segment */ diff --git a/kernel/table.h b/kernel/table.h index 9136f537..6dac48d4 100644 --- a/kernel/table.h +++ b/kernel/table.h @@ -117,8 +117,8 @@ struct table_proc_mem struct table_proc_segment { unsigned long vsize; - int size, resident, shared; - int trs, lrs, drs, dt; + unsigned long size, resident, shared; + unsigned long trs, lrs, drs, srs, dt; }; struct table_proc_time diff --git a/kernel/table21/module.c b/kernel/table21/module.c index 77ff898a..9b55eca6 100644 --- a/kernel/table21/module.c +++ b/kernel/table21/module.c @@ -473,7 +473,7 @@ table_fkt (int type, union table *buf, const void *param) if (tsk->mm && tsk->mm != &init_mm) { unsigned long vsize = 0; int size = 0, resident = 0, share = 0; - int trs = 0, lrs = 0, drs = 0, dt = 0; + int trs = 0, lrs = 0, drs = 0, srs = 0, dt = 0; struct vm_area_struct * vma = tsk->mm->mmap; while (vma) { @@ -486,27 +486,26 @@ table_fkt (int type, union table *buf, const void *param) &pages, &shared, &dirty, &total); -#if 0 - printk ("vma %p (%d) - %d, %d, %d, %d - " - "%lx - %lx, %lx - %lx - %lx\n", - vma, pid, pages, shared, dirty, total, - PAGE_SIZE, vma->vm_start, vma->vm_end, - vma->vm_end - vma->vm_start, - (vma->vm_end - vma->vm_start) >> PAGE_SHIFT); -#endif - resident += pages; share += shared; dt += dirty; size += total; - if (vma->vm_flags & VM_EXECUTABLE) - trs += pages; /* text */ - else if (vma->vm_flags & VM_GROWSDOWN) - drs += pages; /* stack */ - else if (vma->vm_end > 0x60000000) + + /* Well, shared library seem to get mapped + * above 0x40000000 and are executable, + * so I use this hack to get their size. + */ + + if (vma->vm_flags & VM_GROWSDOWN) + srs += pages; /* stack */ + else if ((vma->vm_flags & VM_EXEC) && + (vma->vm_start > 0x40000000)) lrs += pages; /* library */ + else if (vma->vm_flags & VM_EXECUTABLE) + trs += pages; /* text */ else drs += pages; + vma = vma->vm_next; } @@ -516,6 +515,8 @@ table_fkt (int type, union table *buf, const void *param) tbl.proc_segment.shared = share << PAGE_SHIFT; tbl.proc_segment.trs = trs << PAGE_SHIFT; tbl.proc_segment.lrs = lrs << PAGE_SHIFT; + tbl.proc_segment.drs = drs << PAGE_SHIFT; + tbl.proc_segment.srs = srs << PAGE_SHIFT; tbl.proc_segment.dt = dt << PAGE_SHIFT; } break; diff --git a/sysdeps/guile/names/guile-names.awk b/sysdeps/guile/names/guile-names.awk index 3572c001..4790cae9 100644 --- a/sysdeps/guile/names/guile-names.awk +++ b/sysdeps/guile/names/guile-names.awk @@ -103,6 +103,8 @@ function output(feature) { } END { + features["sysdeps"] = "sysdeps"; + for (feature in features) { output(feature); } diff --git a/sysdeps/kernel/Makefile.am b/sysdeps/kernel/Makefile.am index 10318b8d..fcc2f1cf 100644 --- a/sysdeps/kernel/Makefile.am +++ b/sysdeps/kernel/Makefile.am @@ -8,7 +8,7 @@ libgtop_sysdeps_la_SOURCES = open.c close.c kernel.s cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c siglist.c + procsegment.c siglist.c procmap.c include_HEADERS = glibtop_server.h diff --git a/sysdeps/kernel/glibtop_server.h b/sysdeps/kernel/glibtop_server.h index 52b1b3c0..23664c12 100644 --- a/sysdeps/kernel/glibtop_server.h +++ b/sysdeps/kernel/glibtop_server.h @@ -40,6 +40,7 @@ __BEGIN_DECLS #define GLIBTOP_SUID_PROC_SIGNAL 0 #define GLIBTOP_SUID_PROC_KERNEL 0 #define GLIBTOP_SUID_PROC_SEGMENT 0 +#define GLIBTOP_SUID_PROC_MAP 0 __END_DECLS diff --git a/sysdeps/kernel/kernel.s b/sysdeps/kernel/kernel.s index 155fddaa..d6b368c1 100644 --- a/sysdeps/kernel/kernel.s +++ b/sysdeps/kernel/kernel.s @@ -19,7 +19,7 @@ gcc2_compiled.: table: pushl %ebp movl %esp,%ebp - movl $188,%eax + movl $190,%eax pushl %ebx movl 8(%ebp),%ebx movl 12(%ebp),%ecx diff --git a/sysdeps/kernel/prockernel.c b/sysdeps/kernel/prockernel.c index 6b697b46..0a69f4a5 100644 --- a/sysdeps/kernel/prockernel.c +++ b/sysdeps/kernel/prockernel.c @@ -29,7 +29,7 @@ static const unsigned long _glibtop_sysdeps_proc_kernel = (1 << GLIBTOP_PROC_KERNEL_K_FLAGS) + (1 << GLIBTOP_PROC_KERNEL_MIN_FLT) + (1 << GLIBTOP_PROC_KERNEL_MAJ_FLT) + (1 << GLIBTOP_PROC_KERNEL_CMIN_FLT) + (1 << GLIBTOP_PROC_KERNEL_CMAJ_FLT) + (1 << GLIBTOP_PROC_KERNEL_KSTK_ESP) + -(1 << GLIBTOP_PROC_KERNEL_KSTK_EIP) + (1 << GLIBTOP_PROC_KERNEL_WCHAN); +(1 << GLIBTOP_PROC_KERNEL_KSTK_EIP) + (1 << GLIBTOP_PROC_KERNEL_NWCHAN); /* Init function. */ @@ -62,5 +62,5 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, buf->cmaj_flt = tbl.proc_kernel.cmaj_flt; buf->kstk_esp = tbl.proc_kernel.kesp; buf->kstk_eip = tbl.proc_kernel.keip; - buf->wchan = tbl.proc_kernel.wchan; + buf->nwchan = tbl.proc_kernel.wchan; } diff --git a/sysdeps/kernel/proclist.c b/sysdeps/kernel/proclist.c index c664c7ca..e9289444 100644 --- a/sysdeps/kernel/proclist.c +++ b/sysdeps/kernel/proclist.c @@ -54,7 +54,8 @@ glibtop_init_proclist_s (glibtop *server) * On error, NULL is returned and buf->flags is zero. */ unsigned * -glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf) +glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf, + int64_t which, int64_t arg) { union table tbl; unsigned *pids_chain; diff --git a/sysdeps/kernel/procmap.c b/sysdeps/kernel/procmap.c new file mode 100644 index 00000000..33a86a83 --- /dev/null +++ b/sysdeps/kernel/procmap.c @@ -0,0 +1,47 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <glibtop.h> +#include <glibtop/error.h> +#include <glibtop/xmalloc.h> +#include <glibtop/procmap.h> + +static const unsigned long _glibtop_sysdeps_proc_map = 0; + +/* Init function. */ + +void +glibtop_init_proc_map_s (glibtop *server) +{ + server->sysdeps.proc_map = _glibtop_sysdeps_proc_map; +} + +/* Provides detailed information about a process. */ + +glibtop_map_entry * +glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) +{ + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0); + + memset (buf, 0, sizeof (glibtop_proc_map)); + + return NULL; +} diff --git a/sysdeps/kernel/procsegment.c b/sysdeps/kernel/procsegment.c index 8f5c36dc..17c804a5 100644 --- a/sysdeps/kernel/procsegment.c +++ b/sysdeps/kernel/procsegment.c @@ -26,9 +26,13 @@ #include "kernel.h" static const unsigned long _glibtop_sysdeps_proc_segment = -(1 << GLIBTOP_PROC_SEGMENT_TRS) + (1 << GLIBTOP_PROC_SEGMENT_LRS) + -(1 << GLIBTOP_PROC_SEGMENT_DRS) + (1 << GLIBTOP_PROC_SEGMENT_DT) + -(1 << GLIBTOP_PROC_SEGMENT_START_CODE) + (1 << GLIBTOP_PROC_SEGMENT_END_CODE) + +(1 << GLIBTOP_PROC_SEGMENT_TEXT_RSS) + +(1 << GLIBTOP_PROC_SEGMENT_SHLIB_RSS) + +(1 << GLIBTOP_PROC_SEGMENT_DATA_RSS) + +(1 << GLIBTOP_PROC_SEGMENT_STACK_RSS) + +(1 << GLIBTOP_PROC_SEGMENT_DIRTY_SIZE) + +(1 << GLIBTOP_PROC_SEGMENT_START_CODE) + +(1 << GLIBTOP_PROC_SEGMENT_END_CODE) + (1 << GLIBTOP_PROC_SEGMENT_START_STACK); /* Init function. */ @@ -63,8 +67,9 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, buf->flags = _glibtop_sysdeps_proc_segment; - buf->trs = tbl.proc_segment.trs; - buf->lrs = tbl.proc_segment.lrs; - buf->drs = tbl.proc_segment.drs; - buf->dt = tbl.proc_segment.dt; + buf->text_rss = tbl.proc_segment.trs; + buf->shlib_rss = tbl.proc_segment.lrs; + buf->data_rss = tbl.proc_segment.drs; + buf->stack_rss = tbl.proc_segment.srs; + buf->dirty_size = tbl.proc_segment.dt; } diff --git a/sysdeps/linux/Makefile.am b/sysdeps/linux/Makefile.am index 29b6fb89..a54e53cf 100644 --- a/sysdeps/linux/Makefile.am +++ b/sysdeps/linux/Makefile.am @@ -8,6 +8,6 @@ libgtop_sysdeps_la_SOURCES = open.c close.c cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c siglist.c + procsegment.c procmap.c siglist.c include_HEADERS = glibtop_server.h glibtop_machine.h diff --git a/sysdeps/linux/glibtop_server.h b/sysdeps/linux/glibtop_server.h index 52b1b3c0..23664c12 100644 --- a/sysdeps/linux/glibtop_server.h +++ b/sysdeps/linux/glibtop_server.h @@ -40,6 +40,7 @@ __BEGIN_DECLS #define GLIBTOP_SUID_PROC_SIGNAL 0 #define GLIBTOP_SUID_PROC_KERNEL 0 #define GLIBTOP_SUID_PROC_SEGMENT 0 +#define GLIBTOP_SUID_PROC_MAP 0 __END_DECLS diff --git a/sysdeps/linux/proclist.c b/sysdeps/linux/proclist.c index 6ed9384f..92cabaae 100644 --- a/sysdeps/linux/proclist.c +++ b/sysdeps/linux/proclist.c @@ -57,7 +57,8 @@ glibtop_init_proclist_s (glibtop *server) * On error, NULL is returned and buf->flags is zero. */ unsigned * -glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf) +glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf, + int64_t which, int64_t arg) { DIR *proc; struct dirent *entry; diff --git a/sysdeps/linux/procmap.c b/sysdeps/linux/procmap.c new file mode 100644 index 00000000..33a86a83 --- /dev/null +++ b/sysdeps/linux/procmap.c @@ -0,0 +1,47 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <glibtop.h> +#include <glibtop/error.h> +#include <glibtop/xmalloc.h> +#include <glibtop/procmap.h> + +static const unsigned long _glibtop_sysdeps_proc_map = 0; + +/* Init function. */ + +void +glibtop_init_proc_map_s (glibtop *server) +{ + server->sysdeps.proc_map = _glibtop_sysdeps_proc_map; +} + +/* Provides detailed information about a process. */ + +glibtop_map_entry * +glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) +{ + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0); + + memset (buf, 0, sizeof (glibtop_proc_map)); + + return NULL; +} diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c index 2cd84a37..813eb696 100644 --- a/sysdeps/linux/procmem.c +++ b/sysdeps/linux/procmem.c @@ -28,12 +28,33 @@ static const unsigned long _glibtop_sysdeps_proc_mem = (1 << GLIBTOP_PROC_MEM_RESIDENT) + (1 << GLIBTOP_PROC_MEM_SHARE) + (1 << GLIBTOP_PROC_MEM_RSS) + (1 << GLIBTOP_PROC_MEM_RSS_RLIM); +#ifndef LOG1024 +#define LOG1024 10 +#endif + +/* these are for getting the memory statistics */ +static int pageshift; /* log base 2 of the pagesize */ + +/* define pagetok in terms of pageshift */ +#define pagetok(size) ((size) << pageshift) + /* Init function. */ void glibtop_init_proc_mem_s (glibtop *server) { + register int pagesize; + server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem; + + /* get the page size with "getpagesize" and calculate pageshift + * from it */ + pagesize = getpagesize (); + pageshift = 0; + while (pagesize > 1) { + pageshift++; + pagesize >>= 1; + } } /* Provides detailed information about a process. */ @@ -93,6 +114,11 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) sscanf (input, "%Lu %Lu %Lu", &buf->size, &buf->resident, &buf->share); + buf->size <<= pageshift; + buf->resident <<= pageshift; + buf->share <<= pageshift; + buf->rss <<= pageshift; + fclose (f); buf->flags = _glibtop_sysdeps_proc_mem; diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c index 375a16f7..9e6e479d 100644 --- a/sysdeps/linux/procsegment.c +++ b/sysdeps/linux/procsegment.c @@ -24,17 +24,41 @@ #include <glibtop/procsegment.h> static const unsigned long _glibtop_sysdeps_proc_segment = -(1 << GLIBTOP_PROC_SEGMENT_TRS) + (1 << GLIBTOP_PROC_SEGMENT_LRS) + -(1 << GLIBTOP_PROC_SEGMENT_DRS) + (1 << GLIBTOP_PROC_SEGMENT_DT) + -(1 << GLIBTOP_PROC_SEGMENT_START_CODE) + (1 << GLIBTOP_PROC_SEGMENT_END_CODE) + +(1 << GLIBTOP_PROC_SEGMENT_TEXT_RSS) + +(1 << GLIBTOP_PROC_SEGMENT_SHLIB_RSS) + +(1 << GLIBTOP_PROC_SEGMENT_DATA_RSS) + +(1 << GLIBTOP_PROC_SEGMENT_DIRTY_SIZE) + +(1 << GLIBTOP_PROC_SEGMENT_START_CODE) + +(1 << GLIBTOP_PROC_SEGMENT_END_CODE) + (1 << GLIBTOP_PROC_SEGMENT_START_STACK); +#ifndef LOG1024 +#define LOG1024 10 +#endif + +/* these are for getting the memory statistics */ +static int pageshift; /* log base 2 of the pagesize */ + +/* define pagetok in terms of pageshift */ +#define pagetok(size) ((size) << pageshift) + /* Init function. */ void glibtop_init_proc_segment_s (glibtop *server) { + register int pagesize; + server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment; + + /* get the page size with "getpagesize" and calculate pageshift + * from it */ + pagesize = getpagesize (); + pageshift = 0; + while (pagesize > 1) { + pageshift++; + pagesize >>= 1; + } } /* Provides detailed information about a process. */ @@ -94,7 +118,13 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, input [nread] = 0; sscanf (input, "%*d %*d %*d %Lu %Lu %Lu %Lu", - &buf->trs, &buf->lrs, &buf->drs, &buf->dt); + &buf->text_rss, &buf->shlib_rss, + &buf->data_rss, &buf->dirty_size); + + buf->text_rss <<= pageshift; + buf->shlib_rss <<= pageshift; + buf->data_rss <<= pageshift; + buf->dirty_size <<= pageshift; fclose (f); diff --git a/sysdeps/names/procsegment.c b/sysdeps/names/procsegment.c index c0c84b66..326ee49a 100644 --- a/sysdeps/names/procsegment.c +++ b/sysdeps/names/procsegment.c @@ -24,20 +24,21 @@ const char *glibtop_names_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = { - "trs", "lrs", "drs", "dt", "start_code", "end_code", "start_stack" + "text_rss", "shlib_rss", "data_rss", "stack_rss", + "dirty_size", "start_code", "end_code", "start_stack" }; const unsigned glibtop_types_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = { - GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, - GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, - GLIBTOP_TYPE_ULONG + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = { - N_("TRS"), N_("LRS"), N_("DRS"), N_("DT"), N_("Start_Code"), - N_("End_Code"), N_("Start_Stack") + N_("Text_RSS"), N_("ShLib_RSS"), N_("Data_RSS"), N_("Stack_RSS"), + N_("Dirty Size"), N_("Start_Code"), N_("End_Code"), N_("Start_Stack") }; const char *glibtop_descriptions_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = @@ -45,7 +46,8 @@ const char *glibtop_descriptions_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = N_("Text resident set size"), N_("Shared-Lib resident set size"), N_("Data resident set size"), - N_("Dirty pages"), + N_("Stack resident set size"), + N_("Total size of dirty pages"), N_("Address of beginning of code segment"), N_("Address of end of code segment"), N_("Address of the bottom of stack segment") diff --git a/sysdeps/stub/Makefile.am b/sysdeps/stub/Makefile.am index 07b25c66..0b729f62 100644 --- a/sysdeps/stub/Makefile.am +++ b/sysdeps/stub/Makefile.am @@ -8,5 +8,5 @@ libgtop_sysdeps_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c + procsegment.c procmap.c diff --git a/sysdeps/stub/procmap.c b/sysdeps/stub/procmap.c new file mode 100644 index 00000000..33a86a83 --- /dev/null +++ b/sysdeps/stub/procmap.c @@ -0,0 +1,47 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <glibtop.h> +#include <glibtop/error.h> +#include <glibtop/xmalloc.h> +#include <glibtop/procmap.h> + +static const unsigned long _glibtop_sysdeps_proc_map = 0; + +/* Init function. */ + +void +glibtop_init_proc_map_s (glibtop *server) +{ + server->sysdeps.proc_map = _glibtop_sysdeps_proc_map; +} + +/* Provides detailed information about a process. */ + +glibtop_map_entry * +glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) +{ + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0); + + memset (buf, 0, sizeof (glibtop_proc_map)); + + return NULL; +} |