Invalid memory stats from vmstat and sysctl vm.vmtotal?

2011-11-30 Thread Steven Hartland

We're seeing some impossible memory usage stats reported on machines
here from vmstat and sysctl vm.vmtotal.

We have machines reporting to be using 31GB total when they only have
8GB physical and are not using any swap.

Here's an output from one of our machines:-
vmstat -c 2 -w 1 -n 0 
procs  memory  page  faults cpu

r b w avmfre   flt  re  pi  pofr  sr   in   sy   cs us sy id
0 0 0  31768M  2112M   586   0   0   0   421   0  106  270  569  0  6 94
0 0 0  31768M  2112M 2   0   0   0 0   0  370 8139 3996  0  1 99

The raw output is:-
vmstat -c 2 -w 1 -n 0 -H
procs  memory  page  faults cpu
r b w avmfre   flt  re  pi  pofr  sr   in   sy   cs us sy id
0 0 0 32530228  2162524   586   0   0   0   421   0  106  270  569  0  6 94
0 0 0 32530228  2162524 2   0   0   0 0   0  286 8234 4347  0  1 99

Top shows:-
last pid:  6665;  load averages:  0.00,  0.00, 0.01 up 80+01:24:12  09:35:28
1893 processes:1 running, 1892 sleeping
CPU:  0.0% user,  0.0% nice,  0.3% system,  0.0% interrupt, 99.7% idle
Mem: 3754M Active, 84M Inact, 1976M Wired, 4K Cache, 2109M Free
Swap: 4096M Total, 4096M Free

sysctl vm.vmtotal
vm.vmtotal: 
System wide totals computed every five seconds: (values in kilobytes)

===
Processes:  (RUNQ: 1 Disk Wait: 0 Page Wait: 0 Sleep: 1893)
Virtual Memory: (Total: 1106403532K Active: 32540260K)
Real Memory:(Total: 4563648K Active: 3921644K)
Shared Virtual Memory:  (Total: 19976K Active: 16396K)
Shared Real Memory: (Total: 9040K Active: 8436K)
Free Memory Pages:  2161740K

As mentioned this machine has 8GB of ram and according to both top and
swapinfo is using no swap at all


From dmesg:-

real memory  = 8589934592 (8192 MB)
avail memory = 823536 (7873 MB)

swapinfo
Device  1K-blocks UsedAvail Capacity
/dev/gptid/09f211f7-39ce-11e0-8   41943040  4194304 0%

uname -a
FreeBSD test 8.2-RELEASE FreeBSD 8.2-RELEASE #2: Thu Mar 24 17:28:55 UTC 2011   
  root@test:/usr/obj/usr/src/sys/MULTIPLAY  amd64

sysctl hw.pagesize
hw.pagesize: 4096

It looks like it may be out by a factor of 4, possibly due to the fact
the its a 4k page size not 1k as indicated by the vmstat man page:-

memory  Information about the usage of virtual and real memory.  Virtual
pages (reported in units of 1024 bytes) are considered active if
they belong to processes which are running or have run in the
last 20 seconds.

avm active virtual pages
fre size of the free list


Totalling up RSS from ps axo rss gives a total in the region of that if
the vm stats are out by a factor of 4, in this case it should be: 8132557
which is 7.75GB a much more realistic value.

Am I totally missing something or is there problem here?

   Regards
   Steve


This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. 


In the event of misdirection, illegible or incomplete transmission please 
telephone +44 845 868 1337
or return the E.mail to postmas...@multiplay.co.uk.

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: sysctl description spillover and also setting the sysctl ?

2011-11-30 Thread John Baldwin
On Friday, November 25, 2011 2:36:30 am Jason Hellenthal wrote:
 
 Found a troubling result of the following and figured someone might want to 
take a look.
 
 Pay close attention to the output and behavior.
 
 sysctl net.inet.udp.blackhole=0
 sysctl net.inet.udp.blackhole
 sysctl -d net.inet.udp.blackhole=1
 sysctl net.inet.udp.blackhole
 
 
 Is this expected ? should it not just display the description instead of 
adjusting ? as well not display the description like it is adjusting the 
description too ?

Hah, cute.  It should probably fail with an error if you do something like 
that, yes.

-- 
John Baldwin
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: sysctl description spillover and also setting the sysctl ?

2011-11-30 Thread Jason Hellenthal


On Wed, Nov 30, 2011 at 11:52:46AM -0500, John Baldwin wrote:
 On Friday, November 25, 2011 2:36:30 am Jason Hellenthal wrote:
  
  Found a troubling result of the following and figured someone might want to 
 take a look.
  
  Pay close attention to the output and behavior.
  
  sysctl net.inet.udp.blackhole=0
  sysctl net.inet.udp.blackhole
  sysctl -d net.inet.udp.blackhole=1
  sysctl net.inet.udp.blackhole
  
  
  Is this expected ? should it not just display the description instead of 
 adjusting ? as well not display the description like it is adjusting the 
 description too ?
 
 Hah, cute.  It should probably fail with an error if you do something like 
 that, yes.
 

