Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Aug 2012 09:09:17 -0700
From:      Patrick Mahan <PMahan@adaranet.com>
To:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Need some explanation on a field in struct vmtotal
Message-ID:  <DA0D02C15AF8CF408F8A03D8FE5AD16C1777FDDA@SJ-EXCH-1.adaranet.com>

next in thread | raw e-mail | index | archive | help
All,

I'm trying to determine if this is a bug or for real.  We have a customer t=
hat pointed his
NMS at our appliance (running FBSD 9.0).  These are 64-bit intel platforms =
(8 core Xeons)
with 8 Gbytes of RAM and a 16 Gbyte swap.

The customer claims that the NMS shows him that these boxes have a tetrabyt=
e of VM, which
surprised him somewhat.  These platforms are using net-snmp 5.7.1 out of th=
e ports tree.

I did an snmpget query on one of our boxes here in our lab and saw the foll=
owing:

comet1# snmpget -v2c -c public localhost hrMemorySize.0
HOST-RESOURCES-MIB::hrMemorySize.0 =3D INTEGER: 8351368 KBytes


SNMP table: HOST-RESOURCES-MIB::hrStorageTable

hrStorageIndex   hrStorageType  hrStorageDescr hrStorageAllocationUnits hrS=
torageSize hrStorageUsed hrStorageAllocationFailures

...

     3  HOST-RESOURCES-TYPES::hrStorageVirtualMemory Virtual memory   4096 =
Bytes     269040967     268460681          0

My understanding is that the 'hrStorageSize' is in 'hrStorageAllocationUnit=
s', so the total
byte size should be=20

    4096 x 269040967 =3D 1085607800832

Now, I have looked at the net-snmp code for retrieving this value and it se=
ems to be=20
via a sysctl to vm.vmtotal.  This value is the field t_vm in the vmtotal st=
ructure
(defined in sys/sys/vmmeter.h).

Looking at the code in sys/vm/vm_meter.c I see the following:

        TAILQ_FOREACH(object, &vm_object_list, object_list) {
                /*
                 * Perform unsynchronized reads on the object to avoid
                 * a lock-order reversal.  In this case, the lack of
                 * synchronization should not impair the accuracy of
                 * the reported statistics.
                 */
                if (object->type =3D=3D OBJT_DEVICE || object->type =3D=3D =
OBJT_SG) {
                        /*
                         * Devices, like /dev/mem, will badly skew our tota=
ls.
                         */
                        continue;
                }
                if (object->ref_count =3D=3D 0) {
                        /*
                         * Also skip unreferenced objects, including
                         * vnodes representing mounted file systems.
                         */
                        continue;
                }
                total.t_vm +=3D object->size;

But I cannot find any description of what object->size is defined.  The
vm_object structure is defined in vm/vm_object.h as type vm_pindex_t.

Which is an architecturally defined in <machine>/_types.h (for amd64 this
is defined as __uint64_t.

My FreeBSD internals (McKusick's book) for 5.5 doesn't seem to reference it=
.

So my question is -  Is the object->size in bytes?  If this is so, then
total.t_vm is in bytes and net-snmp is using that value unmodified.  Instea=
d
it should divide that value by 4096 and report that number instead?

Or is my understanding screwed up here?

Thanks,

Patrick
----------------------------------------------------
Patrick Mahan
Lead Technical Kernel Engineer
Adara Networks
Disclaimer: The opinions expressed here are solely the responsibility of th=
e author and are not to be
construed as an official opinion of Adara Networks.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DA0D02C15AF8CF408F8A03D8FE5AD16C1777FDDA>