VMware Cloud Community
rr_hyperic
Contributor
Contributor

HP-UX process memory size

Hi. I have noticed that the process memory size values returned from sigar_proc_mem_get() is not the same as top, which it should be comparable to, as stated in the sigar docs.

I switched from real memory to virtual memory usage,
and added the sizes for all memory areas for a process found in /usr/include/sys/pstat/pm_pstat_body.h from HP-UX B.11.11. which seemed to be relevant.

Also switched from real to virtual memory for shared area

This post from HP forums seem to verify that,
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1077194

But this post mentions the size calculation is fuzzy:

http://groups.google.co.in/group/comp.sys.hp.hpux/browse_thread/thread/7c4ac0033ce706c8/600ccdc16fd0...

anyway.. now size matches "hp-ux top" size more closely

diff -u sigar/os/hpux/hpux_sigar.c.orig sigar/os/hpux/hpux_sigar.c
--- sigar/os/hpux/hpux_sigar.c.orig 2006-12-16 20:12:33 +0100
+++ sigar/os/hpux/hpux_sigar.c 2007-01-23 10:24:07 +0100
@@ -34,6 +34,10 @@
typedef int32_t pstat_int_t;
#endif

int sigar_os_open(sigar_t **sigar)
{
*sigar = malloc(sizeof(**sigar));
@@ -284,15 +288,19 @@
}

procmem->size =
- pinfo->pst_tsize + /* text */
- pinfo->pst_dsize + /* data */
- pinfo->pst_ssize; /* stack */
+ pinfo->pst_vtsize + /* text */
+ pinfo->pst_vdsize + /* data */
+ pinfo->pst_vssize + /* stack */
+ pinfo->pst_vshmsize + /* shared memory */
+ pinfo->pst_vmmsize + /* mem-mapped files */
+ pinfo->pst_vusize + /* U-Area & K-Stack */
+ pinfo->pst_viosize; /* I/O dev mapping */

procmem->size *= pagesize;

procmem->resident = pinfo->pst_rssize * pagesize;

- procmem->share = pinfo->pst_shmsize * pagesize;
+ procmem->share = pinfo->pst_vshmsize * pagesize;

procmem->minor_faults = pinfo->pst_minorfaults;
procmem->major_faults = pinfo->pst_majorfaults;
Reply
0 Kudos
1 Reply
dougm_hyperic
VMware Employee
VMware Employee

(moved to sigar-dev)

Interesting, the numbers look the same between top and sigar on HP-UX
11.00, so I hadn't noticed. Your explanation makes sense and patch
looks good, I've applied to both trunk and the SIGAR_1_3 branch.
Thanks!

On Jan 23, 2007, at 1:48 AM, rr wrote:

> Hi. I have noticed that the process memory size values returned
> from sigar_proc_mem_get() is not the same as top, which it should
> be comparable to, as stated in the sigar docs.
>
> I switched from real memory to virtual memory usage,
> and added the sizes for all memory areas for a process found in /
> usr/include/sys/pstat/pm_pstat_body.h from HP-UX B.11.11. which
> seemed to be relevant.
>
> Also switched from real to virtual memory for shared area
>
> This post from HP forums seem to verify that,
> http://forums1.itrc.hp.com/service/forums/questionanswer.do?
> threadId=1077194
>
> But this post mentions the size calculation is fuzzy:
>
> http://groups.google.co.in/group/comp.sys.hp.hpux/browse_thread/
> thread/7c4ac0033ce706c8/600ccdc16fd04f0b?lnk=gst&q=glance&rnum=15
>
> anyway.. now size matches "hp-ux top" size more closely
>
> diff -u sigar/os/hpux/hpux_sigar.c.orig sigar/os/hpux/hpux_sigar.c
> --- sigar/os/hpux/hpux_sigar.c.orig 2006-12-16 20:12:33 +0100
> +++ sigar/os/hpux/hpux_sigar.c 2007-01-23 10:24:07 +0100
> @@ -34,6 +34,10 @@
> typedef int32_t pstat_int_t;
> #endif
>
> int sigar_os_open(sigar_t **sigar)
> {
> *sigar = malloc(sizeof(**sigar));
> @@ -284,15 +288,19 @@
> }
>
> procmem->size =
> - pinfo->pst_tsize + /* text */
> - pinfo->pst_dsize + /* data */
> - pinfo->pst_ssize; /* stack */
> + pinfo->pst_vtsize + /* text */
> + pinfo->pst_vdsize + /* data */
> + pinfo->pst_vssize + /* stack */
> + pinfo->pst_vshmsize + /* shared memory */
> + pinfo->pst_vmmsize + /* mem-mapped files */
> + pinfo->pst_vusize + /* U-Area & K-Stack */
> + pinfo->pst_viosize; /* I/O dev mapping */
>
> procmem->size *= pagesize;
>
> procmem->resident = pinfo->pst_rssize * pagesize;
>
> - procmem->share = pinfo->pst_shmsize * pagesize;
> + procmem->share = pinfo->pst_vshmsize * pagesize;
>
> procmem->minor_faults = pinfo->pst_minorfaults;
> procmem->major_faults = pinfo->pst_majorfaults;
>



Reply
0 Kudos