Yeah thats what I thought about it to but the more I thought about it, if it 
just displayed the values changing instead of the description when =N is 
supplied I think that would be acceptable to. 0 - 1 in this case. Or possibly 
sys.oid: 0 - 1 # Description since sysctl.conf(5) also takes comments like 
that.

Not really thats something at the top of the list for fixes though. Low fruit. 
Food for thought.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


[CFT] pkgng alpha2

2011-11-30 Thread Julien Laffaye

Hi all,

We are releasing pkgng (the next pkg_install) alpha2 to the world and we 
want you to test it!

There is no good method to test it: use it as you would in the real
world. Of course, you are encouraged to backup your data or test it in some
kind of virtualized environment.
After using it for some time, you will certainly find bugs. You can 
report them
on the issues tracker [1]. If you find missing features, that is things 
you can't do

with pkgng but can with pkg_install, you can also report
them. New features are not the expected outcome of this call, as we want to
release a final version ASAP.
FYI, an alpha3 should follow shortly to fix issues in alpha3 and test
additional features. After that, there will be a feature freeze with beta1.

Getting started:
You can download or git clone the source code of pkgng on the github 
page [2].

Then, a boring `make' followed by `make install' will do it.
If you have some packages installed by pkg_add, you can convert the old
database to the pkgng database with the 'pkg2ng' shell script in the ports/
folder.
You can also add packages from the ports tree (with bsd.pkgng.mk) or with
a pkgng repository. All is documented in the README and manpages.
If you are a newcomer to pkgng, this doc reading step is also valuable 
to us.

Indeed, if you fight to get the right infos, or if some things feel counter
intuitive, we should improve it!

Which brings me to the topic of contributing to pkgng.
The best thing you can do is to write down the documentation you would 
have loved

to read while testing pkgng!
And of course, if you have a patch with your bug report, it is much
appreciated.

If you read this entire mail and wonder what is this pkgng thing, you 
can read
the wiki page [3], bapt's presentation from BSDCan [4], EuroBSDCon [5] 
[6] and browse the source code.


Regards,
Julien, on behalf of the pkgng team.

And remember, we _do_ want to hear back from you!
Please also note that it is still alpha code and it can kill kitten and
puppies. You are warned ;-)

[1] : https://github.com/pkgng/pkgng/issues
[2] : https://github.com/pkgng/pkgng
[3] : http://wiki.freebsd.org/pkgng
[4] : http://people.freebsd.org/~bapt/pkgng-bsdcan2011.pdf
[5] : 
http://wiki.freebsd.org/201110DevSummit/Ports?action=AttachFiledo=gettarget=pkgng-devsummit.pdf
[6] : 
http://wiki.freebsd.org/201110DevSummit?action=AttachFiledo=gettarget=pkgng-devsummit-track.pdf

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: sysctl description spillover and also setting the sysctl ?

2011-11-30 Thread Damien Fleuriot


On 11/30/11 7:48 PM, Jason Hellenthal wrote:
 
 
 On Wed, Nov 30, 2011 at 11:52:46AM -0500, John Baldwin wrote:
 On Friday, November 25, 2011 2:36:30 am Jason Hellenthal wrote:

 Found a troubling result of the following and figured someone might want to 
 take a look.

 Pay close attention to the output and behavior.

 sysctl net.inet.udp.blackhole=0
 sysctl net.inet.udp.blackhole
 sysctl -d net.inet.udp.blackhole=1
 sysctl net.inet.udp.blackhole


 Is this expected ? should it not just display the description instead of 
 adjusting ? as well not display the description like it is adjusting the 
 description too ?

 Hah, cute.  It should probably fail with an error if you do something like 
 that, yes.

 
 Yeah thats what I thought about it to but the more I thought about it, if it 
 just displayed the values changing instead of the description when =N is 
 supplied I think that would be acceptable to. 0 - 1 in this case. Or 
 possibly sys.oid: 0 - 1 # Description since sysctl.conf(5) also takes 
 comments like that.
 
 Not really thats something at the top of the list for fixes though. Low 
 fruit. Food for thought.



Perhaps you would kindly provide a patch for this ?

I might have a look at it if nobody does, sounds trivial enough that I
might be able to handle it ;)
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: sysctl description spillover and also setting the sysctl ?

2011-11-30 Thread Damien Fleuriot


