Ulrich Spoerlein
2006-Nov-16 10:55 UTC
systat -vm output showing negative total virtual memory
Hi all, this is on a two week old RELENG_6. The machine has 4GB RAM, SMP CPU: Intel(R) Xeon(TM) CPU 3.00GHz (3012.12-MHz 686-class CPU) Origin = "GenuineIntel" Id = 0xf43 Stepping = 3 Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUS H,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> Features2=0x641d<SSE3,RSVD2,MON,DS_CPL,CNTX-ID,CX16,<b14>> AMD Features=0x20100000<NX,LM> real memory = 3489071104 (3327 MB) avail memory = 3414265856 (3256 MB) ACPI APIC Table: <PTLTD APIC > FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs cpu0 (BSP): APIC ID: 0 cpu1 (AP): APIC ID: 6 Mem:KB REAL VIRTUAL VN PAGER SWAP PAGER Tot Share Tot Share Free in out in out Act 1198620 115040 1480676 289860 153004 count All 3330652 116920 -956751k 293960 pages vm.vmtotal has this to say System wide totals computed every five seconds: (values in kilobytes) ==============================================Processes: (RUNQ: 3 Disk Wait: 1 Page Wait: 1 Sleep: 40) Virtual Memory: (Total: 815944K, Active 355288K) Real Memory: (Total: 2558540K Active 150424K) Shared Virtual Memory: (Total: 11460K Active: 7856K) Shared Real Memory: (Total: 6916K Active: 5044K) Free Memory Pages: 890092K Uli
Ruslan Ermilov
2006-Nov-16 15:03 UTC
systat -vm output showing negative total virtual memory
On Thu, Nov 16, 2006 at 11:55:09AM +0100, Ulrich Spoerlein wrote:> Hi all, > > this is on a two week old RELENG_6. The machine has 4GB RAM, SMP > > CPU: Intel(R) Xeon(TM) CPU 3.00GHz (3012.12-MHz 686-class CPU) > Origin = "GenuineIntel" Id = 0xf43 Stepping = 3 > Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUS > H,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> > Features2=0x641d<SSE3,RSVD2,MON,DS_CPL,CNTX-ID,CX16,<b14>> > AMD Features=0x20100000<NX,LM> > real memory = 3489071104 (3327 MB) > avail memory = 3414265856 (3256 MB) > ACPI APIC Table: <PTLTD APIC > > FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs > cpu0 (BSP): APIC ID: 0 > cpu1 (AP): APIC ID: 6 > > > Mem:KB REAL VIRTUAL VN PAGER SWAP PAGER > Tot Share Tot Share Free in out in out > Act 1198620 115040 1480676 289860 153004 count > All 3330652 116920 -956751k 293960 pages > > vm.vmtotal has this to say > System wide totals computed every five seconds: (values in kilobytes) > ==============================================> Processes: (RUNQ: 3 Disk Wait: 1 Page Wait: 1 Sleep: 40) > Virtual Memory: (Total: 815944K, Active 355288K) > Real Memory: (Total: 2558540K Active 150424K) > Shared Virtual Memory: (Total: 11460K Active: 7856K) > Shared Real Memory: (Total: 6916K Active: 5044K) > Free Memory Pages: 890092K >If my reading of the sys/vm/vm_meter.c code is correct, then all this is wrong; t_vm, t_avm, t_vmshr, and t_avmshr are all in bytes (here's a snippet from vm_meter.c): : totalp->t_vm += object->size; : totalp->t_rm += object->resident_page_count; : if (object->flags & OBJ_ACTIVE) { : totalp->t_avm += object->size; : totalp->t_arm += object->resident_page_count; : } : if (object->shadow_count > 1) { : /* shared object */ : totalp->t_vmshr += object->size; : totalp->t_rmshr += object->resident_page_count; : if (object->flags & OBJ_ACTIVE) { : totalp->t_avmshr += object->size; : totalp->t_armshr += object->resident_page_count; : } : } sysctl(8) knows that t_vm is in bytes, but for the other stats it thinks they are in pages. "systat -vm" thinks they are all in bytes. Here's a fix: %%% Index: sbin/sysctl/sysctl.c ==================================================================RCS file: /home/ncvs/src/sbin/sysctl/sysctl.c,v retrieving revision 1.67.2.7 diff -u -p -r1.67.2.7 sysctl.c --- sbin/sysctl/sysctl.c 8 Sep 2006 09:45:35 -0000 1.67.2.7 +++ sbin/sysctl/sysctl.c 16 Nov 2006 14:51:18 -0000 @@ -395,14 +395,14 @@ S_vmtotal(int l2, void *p) "%hu Sleep: %hu)\n", v->t_rq, v->t_dw, v->t_pw, v->t_sl); printf( - "Virtual Memory:\t\t(Total: %luK, Active %lldK)\n", + "Virtual Memory:\t\t(Total: %luK, Active %luK)\n", (unsigned long)v->t_vm / 1024, - (long long)v->t_avm * pageKilo); + (unsigned long)v->t_avm / 1024); printf("Real Memory:\t\t(Total: %lldK Active %lldK)\n", (long long)v->t_rm * pageKilo, (long long)v->t_arm * pageKilo); - printf("Shared Virtual Memory:\t(Total: %lldK Active: %lldK)\n", - (long long)v->t_vmshr * pageKilo, - (long long)v->t_avmshr * pageKilo); + printf("Shared Virtual Memory:\t(Total: %luK Active: %luK)\n", + (unsigned long)v->t_vmshr / 1024, + (unsigned long)v->t_avmshr / 1024); printf("Shared Real Memory:\t(Total: %lldK Active: %lldK)\n", (long long)v->t_rmshr * pageKilo, (long long)v->t_armshr * pageKilo); Index: usr.bin/systat/vmstat.c ==================================================================RCS file: /home/ncvs/src/usr.bin/systat/vmstat.c,v retrieving revision 1.60.2.1 diff -u -p -r1.60.2.1 vmstat.c --- usr.bin/systat/vmstat.c 21 Mar 2006 20:49:50 -0000 1.60.2.1 +++ usr.bin/systat/vmstat.c 16 Nov 2006 14:55:32 -0000 @@ -475,12 +475,12 @@ showkre() #define pgtokb(pg) ((pg) * (s.v_page_size / 1024)) putint(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 3, 8); putint(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 11, 8); - putint(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 19, 9); - putint(pgtokb(total.t_avmshr), MEMROW + 2, MEMCOL + 28, 9); + putint(total.t_avm/1024, MEMROW + 2, MEMCOL + 19, 9); + putint(total.t_avmshr/1024, MEMROW + 2, MEMCOL + 28, 9); putint(pgtokb(total.t_rm), MEMROW + 3, MEMCOL + 3, 8); putint(pgtokb(total.t_rmshr), MEMROW + 3, MEMCOL + 11, 8); - putint(pgtokb(total.t_vm), MEMROW + 3, MEMCOL + 19, 9); - putint(pgtokb(total.t_vmshr), MEMROW + 3, MEMCOL + 28, 9); + putint(total.t_vm/1024, MEMROW + 3, MEMCOL + 19, 9); + putint(total.t_vmshr/1024, MEMROW + 3, MEMCOL + 28, 9); putint(pgtokb(total.t_free), MEMROW + 2, MEMCOL + 37, 8); putint(total.t_rq - 1, PROCSROW + 1, PROCSCOL + 3, 3); putint(total.t_pw, PROCSROW + 1, PROCSCOL + 6, 3); %%% Cheers, -- Ruslan Ermilov ru@FreeBSD.org FreeBSD committer -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20061116/74aa61f2/attachment.pgp
The change to vm_meter.c is ok. Could you please add a comment like that above the location of the patch. Alan
Ruslan Ermilov
2006-Nov-20 16:24 UTC
systat -vm output showing negative total virtual memory
On Sun, Nov 19, 2006 at 04:10:35PM -0600, Alan Cox wrote:> The change to vm_meter.c is ok. Could you please add a comment like > that above the location of the patch. >Done, thanks! Cheers, -- Ruslan Ermilov ru@FreeBSD.org FreeBSD committer -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20061120/3c34dd48/attachment.pgp