Re: add protection metrics of zoneinfo

"Nathan Scott" <[email protected]> Thu, 26 Jan 2017 19:45:12 -0500 (EST)
Newsgroups gmane.comp.sysutils.pcp
Message-ID <[email protected]>
Hi Liming,

----- Original Message -----
> Hi:
>    
>    These 2 patch add protection metrics of zoneinfoto linux pmda.
>    And add the protection's regression test.
>    please refer to the attachment for the details.
> 

The patch is close but not quite ideal yet I think.  The proc_zoneinfo.c
code is assuming 4 elements in the array of values, and assigning each to
a new metric (mem.zoneinfo.protection1-4).

Sometimes there are not 4 elements in the array, however - it depends on
the hardware platform, and the kernel build configuration.  On my x86_64
laptop for example:

$ cat /proc/zoneinfo  | grep protection | head -1
        protection: (0, 1583, 15639, 15639, 15639)

That's because the Linux kernel code is like this (mm/vmstat.c):

        seq_printf(m,
                   "\n        protection: (%ld",
                   zone->lowmem_reserve[0]);
        for (i = 1; i < ARRAY_SIZE(zone->lowmem_reserve); i++)
                seq_printf(m, ", %ld", zone->lowmem_reserve[i]);
        seq_printf(m,
                   ")"
                   [...]

A more flexible approach will be to create a single metric with a new
instance domain (just for this metric), so that we can represent any
lowmem_reserved array size and export all of the protected values as:

$ pminfo -f mem.zoneinfo

mem.zoneinfo.free
    inst [0 or "DMA::node0"] value 15884
    inst [1 or "DMA32::node0"] value 342584
    inst [2 or "Normal::node0"] value 268976

[...]

mem.zoneinfo.protected
    inst [0 or "DMA::node0::lowmem_reserved0"] value 0
    inst [1 or "DMA::node0::lowmem_reserved1"] value 1583
    inst [2 or "DMA::node0::lowmem_reserved2"] value 15639
    inst [3 or "DMA::node0::lowmem_reserved3"] value 15639
    inst [4 or "DMA::node0::lowmem_reserved4"] value 15639
    inst [5 or "DMA32::node0::lowmem_reserved0"] value 0
    inst [6 or "DMA32::node0::lowmem_reserved1"] value 0
    inst [7 or "DMA32::node0::lowmem_reserved2"] value 0
    inst [8 or "DMA32::node0::lowmem_reserved3"] value 0
    inst [9 or "DMA32::node0::lowmem_reserved4"] value 0
    inst [10 or "Normal::node0::lowmem_reserved0"] value 0
    inst [11 or "Normal::node0::lowmem_reserved1"] value 0
    [...]


And instead of scanning like this in src/pmdas/linux/proc_zoneinfo.c

            else if ((sscanf(buf, "        protection: (%llu, %llu, %llu, %llu)",
                      &value, &value1, &value2, &value3)) == 4) {
                 [...]
            }

it will need to cope with the varying array length; something like:

            else if (strncmp(buf, "        protection: (", 20) == 0) {
                char protected_name[64];
                char *endp, *bp = buf + 20 + 1;
                int  value, index = 0;

                for (index = 0;; index++) {
                    value = strtoul(bp, &endp, 10);
                    sprintf(protected_name, "%s::lowmem_reserved%d", instname, index);
                    pmdaCacheStore(zoneinfo_protected_indom, PMDA_CACHE_ADD, protected_name, (void *)value);
                    if (*endp != ',')
                        break;
                    bp = endp + 2;   /* skip comma and space, then continue */
                 }
            }


cheers.

--
Nathan

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#15037): https://groups.io/g/pcp/message/15037
View All Messages In Topic (2): https://groups.io/g/pcp/topic/4253203
Mute This Topic: https://groups.io/mt/4253203?uid=174580
New Topic: https://groups.io/g/pcp/post
-=-=-
pcp mailing list
[email protected]
https://groups.io/g/pcp/messages
-=-=-
Change Your Subscription: https://groups.io/g/pcp/editsub?uid=174580
Group Home: https://groups.io/g/pcp
Contact Group Owner: [email protected]
Terms of Service: https://groups.io/static/tos
Unsubscribe: https://groups.io/g/pcp/leave/354243/563757577/xyzzy
-=-=-=-=-=-=-=-=-=-=-=-