The xvmstat dtrace script gives me an outrageous value for swap:

  w            swap          free     re   maj    mf   
264  17592185983072   2014      5     0   529    

the 'top' command shows it correctly:

Memory: 128G real, 2088M free, 130G swap in use, 23G swap free

It looks like the problem is that my system is returning a higher value for 
swapfs_minfree than availrmem, so `availrmem - `swapfs_minfree is a negative 
number, and that um, does not compute.  Taking code from xvmstat:

# cat ./mem.d
#!/usr/sbin/dtrace -qs
dtrace:::BEGIN
{
   printf("k_anoninfo.ani_max :       %9d\n", `k_anoninfo.ani_max);
   printf("k_anoninfo.ani_phys_resv : %9d\n", `k_anoninfo.ani_phys_resv);
   printf("k_anoninfo.ani_mem_resv :  %9d\n", `k_anoninfo.ani_mem_resv);
   printf("availrmem :                %9d\n", `availrmem);
   printf("swapfs_minfree :           %9d\n", `swapfs_minfree);
   printf("_pagesize :                %9d\n\n", `_pagesize);

   this->ani_max = `k_anoninfo.ani_max; 
   printf("this->ani_max is %9d\n", this->ani_max);

   this->ani_resv = `k_anoninfo.ani_phys_resv + `k_anoninfo.ani_mem_resv; 
   printf("this->ani_resv is %9d\n", this->ani_resv);

   this->swap = (this->ani_max - this->ani_resv > 0 ? this->ani_max - 
this->ani_resv : 0) + `availrmem - `swapfs_minfree;
   printf("this->swap is  %9d\n", this->swap);

   this->swap *= `_pagesize;
   printf("this->swap is  %9d\n", this->swap);

   this->swap /= 1048576;
   printf("this->swap is  %9d\n", this->swap);

   exit(0);
}

# ./mem.d
k_anoninfo.ani_max :         9995349
k_anoninfo.ani_phys_resv :   7061224
k_anoninfo.ani_mem_resv :   10031698
availrmem :                  1277036
swapfs_minfree :             2061000
_pagesize :                     8192

this->ani_max is   9995349
this->ani_resv is  17092922
this->swap is  18446744073701670079
this->swap is  18446744009144000512
this->swap is  17592185982841

So, any idea on how to correctly calculate swap?
-- 
This message posted from opensolaris.org
_______________________________________________
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org

Reply via email to