On 11/30/11 7:48 PM, Jason Hellenthal wrote:
 
 
 On Wed, Nov 30, 2011 at 11:52:46AM -0500, John Baldwin wrote:
 On Friday, November 25, 2011 2:36:30 am Jason Hellenthal wrote:

 Found a troubling result of the following and figured someone might want to 
 take a look.

 Pay close attention to the output and behavior.

 sysctl net.inet.udp.blackhole=0
 sysctl net.inet.udp.blackhole
 sysctl -d net.inet.udp.blackhole=1
 sysctl net.inet.udp.blackhole


 Is this expected ? should it not just display the description instead of 
 adjusting ? as well not display the description like it is adjusting the 
 description too ?

 Hah, cute.  It should probably fail with an error if you do something like 
 that, yes.

 
 Yeah thats what I thought about it to but the more I thought about it, if it 
 just displayed the values changing instead of the description when =N is 
 supplied I think that would be acceptable to. 0 - 1 in this case. Or 
 possibly sys.oid: 0 - 1 # Description since sysctl.conf(5) also takes 
 comments like that.
 
 Not really thats something at the top of the list for fixes though. Low 
 fruit. Food for thought.






Ok so I'm totally not a dev, don't take my findings for granted, but:



(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /usr/src/sbin/sysctl/sysctl -d net.inet.udp.blackhole=1

Breakpoint 5, show_var (oid=0x7fffe1d0, nlen=4) at
/usr/src/sbin/sysctl/sysctl.c:549
549 {
(gdb) s
562 bzero(buf, BUFSIZ);
(gdb) s
563 bzero(name, BUFSIZ);
(gdb) s
564 qoid[0] = 0;
(gdb) s
565 memcpy(qoid + 2, oid, nlen * sizeof(int));
(gdb) s
567 qoid[1] = 1;
(gdb) s
568 j = sizeof(name);
(gdb) s
569 i = sysctl(qoid, nlen + 2, name, j, 0, 0);
(gdb) s
570 if (i || !j)
(gdb) s
573 if (Nflag) {
(gdb) s
578 if (eflag)
(gdb) s
581 sep = : ;
(gdb) s
583 if (dflag) {/* just print description */
(gdb) s
584 qoid[1] = 5;
(gdb) s
585 j = sizeof(buf);
(gdb) s
586 i = sysctl(qoid, nlen + 2, buf, j, 0, 0);
(gdb) s
587 if (!nflag)
(gdb) s
588 printf(%s%s, name, sep);
(gdb) s
net.inet.udp.blackhole:
589 printf(%s, buf);
(gdb) s
Do not send port unreachables for refused connects
590   return (0);
(gdb) s
719 }


At this point, we have shown the description and should exit.

Instead, we're calling parse() again ?



(gdb) s
parse (string=0x7fffee07 net.inet.udp.blackhole) at
/usr/src/sbin/sysctl/sysctl.c:299
299 if (sysctl(mib, len, 0, 0, newval, newsize) == -1) {
(gdb) s
318 if (!bflag)
(gdb) s
319 printf( - );
(gdb) s
 - 320 i = nflag;
(gdb) s
321 nflag = 1;
(gdb) s
322 j = show_var(mib, len);
(gdb) s


Breakpoint 5, show_var (oid=0x7fffe1d0, nlen=4) at
/usr/src/sbin/sysctl/sysctl.c:549
549 {
(gdb) s
562 bzero(buf, BUFSIZ);
(gdb) s
563 bzero(name, BUFSIZ);
(gdb) s
564 qoid[0] = 0;
(gdb) s
565 memcpy(qoid + 2, oid, nlen * sizeof(int));
(gdb) s
567 qoid[1] = 1;
(gdb) s
568 j = sizeof(name);
(gdb) s
569 i = sysctl(qoid, nlen + 2, name, j, 0, 0);
(gdb) s
570 if (i || !j)
(gdb) s
573 if (Nflag) {
(gdb) s
578 if (eflag)
(gdb) s
581 sep = : ;
(gdb) s
583 if (dflag) {/* just print description */
(gdb) s
584 qoid[1] = 5;
(gdb) s
585 j = sizeof(buf);
(gdb) s
586 i = sysctl(qoid, nlen + 2, buf, j, 0, 0);
(gdb) s
587 if (!nflag)
(gdb) s
589 printf(%s, buf);
(gdb) s
Do not send port unreachables for refused connects
590   return (0);
(gdb) s
719 }
(gdb) s
parse (string=0x7fffee07 net.inet.udp.blackhole) at
/usr/src/sbin/sysctl/sysctl.c:323
323 if (!j  !bflag)
(gdb) s
324 putchar('\n');
(gdb) s
__sputc (_c=10, _p=0x80085a810) at stdio.h:457
457 if (--_p-_w = 0 || (_p-_w = _p-_lbfsize  (char)_c
!= '\n'))
(gdb) s
460 return (__swbuf(_c, _p));
(gdb) s

461 }
(gdb) s
parse (string=0x7fffee07 net.inet.udp.blackhole) at
/usr/src/sbin/sysctl/sysctl.c:325
325 nflag = i;
(gdb) s
327 }
(gdb) s
main (argc=0, argv=0x7fffeb48) at /usr/src/sbin/sysctl/sysctl.c:154
154 while (argc--  0)
(gdb) s
156 exit(warncount);
(gdb) s

Program exited normally.





I think that the issue here is that sysctl continues being run after
displaying the description at line 588.

I would assume that upon reaching the closing hyphen at line 719 ,

Re: Invalid memory stats from vmstat and sysctl vm.vmtotal?

2011-11-30 Thread Jason Hellenthal


On Wed, Nov 30, 2011 at 12:39:10PM -, Steven Hartland wrote:
 We're seeing some impossible memory usage stats reported on machines
 here from vmstat and sysctl vm.vmtotal.
 
 We have machines reporting to be using 31GB total when they only have
 8GB physical and are not using any swap.
 
 Here's an output from one of our machines:-
 vmstat -c 2 -w 1 -n 0 
  procs  memory  page  faults cpu
  r b w avmfre   flt  re  pi  pofr  sr   in   sy   cs us sy id
  0 0 0  31768M  2112M   586   0   0   0   421   0  106  270  569  0  6 94
  0 0 0  31768M  2112M 2   0   0   0 0   0  370 8139 3996  0  1 99
 
 The raw output is:-
 vmstat -c 2 -w 1 -n 0 -H
  procs  memory  page  faults cpu
  r b w avmfre   flt  re  pi  pofr  sr   in   sy   cs us sy id
  0 0 0 32530228  2162524   586   0   0   0   421   0  106  270  569  0  6 94
  0 0 0 32530228  2162524 2   0   0   0 0   0  286 8234 4347  0  1 99
 
 Top shows:-
 last pid:  6665;  load averages:  0.00,  0.00, 0.01 up 80+01:24:12  09:35:28
 1893 processes:1 running, 1892 sleeping
 CPU:  0.0% user,  0.0% nice,  0.3% system,  0.0% interrupt, 99.7% idle
 Mem: 3754M Active, 84M Inact, 1976M Wired, 4K Cache, 2109M Free
 Swap: 4096M Total, 4096M Free
 
 sysctl vm.vmtotal
 vm.vmtotal: 
 System wide totals computed every five seconds: (values in kilobytes)
 ===
 Processes:  (RUNQ: 1 Disk Wait: 0 Page Wait: 0 Sleep: 1893)
 Virtual Memory: (Total: 1106403532K Active: 32540260K)
 Real Memory:(Total: 4563648K Active: 3921644K)
 Shared Virtual Memory:  (Total: 19976K Active: 16396K)
 Shared Real Memory: (Total: 9040K Active: 8436K)
 Free Memory Pages:  2161740K
 
 As mentioned this machine has 8GB of ram and according to both top and
 swapinfo is using no swap at all
 
 From dmesg:-
 real memory  = 8589934592 (8192 MB)
 avail memory = 823536 (7873 MB)
 
 swapinfo
 Device  1K-blocks UsedAvail Capacity
 /dev/gptid/09f211f7-39ce-11e0-8   41943040  4194304 0%
 
 uname -a
 FreeBSD test 8.2-RELEASE FreeBSD 8.2-RELEASE #2: Thu Mar 24 17:28:55 UTC 2011 
 root@test:/usr/obj/usr/src/sys/MULTIPLAY  amd64
 
 sysctl hw.pagesize
 hw.pagesize: 4096
 
 It looks like it may be out by a factor of 4, possibly due to the fact
 the its a 4k page size not 1k as indicated by the vmstat man page:-
 
 memory  Information about the usage of virtual and real memory.  Virtual
  pages (reported in units of 1024 bytes) are considered active if
  they belong to processes which are running or have run in the
  last 20 seconds.
 
  avm active virtual pages
  fre size of the free list
 
 
 Totalling up RSS from ps axo rss gives a total in the region of that if
 the vm stats are out by a factor of 4, in this case it should be: 8132557
 which is 7.75GB a much more realistic value.
 
 Am I totally missing something or is there problem here?
 
 Regards
 Steve
 

This goes along with the thoughts I had about 4 months ago tending to some zfs 
statistics as well top showing greater than 100% actual CPU usage. This is a 
big pet peave of mine. Its like saying you ate 134% of a bannanna when in all 
reallity it is impossible. You can never have more than 100% usage of anything 
and when seen is a clear notice that some math is considerably incorrect 
leading to other such miscalculations to be performed. Things like the above 
already have checks in place that ensure no boundries are being 
crossed/overflowed or underrun but it surely makes processing results building 
future products a bitch. One instance is the calculation of threads for example 
firefox can be seen using upto or more 338% of the CPU. Thats impossible its 
like saying anyones CPU grew by 400%.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org