From 1c559713ebc5c02759de59013066c3d29e4395e4 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Mon, 13 Nov 2023 15:57:15 +1100 Subject: [PATCH 1/4] pmdalinux: additional mem.util metrics from recent Linux kernel versions Ten additional Linux kernel /proc/meminfo memory metrics relating to new aspects of hugepages, the contiguous and percpu memory allocators, zswap, shadow call stacks and unaccepted memory. --- qa/821.out | 231 +++++++++++++++++++++++++++++++++ src/pmdas/linux/help | 23 +++- src/pmdas/linux/pmda.c | 114 +++++++++++++++- src/pmdas/linux/proc_meminfo.c | 11 ++ src/pmdas/linux/proc_meminfo.h | 12 ++ src/pmdas/linux/root_linux | 11 ++ 6 files changed, 399 insertions(+), 3 deletions(-) diff --git a/qa/821.out b/qa/821.out index a848304849..799aa0a85d 100644 --- a/qa/821.out +++ b/qa/821.out @@ -287,6 +287,12 @@ mem.util.cache_clean mem.util.cached value 7628228 +mem.util.cmafree + value 0 + +mem.util.cmatotal + value 0 + mem.util.commitLimit value 16071992 @@ -308,6 +314,12 @@ mem.util.directMap4k mem.util.dirty value 172 +mem.util.filehugepages +No value(s) available! + +mem.util.filepmdmapped +No value(s) available! + mem.util.free value 4650860 @@ -374,18 +386,30 @@ mem.util.other mem.util.pageTables value 55928 +mem.util.percpu +No value(s) available! + mem.util.quicklists No value(s) available! mem.util.reverseMaps No value(s) available! +mem.util.shadowcallstack +No value(s) available! + mem.util.shared No value(s) available! mem.util.shmem value 406288 +mem.util.shmemhugepages +No value(s) available! + +mem.util.shmempmdmapped +No value(s) available! + mem.util.slab value 1339256 @@ -404,6 +428,9 @@ mem.util.swapFree mem.util.swapTotal value 8060924 +mem.util.unaccepted +No value(s) available! + mem.util.unevictable value 16 @@ -422,6 +449,12 @@ mem.util.vmallocUsed mem.util.writeback value 0 +mem.util.zswap +No value(s) available! + +mem.util.zswapped +No value(s) available! + mem.vmstat.allocstall value 0 @@ -3033,6 +3066,12 @@ mem.util.cache_clean mem.util.cached value 31228980 +mem.util.cmafree +No value(s) available! + +mem.util.cmatotal +No value(s) available! + mem.util.commitLimit value 70109824 @@ -3054,6 +3093,12 @@ mem.util.directMap4k mem.util.dirty value 8 +mem.util.filehugepages +No value(s) available! + +mem.util.filepmdmapped +No value(s) available! + mem.util.free value 87287012 @@ -3120,18 +3165,30 @@ mem.util.other mem.util.pageTables value 40644 +mem.util.percpu +No value(s) available! + mem.util.quicklists No value(s) available! mem.util.reverseMaps No value(s) available! +mem.util.shadowcallstack +No value(s) available! + mem.util.shared No value(s) available! mem.util.shmem value 1001280 +mem.util.shmemhugepages +No value(s) available! + +mem.util.shmempmdmapped +No value(s) available! + mem.util.slab value 1452008 @@ -3150,6 +3207,9 @@ mem.util.swapFree mem.util.swapTotal value 4194300 +mem.util.unaccepted +No value(s) available! + mem.util.unevictable value 149708 @@ -3168,6 +3228,12 @@ mem.util.vmallocUsed mem.util.writeback value 0 +mem.util.zswap +No value(s) available! + +mem.util.zswapped +No value(s) available! + mem.vmstat.allocstall value 0 @@ -5757,6 +5823,12 @@ mem.util.cache_clean mem.util.cached value 31228980 +mem.util.cmafree +No value(s) available! + +mem.util.cmatotal +No value(s) available! + mem.util.commitLimit value 70109824 @@ -5778,6 +5850,12 @@ mem.util.directMap4k mem.util.dirty value 8 +mem.util.filehugepages +No value(s) available! + +mem.util.filepmdmapped +No value(s) available! + mem.util.free value 87287012 @@ -5844,18 +5922,30 @@ mem.util.other mem.util.pageTables value 40644 +mem.util.percpu +No value(s) available! + mem.util.quicklists No value(s) available! mem.util.reverseMaps No value(s) available! +mem.util.shadowcallstack +No value(s) available! + mem.util.shared No value(s) available! mem.util.shmem value 1001280 +mem.util.shmemhugepages +No value(s) available! + +mem.util.shmempmdmapped +No value(s) available! + mem.util.slab value 1452008 @@ -5874,6 +5964,9 @@ mem.util.swapFree mem.util.swapTotal value 4194300 +mem.util.unaccepted +No value(s) available! + mem.util.unevictable value 149708 @@ -5892,6 +5985,12 @@ mem.util.vmallocUsed mem.util.writeback value 4 +mem.util.zswap +No value(s) available! + +mem.util.zswapped +No value(s) available! + mem.vmstat.allocstall value 0 @@ -8444,6 +8543,12 @@ mem.util.cache_clean mem.util.cached value 281572 +mem.util.cmafree + value 0 + +mem.util.cmatotal + value 0 + mem.util.commitLimit value 4631924 @@ -8465,6 +8570,12 @@ mem.util.directMap4k mem.util.dirty value 0 +mem.util.filehugepages +No value(s) available! + +mem.util.filepmdmapped +No value(s) available! + mem.util.free value 3264460 @@ -8531,18 +8642,30 @@ mem.util.other mem.util.pageTables value 20784 +mem.util.percpu +No value(s) available! + mem.util.quicklists No value(s) available! mem.util.reverseMaps No value(s) available! +mem.util.shadowcallstack +No value(s) available! + mem.util.shared No value(s) available! mem.util.shmem value 1340 +mem.util.shmemhugepages + value 0 + +mem.util.shmempmdmapped + value 0 + mem.util.slab value 109736 @@ -8561,6 +8684,9 @@ mem.util.swapFree mem.util.swapTotal value 2621436 +mem.util.unaccepted +No value(s) available! + mem.util.unevictable value 0 @@ -8579,6 +8705,12 @@ mem.util.vmallocUsed mem.util.writeback value 0 +mem.util.zswap +No value(s) available! + +mem.util.zswapped +No value(s) available! + mem.vmstat.allocstall No value(s) available! @@ -10899,6 +11031,12 @@ mem.util.cache_clean mem.util.cached value 7246776 +mem.util.cmafree + value 0 + +mem.util.cmatotal + value 0 + mem.util.commitLimit value 16119160 @@ -10920,6 +11058,12 @@ mem.util.directMap4k mem.util.dirty value 1724 +mem.util.filehugepages +No value(s) available! + +mem.util.filepmdmapped +No value(s) available! + mem.util.free value 2496772 @@ -10986,18 +11130,30 @@ mem.util.other mem.util.pageTables value 94572 +mem.util.percpu +No value(s) available! + mem.util.quicklists No value(s) available! mem.util.reverseMaps No value(s) available! +mem.util.shadowcallstack +No value(s) available! + mem.util.shared No value(s) available! mem.util.shmem value 978508 +mem.util.shmemhugepages + value 0 + +mem.util.shmempmdmapped + value 0 + mem.util.slab value 694056 @@ -11016,6 +11172,9 @@ mem.util.swapFree mem.util.swapTotal value 8093692 +mem.util.unaccepted +No value(s) available! + mem.util.unevictable value 80 @@ -11034,6 +11193,12 @@ mem.util.vmallocUsed mem.util.writeback value 0 +mem.util.zswap +No value(s) available! + +mem.util.zswapped +No value(s) available! + mem.vmstat.allocstall No value(s) available! @@ -13418,6 +13583,12 @@ mem.util.cache_clean mem.util.cached value 708152 +mem.util.cmafree +No value(s) available! + +mem.util.cmatotal +No value(s) available! + mem.util.commitLimit value 5081520 @@ -13439,6 +13610,12 @@ mem.util.directMap4k mem.util.dirty value 16 +mem.util.filehugepages +No value(s) available! + +mem.util.filepmdmapped +No value(s) available! + mem.util.free value 2524972 @@ -13505,18 +13682,30 @@ mem.util.other mem.util.pageTables value 8848 +mem.util.percpu +No value(s) available! + mem.util.quicklists No value(s) available! mem.util.reverseMaps No value(s) available! +mem.util.shadowcallstack +No value(s) available! + mem.util.shared No value(s) available! mem.util.shmem value 202696 +mem.util.shmemhugepages + value 0 + +mem.util.shmempmdmapped + value 0 + mem.util.slab value 425060 @@ -13535,6 +13724,9 @@ mem.util.swapFree mem.util.swapTotal value 3145724 +mem.util.unaccepted +No value(s) available! + mem.util.unevictable value 0 @@ -13553,6 +13745,12 @@ mem.util.vmallocUsed mem.util.writeback value 0 +mem.util.zswap +No value(s) available! + +mem.util.zswapped +No value(s) available! + mem.vmstat.allocstall No value(s) available! @@ -15246,6 +15444,12 @@ mem.util.cache_clean mem.util.cached value 3194544 +mem.util.cmafree + value 0 + +mem.util.cmatotal + value 0 + mem.util.commitLimit value 12211660 @@ -15267,6 +15471,12 @@ mem.util.directMap4k mem.util.dirty value 0 +mem.util.filehugepages + value 0 + +mem.util.filepmdmapped + value 0 + mem.util.free value 4211712 @@ -15333,18 +15543,30 @@ mem.util.other mem.util.pageTables value 4072 +mem.util.percpu + value 5280 + mem.util.quicklists No value(s) available! mem.util.reverseMaps No value(s) available! +mem.util.shadowcallstack +No value(s) available! + mem.util.shared No value(s) available! mem.util.shmem value 1148 +mem.util.shmemhugepages + value 0 + +mem.util.shmempmdmapped + value 0 + mem.util.slab value 298464 @@ -15363,6 +15585,9 @@ mem.util.swapFree mem.util.swapTotal value 8140796 +mem.util.unaccepted +No value(s) available! + mem.util.unevictable value 0 @@ -15381,6 +15606,12 @@ mem.util.vmallocUsed mem.util.writeback value 0 +mem.util.zswap +No value(s) available! + +mem.util.zswapped +No value(s) available! + mem.vmstat.allocstall No value(s) available! diff --git a/src/pmdas/linux/help b/src/pmdas/linux/help index 3e0b2e24cf..9485318a19 100644 --- a/src/pmdas/linux/help +++ b/src/pmdas/linux/help @@ -962,8 +962,29 @@ you will get real memory on demand, and just as much as you use. @ mem.util.hugepagesFreeBytes amount of memory in free hugepages @ mem.util.hugepagesRsvdBytes amount of memory in reserved hugepages @ mem.util.hugepagesSurpBytes amount of memory in surplus hugepages - User memory (Kbytes) in pages not backed by files, e.g. from malloc() +@ mem.util.shmemhugepages amount of shared memory allocated with hugepages +@ mem.util.shmempmdmapped shared memory mapped into userspace with hugepages +@ mem.util.filehugepages page cache (file) pages allocated with hugepages +@ mem.util.filepmdmapped page cache mapped into userspace with hugepages +@ mem.util.cmatotal total contiguous memory allocator memory +@ mem.util.cmafree free contiguous memory allocator memory +@ mem.util.unaccepted amount of unaccepted memory +When this mechanism is in use, a virtual machine can be launched with +its memory in an unaccepted state. Such a system will not be able to +make use of the memory provided until that memory has been explicitly +accepted. On these systems, the bootloader will typically pre-accept +enough memory to allow the guest kernel to boot then that kernel must +take responsibility for accepting the rest before using it. +@ mem.util.zswap total size of the zswap memory pool +@ mem.util.zswapped current memory used from the zswap memory pool +@ mem.util.shadowcallstack memory used for shadown call stacks +Shadow stacks are a modern security feature allowing for detection of +corruption of the call stack, allowing the kernel to react to such an +attach in an appropriate fashion. Shadow stacks are often maintained +by the processor hardware and require additional stack memory. +@ mem.util.percpu amount of per CPU allocator memory + @ mem.numa.util.total per-node total memory @ mem.numa.util.free per-node free memory @ mem.numa.util.used per-node used memory diff --git a/src/pmdas/linux/pmda.c b/src/pmdas/linux/pmda.c index dfba8e8954..98d66748e7 100644 --- a/src/pmdas/linux/pmda.c +++ b/src/pmdas/linux/pmda.c @@ -1093,7 +1093,7 @@ static pmdaMetric metrictab[] = { { PMDA_PMID(CLUSTER_MEMINFO,55), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, -/* mem.util.mmap_copy */ +/* mem.util.anonhugepages */ { NULL, { PMDA_PMID(CLUSTER_MEMINFO,56), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, @@ -1133,6 +1133,61 @@ static pmdaMetric metrictab[] = { { PMDA_PMID(CLUSTER_MEMINFO,63), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, PMDA_PMUNITS(1,0,0,PM_SPACE_BYTE,0,0) }, }, +/* mem.util.shmemhugepages */ + { NULL, + { PMDA_PMID(CLUSTER_MEMINFO,64), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, + PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, + +/* mem.util.shmempmdmapped */ + { NULL, + { PMDA_PMID(CLUSTER_MEMINFO,65), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, + PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, + +/* mem.util.filehugepages */ + { NULL, + { PMDA_PMID(CLUSTER_MEMINFO,66), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, + PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, + +/* mem.util.filepmdmapped */ + { NULL, + { PMDA_PMID(CLUSTER_MEMINFO,67), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, + PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, + +/* mem.util.cmatotal */ + { NULL, + { PMDA_PMID(CLUSTER_MEMINFO,68), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, + PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, + +/* mem.util.cmafree */ + { NULL, + { PMDA_PMID(CLUSTER_MEMINFO,69), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, + PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, + +/* mem.util.unaccepted */ + { NULL, + { PMDA_PMID(CLUSTER_MEMINFO,70), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, + PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, + +/* mem.util.zswap */ + { NULL, + { PMDA_PMID(CLUSTER_MEMINFO,71), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, + PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, + +/* mem.util.zswapped */ + { NULL, + { PMDA_PMID(CLUSTER_MEMINFO,72), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, + PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, + +/* mem.util.shadowcallstack */ + { NULL, + { PMDA_PMID(CLUSTER_MEMINFO,73), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, + PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, + +/* mem.util.percpu */ + { NULL, + { PMDA_PMID(CLUSTER_MEMINFO,74), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT, + PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, }, + /* mem.numa.util.total */ { NULL, { PMDA_PMID(CLUSTER_NUMA_MEMINFO,0), PM_TYPE_U64, NODE_INDOM, PM_SEM_INSTANT, @@ -8291,7 +8346,7 @@ linux_fetchCallBack(pmdaMetric *mdesc, unsigned int inst, pmAtomValue *atom) return 0; /* no values available */ atom->ull = proc_meminfo.HardwareCorrupted; break; - case 56: /* mem.util.anonhugepages (in pages) */ + case 56: /* mem.util.anonhugepages (in kbytes) */ if (!MEMINFO_VALID_VALUE(proc_meminfo.AnonHugePages)) return 0; /* no values available */ atom->ull = proc_meminfo.AnonHugePages; @@ -8335,6 +8390,61 @@ linux_fetchCallBack(pmdaMetric *mdesc, unsigned int inst, pmAtomValue *atom) atom->ull = proc_meminfo.HugepagesSurp * (proc_meminfo.Hugepagesize << 10); break; + case 64: /* mem.util.shmemhugepages (in kbytes) */ + if (!MEMINFO_VALID_VALUE(proc_meminfo.ShmemHugePages)) + return 0; /* no values available */ + atom->ull = proc_meminfo.ShmemHugePages; + break; + case 65: /* mem.util.shmempmdmapped (in kbytes) */ + if (!MEMINFO_VALID_VALUE(proc_meminfo.ShmemPmdMapped)) + return 0; /* no values available */ + atom->ull = proc_meminfo.ShmemPmdMapped; + break; + case 66: /* mem.util.filehugepages (in kbytes) */ + if (!MEMINFO_VALID_VALUE(proc_meminfo.FileHugePages)) + return 0; /* no values available */ + atom->ull = proc_meminfo.FileHugePages; + break; + case 67: /* mem.util.filepmdmapped (in kbytes) */ + if (!MEMINFO_VALID_VALUE(proc_meminfo.FilePmdMapped)) + return 0; /* no values available */ + atom->ull = proc_meminfo.FilePmdMapped; + break; + case 68: /* mem.util.cmatotal (in kbytes) */ + if (!MEMINFO_VALID_VALUE(proc_meminfo.CmaTotal)) + return 0; /* no values available */ + atom->ull = proc_meminfo.CmaTotal; + break; + case 69: /* mem.util.cmafree (in kbytes) */ + if (!MEMINFO_VALID_VALUE(proc_meminfo.CmaFree)) + return 0; /* no values available */ + atom->ull = proc_meminfo.CmaFree; + break; + case 70: /* mem.util.unaccepted (in kbytes) */ + if (!MEMINFO_VALID_VALUE(proc_meminfo.Unaccepted)) + return 0; /* no values available */ + atom->ull = proc_meminfo.Unaccepted; + break; + case 71: /* mem.util.zswap (in kbytes) */ + if (!MEMINFO_VALID_VALUE(proc_meminfo.Zswap)) + return 0; /* no values available */ + atom->ull = proc_meminfo.Zswap; + break; + case 72: /* mem.util.zswapped (in kbytes) */ + if (!MEMINFO_VALID_VALUE(proc_meminfo.Zswapped)) + return 0; /* no values available */ + atom->ull = proc_meminfo.Zswapped; + break; + case 73: /* mem.util.shadowcallstack (in kbytes) */ + if (!MEMINFO_VALID_VALUE(proc_meminfo.ShadowCallStack)) + return 0; /* no values available */ + atom->ull = proc_meminfo.ShadowCallStack; + break; + case 74: /* mem.util.percpu (in kbytes) */ + if (!MEMINFO_VALID_VALUE(proc_meminfo.Percpu)) + return 0; /* no values available */ + atom->ull = proc_meminfo.Percpu; + break; default: return PM_ERR_PMID; } diff --git a/src/pmdas/linux/proc_meminfo.c b/src/pmdas/linux/proc_meminfo.c index f7599e259f..7d9f5ce177 100644 --- a/src/pmdas/linux/proc_meminfo.c +++ b/src/pmdas/linux/proc_meminfo.c @@ -47,6 +47,8 @@ static struct { { "MmapCopy", &moff.MmapCopy }, { "SwapTotal", &moff.SwapTotal }, { "SwapFree", &moff.SwapFree }, + { "Zswap", &moff.Zswap }, + { "Zswapped", &moff.Zswapped }, { "Dirty", &moff.Dirty }, { "Writeback", &moff.Writeback }, { "AnonPages", &moff.AnonPages }, @@ -56,6 +58,7 @@ static struct { { "SReclaimable", &moff.SlabReclaimable }, { "SUnreclaim", &moff.SlabUnreclaimable }, { "KernelStack", &moff.KernelStack }, + { "ShadowCallStack", &moff.ShadowCallStack }, { "PageTables", &moff.PageTables }, { "Quicklists", &moff.Quicklists }, { "NFS_Unstable", &moff.NFS_Unstable }, @@ -66,8 +69,16 @@ static struct { { "VmallocTotal", &moff.VmallocTotal }, { "VmallocUsed", &moff.VmallocUsed }, { "VmallocChunk", &moff.VmallocChunk }, + { "Percpu", &moff.Percpu }, { "HardwareCorrupted", &moff.HardwareCorrupted }, { "AnonHugePages", &moff.AnonHugePages }, + { "ShmemHugePages", &moff.ShmemHugePages }, + { "ShmemPmdMapped", &moff.ShmemPmdMapped }, + { "FileHugePages", &moff.FileHugePages }, + { "FilePmdMapped", &moff.FilePmdMapped }, + { "CmaTotal", &moff.CmaTotal }, + { "CmaFree", &moff.CmaFree }, + { "Unaccepted", &moff.Unaccepted }, /* vendor kernel patches, some outdated now */ { "MemShared", &moff.MemShared }, { "ReverseMaps", &moff.ReverseMaps }, diff --git a/src/pmdas/linux/proc_meminfo.h b/src/pmdas/linux/proc_meminfo.h index c35360686b..321594c755 100644 --- a/src/pmdas/linux/proc_meminfo.h +++ b/src/pmdas/linux/proc_meminfo.h @@ -45,6 +45,8 @@ typedef struct { int64_t SwapTotal; int64_t SwapFree; int64_t SwapUsed; /* computed */ + int64_t Zswap; + int64_t Zswapped; int64_t Dirty; int64_t Writeback; int64_t Mapped; @@ -53,6 +55,7 @@ typedef struct { int64_t SlabReclaimable; int64_t SlabUnreclaimable; int64_t KernelStack; + int64_t ShadowCallStack; int64_t CommitLimit; int64_t Committed_AS; int64_t PageTables; @@ -65,8 +68,17 @@ typedef struct { int64_t VmallocTotal; int64_t VmallocUsed; int64_t VmallocChunk; + int64_t Percpu; int64_t HardwareCorrupted; int64_t AnonHugePages; + int64_t ShmemHugePages; + int64_t ShmemPmdMapped; + int64_t FileHugePages; + int64_t FilePmdMapped; + int64_t CmaTotal; + int64_t CmaFree; + int64_t Unaccepted; + /* vendor patches (old) */ int64_t HugepagesTotal; int64_t HugepagesFree; int64_t HugepagesRsvd; diff --git a/src/pmdas/linux/root_linux b/src/pmdas/linux/root_linux index 12edc7f81b..53b3c96835 100644 --- a/src/pmdas/linux/root_linux +++ b/src/pmdas/linux/root_linux @@ -712,6 +712,17 @@ mem.util { hugepagesFreeBytes 60:1:61 hugepagesRsvdBytes 60:1:62 hugepagesSurpBytes 60:1:63 + shmemhugepages 60:1:64 + shmempmdmapped 60:1:65 + filehugepages 60:1:66 + filepmdmapped 60:1:67 + cmatotal 60:1:68 + cmafree 60:1:69 + unaccepted 60:1:70 + zswap 60:1:71 + zswapped 60:1:72 + shadowcallstack 60:1:73 + percpu 60:1:74 } mem.numa { From 54f5f2f254158d77cb684763b495163c2556a963 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Mon, 13 Nov 2023 16:44:19 +1100 Subject: [PATCH 2/4] build: Linux resource control feature is for Intel/AMD processors only Only build pcp-pmda-resctrl with Intel/AMD processors as others cannot make use of this kernel feature. --- build/rpm/GNUmakefile | 1 + build/rpm/pcp.spec.in | 11 ++++++++++- build/rpm/redhat.spec | 18 +++++++++++++++++- configure | 25 +++++++++++++++++++------ configure.ac | 14 +++++++++++--- src/include/builddefs.in | 1 + src/pmdas/resctrl/GNUmakefile | 6 ++++++ 7 files changed, 65 insertions(+), 11 deletions(-) diff --git a/build/rpm/GNUmakefile b/build/rpm/GNUmakefile index 748a8c782c..8451601da9 100644 --- a/build/rpm/GNUmakefile +++ b/build/rpm/GNUmakefile @@ -89,6 +89,7 @@ pcp.spec: pcp.spec.in -e's|@pmda_activemq@|$(PMDA_ACTIVEMQ)|g' \ -e's|@pmda_bind2@|$(PMDA_BIND2)|g' \ -e's|@pmda_nutcracker@|$(PMDA_NUTCRACKER)|g' \ + -e's|@pmda_resctrl@|$(PMDA_RESCTRL)|g' \ -e's|@pcp2xlsx@|$(HAVE_PYTHON_OPENPYXL)|g' \ -e's|@pcp2influxdb@|$(HAVE_PYTHON_INFLUXDB)|g' \ -e's|@pcp2elasticsearch@|$(HAVE_PYTHON_REQUESTS)|g' \ diff --git a/build/rpm/pcp.spec.in b/build/rpm/pcp.spec.in index a4090b6144..e8b5e43385 100755 --- a/build/rpm/pcp.spec.in +++ b/build/rpm/pcp.spec.in @@ -325,7 +325,7 @@ Requires: pcp-pmda-memcache pcp-pmda-named pcp-pmda-netfilter pcp-pmda-news Requires: pcp-pmda-redis pcp-pmda-samba pcp-pmda-slurm pcp-pmda-zimbra %endif Requires: pcp-pmda-apache pcp-pmda-bash pcp-pmda-cisco pcp-pmda-dm pcp-pmda-gfs2 -Requires: pcp-pmda-logger pcp-pmda-mailq pcp-pmda-mounts pcp-pmda-resctrl +Requires: pcp-pmda-logger pcp-pmda-mailq pcp-pmda-mounts Requires: pcp-pmda-nvidia-gpu pcp-pmda-roomtemp pcp-pmda-sendmail pcp-pmda-shping Requires: pcp-pmda-lustrecomm pcp-pmda-docker pcp-pmda-smart pcp-pmda-farm Requires: pcp-pmda-hacluster pcp-pmda-sockets pcp-pmda-podman @@ -394,6 +394,9 @@ Requires: pcp-pmda-elasticsearch %if "@pmda_postfix@" == "true" Requires: pcp-pmda-postfix %endif +%if "@pmda_resctrl@" == "true" +Requires: pcp-pmda-resctrl +%endif Requires: pcp-system-tools %if "@enable_qt@" == "true" Requires: pcp-gui @@ -2043,6 +2046,7 @@ This package contains the PCP Performance Metrics Domain Agent (PMDA) for collecting metrics about Nvidia GPUs. # end pcp-pmda-nvidia-gpu +%if "@pmda_resctrl@" == "true" # # pcp-pmda-resctrl # @@ -2055,6 +2059,7 @@ Requires: pcp = %{version}-%{release} pcp-libs = %{version}-%{release} This package contains the PCP Performance Metric Domain Agent (PMDA) for collecting metrics from the Linux kernel resource control functionality. #end pcp-pmda-resctrl +%endif # # pcp-pmda-roomtemp @@ -2894,8 +2899,10 @@ done %preun pmda-nvidia-gpu %{pmda_remove "$1" "nvidia"} +%if "@pmda_resctrl@" == "true" %preun pmda-resctrl %{pmda_remove "$1" "resctrl"} +%endif %preun pmda-roomtemp %{pmda_remove "$1" "roomtemp"} @@ -3232,7 +3239,9 @@ fi %files pmda-nvidia-gpu -f pcp-pmda-nvidia-files.rpm +%if "@pmda_resctrl@" == "true" %files pmda-resctrl -f pcp-pmda-resctrl-files.rpm +%endif %files pmda-roomtemp -f pcp-pmda-roomtemp-files.rpm diff --git a/build/rpm/redhat.spec b/build/rpm/redhat.spec index 3dd086d48b..922c1ceabf 100644 --- a/build/rpm/redhat.spec +++ b/build/rpm/redhat.spec @@ -48,6 +48,13 @@ ExcludeArch: %{ix86} %endif %endif +# Resource Control kernel feature is on recent Intel/AMD processors only +%ifarch x86_64 +%global disable_resctrl 0 +%else +%global disable_resctrl 1 +%endif + # libchan, libhdr_histogram and pmdastatsd %if 0%{?fedora} >= 29 || 0%{?rhel} > 7 %global disable_statsd 0 @@ -531,7 +538,7 @@ Requires: pcp-pmda-memcache pcp-pmda-mysql pcp-pmda-named pcp-pmda-netfilter pcp Requires: pcp-pmda-nginx pcp-pmda-nfsclient pcp-pmda-pdns pcp-pmda-postfix pcp-pmda-postgresql pcp-pmda-oracle Requires: pcp-pmda-samba pcp-pmda-slurm pcp-pmda-zimbra Requires: pcp-pmda-dm pcp-pmda-apache -Requires: pcp-pmda-bash pcp-pmda-cisco pcp-pmda-gfs2 pcp-pmda-mailq pcp-pmda-mounts pcp-pmda-resctrl +Requires: pcp-pmda-bash pcp-pmda-cisco pcp-pmda-gfs2 pcp-pmda-mailq pcp-pmda-mounts Requires: pcp-pmda-nvidia-gpu pcp-pmda-roomtemp pcp-pmda-sendmail pcp-pmda-shping pcp-pmda-smart pcp-pmda-farm Requires: pcp-pmda-hacluster pcp-pmda-lustrecomm pcp-pmda-logger pcp-pmda-denki pcp-pmda-docker pcp-pmda-bind2 Requires: pcp-pmda-sockets pcp-pmda-podman @@ -568,6 +575,9 @@ Requires: pcp-pmda-snmp %if !%{disable_json} Requires: pcp-pmda-json %endif +%if !%{disable_resctrl} +Requires: pcp-pmda-resctrl +%endif Requires: pcp-pmda-summary pcp-pmda-trace pcp-pmda-weblog Requires: pcp-system-tools %if !%{disable_qt} @@ -2047,6 +2057,7 @@ This package contains the PCP Performance Metrics Domain Agent (PMDA) for collecting metrics about Nvidia GPUs. # end pcp-pmda-nvidia-gpu +%if !%{disable_resctrl} # # pcp-pmda-resctrl # @@ -2059,6 +2070,7 @@ Requires: pcp = %{version}-%{release} pcp-libs = %{version}-%{release} This package contains the PCP Performance Metric Domain Agent (PMDA) for collecting metrics from the Linux kernel resource control functionality. #end pcp-pmda-resctrl +%endif # # pcp-pmda-roomtemp @@ -3010,8 +3022,10 @@ exit 0 %preun pmda-nvidia-gpu %{pmda_remove "$1" "nvidia"} +%if !%{disable_resctrl} %preun pmda-resctrl %{pmda_remove "$1" "resctrl"} +%endif %preun pmda-roomtemp %{pmda_remove "$1" "roomtemp"} @@ -3369,7 +3383,9 @@ fi %files pmda-nvidia-gpu -f pcp-pmda-nvidia-files.rpm +%if !%{disable_resctrl} %files pmda-resctrl -f pcp-pmda-resctrl-files.rpm +%endif %files pmda-roomtemp -f pcp-pmda-roomtemp-files.rpm diff --git a/configure b/configure index 60f734d51f..fc87e67cb5 100755 --- a/configure +++ b/configure @@ -830,6 +830,7 @@ enable_qt qt_version qt_release QMAKE +PMDA_RESCTRL PMDA_LIBVIRT PMDA_MSSQL PMDA_OPENMETRICS @@ -3832,8 +3833,7 @@ then printf "%s\n" "#define IS_DARWIN 1" >>confdefs.h target_distro=macosx - target_machine=`uname -m` - export CFLAGS="-fPIC -no-cpp-precomp -fno-strict-aliasing -arch $target_machine" + export CFLAGS="-fPIC -no-cpp-precomp -fno-strict-aliasing -arch $target_cpu" pcp_platform_paths='/usr/local/bin:/opt/homebrew/bin' pcp_ps_all_flags="-axw -o user,pid,ppid,cpu,stime,tty,time,command" elif test $target_os = mingw @@ -5288,11 +5288,11 @@ if test x$ac_prog_cxx_stdcxx = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5 printf %s "checking for $CXX option to enable C++11 features... " >&6; } -if test ${ac_cv_prog_cxx_11+y} +if test ${ac_cv_prog_cxx_cxx11+y} then : printf %s "(cached) " >&6 else $as_nop - ac_cv_prog_cxx_11=no + ac_cv_prog_cxx_cxx11=no ac_save_CXX=$CXX cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -5334,11 +5334,11 @@ if test x$ac_prog_cxx_stdcxx = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5 printf %s "checking for $CXX option to enable C++98 features... " >&6; } -if test ${ac_cv_prog_cxx_98+y} +if test ${ac_cv_prog_cxx_cxx98+y} then : printf %s "(cached) " >&6 else $as_nop - ac_cv_prog_cxx_98=no + ac_cv_prog_cxx_cxx98=no ac_save_CXX=$CXX cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -9555,6 +9555,19 @@ if $pmda_libvirt; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes printf "%s\n" "yes" >&6; }; else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; }; fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the resctrl PMDA should be included" >&5 +printf %s "checking if the resctrl PMDA should be included... " >&6; } +pmda_resctrl=false +if test "$target_cpu" = "x86_64" -o "$target_cpu" = "amd64" +then + pmda_resctrl=true +fi +PMDA_RESCTRL=$pmda_resctrl + +if $pmda_resctrl; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; }; else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; }; fi + qmake=$QMAKE enable_qt=false qt_release=release diff --git a/configure.ac b/configure.ac index 9498d2bd9f..23ebf85219 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ dnl -dnl Copyright (c) 2012-2022 Red Hat. +dnl Copyright (c) 2012-2023 Red Hat. dnl Copyright (c) 2008 Aconex. All Rights Reserved. dnl Copyright (c) 2000-2004,2008 Silicon Graphics, Inc. All Rights Reserved. dnl @@ -267,8 +267,7 @@ elif test $target_os = darwin then AC_DEFINE(IS_DARWIN, [1], [Platform is Darwin (Mac OS X)]) target_distro=macosx - target_machine=`uname -m` - export CFLAGS="-fPIC -no-cpp-precomp -fno-strict-aliasing -arch $target_machine" + export CFLAGS="-fPIC -no-cpp-precomp -fno-strict-aliasing -arch $target_cpu" pcp_platform_paths='/usr/local/bin:/opt/homebrew/bin' pcp_ps_all_flags="-axw -o user,pid,ppid,cpu,stime,tty,time,command" elif test $target_os = mingw @@ -1482,6 +1481,15 @@ fi AC_SUBST(PMDA_LIBVIRT, $pmda_libvirt) if $pmda_libvirt; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi +AC_MSG_CHECKING([if the resctrl PMDA should be included]) +pmda_resctrl=false +if test "$target_cpu" = "x86_64" -o "$target_cpu" = "amd64" +then + pmda_resctrl=true +fi +AC_SUBST(PMDA_RESCTRL, $pmda_resctrl) +if $pmda_resctrl; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi + qmake=$QMAKE enable_qt=false qt_release=release diff --git a/src/include/builddefs.in b/src/include/builddefs.in index 4b7c2eed0a..47d9910d6d 100644 --- a/src/include/builddefs.in +++ b/src/include/builddefs.in @@ -358,6 +358,7 @@ PMDA_BIND2 = @PMDA_BIND2@ PMDA_NUTCRACKER = @PMDA_NUTCRACKER@ PMDA_LIO = @PMDA_LIO@ PMDA_MSSQL = @PMDA_MSSQL@ +PMDA_RESCTRL = @PMDA_RESCTRL@ SHELL = /bin/sh IMAGES_DIR = $(TOPDIR)/all-images diff --git a/src/pmdas/resctrl/GNUmakefile b/src/pmdas/resctrl/GNUmakefile index 8afc4b8ba2..3b3624e364 100644 --- a/src/pmdas/resctrl/GNUmakefile +++ b/src/pmdas/resctrl/GNUmakefile @@ -42,6 +42,7 @@ default_pcp default: build-me include $(BUILDRULES) +ifeq "$(PMDA_RESCTRL)" "true" build-me: $(CMDTARGET) $(LIBTARGET) install_pcp install: default @@ -51,6 +52,11 @@ install_pcp install: default $(INSTALL) -m 644 -t $(PMDATMPDIR) root pmns domain.h $(DFILES) $(PMDAADMDIR) $(INSTALL) -m 644 sys-fs-resctrl.mount $(PCP_SYSTEMDUNIT_DIR)/sys-fs-resctrl.mount @$(INSTALL_MAN) +else +build-me: +install_pcp install: + @$(INSTALL_MAN) +endif $(VERSION_SCRIPT): $(VERSION_SCRIPT_MAKERULE) From ffd64778f3de8df7d1fd5dba5d53c219b53c3b0b Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Mon, 13 Nov 2023 16:50:53 +1100 Subject: [PATCH 3/4] pmlogredact: add latitude and longitude labels to the redacted set --- src/pmlogredact/network | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pmlogredact/network b/src/pmlogredact/network index 2524ace4a0..a937ed19a8 100644 --- a/src/pmlogredact/network +++ b/src/pmlogredact/network @@ -33,9 +33,11 @@ metric pmcd.pmie.logfile { value /.*/ -> "[redacted]" } # global { hostname -> "[redacted]" } -# redact hostname from context labels +# redact hostname and geolocation from context labels # label context "hostname" { value -> "[redacted]" } +label context "latitude" { value -> "[redacted]" } +label context "longitude" { value -> "[redacted]" } # metrics who's values may include networking details and # other sensitive information From 311f006564b465c59b6ac2b27b2c9409522de227 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Tue, 14 Nov 2023 11:38:00 +1100 Subject: [PATCH 4/4] pmproxy: fix compressed json termination and qa with new metrics --- qa/1689.out | 24 ++++++++++++++++++++++ src/pmproxy/src/http.c | 45 ++++++++++++++++++++++-------------------- 2 files changed, 48 insertions(+), 21 deletions(-) diff --git a/qa/1689.out b/qa/1689.out index dc4a3be214..043a0a25de 100644 --- a/qa/1689.out +++ b/qa/1689.out @@ -165,6 +165,30 @@ pmproxy.discover.throttled_changed_callbacks PMID: 4.5.18 [filesystem changed ca Help: Number of filesystem change callbacks that were ignored due to throttling +pmproxy.http.compressed.bytes PMID: 4.3.4 [Count of compressed bytes sent] + Data Type: 64-bit unsigned int InDom: PM_INDOM_NULL 0xffffffff + Semantics: counter Units: byte +Help: +Total number of compressed bytes sent + +pmproxy.http.compressed.count PMID: 4.3.1 [Count of compressed transfers] + Data Type: 64-bit unsigned int InDom: PM_INDOM_NULL 0xffffffff + Semantics: counter Units: count +Help: +Number of compressed HTTP transfers + +pmproxy.http.uncompressed.bytes PMID: 4.3.3 [Count of uncompressed bytes sent] + Data Type: 64-bit unsigned int InDom: PM_INDOM_NULL 0xffffffff + Semantics: counter Units: byte +Help: +Total number of uncompressed bytes sent + +pmproxy.http.uncompressed.count PMID: 4.3.2 [Count of uncompresed transfers] + Data Type: 64-bit unsigned int InDom: PM_INDOM_NULL 0xffffffff + Semantics: counter Units: count +Help: +Number of uncompressed HTTP transfers + pmproxy.map.context.size PMID: 4.1.6 [context map dictionary size] Data Type: 32-bit unsigned int InDom: PM_INDOM_NULL 0xffffffff Semantics: instant Units: none diff --git a/src/pmproxy/src/http.c b/src/pmproxy/src/http.c index 9952f3120e..e08ab274f3 100644 --- a/src/pmproxy/src/http.c +++ b/src/pmproxy/src/http.c @@ -47,22 +47,22 @@ static sds HEADER_ACCESS_CONTROL_REQUEST_HEADERS, * Helper function to manage client buffer compression. * The client buffer is compressed in-place (replaced). */ -static void -compress_GZIP(struct client *client) +static sds +compress_GZIP(struct client *client, sds input_buffer) { #ifdef HAVE_ZLIB z_stream *stream = &client->u.http.strm; - size_t input_len = sdslen(client->buffer); + size_t input_len = sdslen(input_buffer); uLong upper_bound = deflateBound(stream, input_len); sds final_buffer = sdsnewlen(NULL, upper_bound); if (deflateReset(stream) != Z_OK) { pmNotifyErr(LOG_ERR, "Deflate reset failed"); sdsfree(final_buffer); - return; + return input_buffer; } - stream->next_in = (Bytef *)client->buffer; + stream->next_in = (Bytef *)input_buffer; stream->avail_in = (uInt)input_len; stream->next_out = (Bytef *)final_buffer; stream->avail_out = (uInt)(upper_bound); @@ -70,15 +70,16 @@ compress_GZIP(struct client *client) if (deflate(stream, Z_FINISH) != Z_STREAM_END) { pmNotifyErr(LOG_ERR, "Deflate failed"); sdsfree(final_buffer); - return; + return input_buffer; } assert(stream->total_out <= upper_bound); sdssetlen(final_buffer, stream->total_out); - sdsfree(client->buffer); - client->buffer = final_buffer; + sdsfree(input_buffer); + return final_buffer; #else (void) client; + return input_buffer; #endif } @@ -429,6 +430,7 @@ http_reply(struct client *client, sds message, { enum http_flags flags = client->u.http.flags; struct proxy *proxy = client->proxy; + pmAtomValue av; char length[32]; /* hex length */ sds buffer, suffix; void *map = proxy->map; @@ -463,13 +465,19 @@ http_reply(struct client *client, sds message, if (client->buffer == NULL) { suffix = message; } else if (message != NULL) { - pmAtomValue av; + suffix = sdscatsds(client->buffer, message); + sdsfree(message); + client->buffer = NULL; + } else { + suffix = sdsempty(); + } + if (flags & HTTP_FLAG_COMPRESS_GZIP) { if (pmDebugOptions.http) fprintf(stderr, "Length before compression: %llu\n", - (unsigned long long)sdslen(client->buffer)); - compress_GZIP(client); - av.ull = sdslen(client->buffer); + (unsigned long long)sdslen(suffix)); + suffix = compress_GZIP(client, suffix); + av.ull = sdslen(suffix); if (pmDebugOptions.http) fprintf(stderr, "Length after compression: %llu\n", (unsigned long long)av.ull); @@ -478,18 +486,13 @@ http_reply(struct client *client, sds message, mmv_inc_atomvalue(map, proxy->values[VALUE_HTTP_COMPRESSED_BYTES], &av); } } else { - av.ull = sdslen(client->buffer); + av.ull = sdslen(suffix); if (map) { mmv_inc(map, proxy->values[VALUE_HTTP_UNCOMPRESSED_COUNT]); mmv_inc_atomvalue(map, proxy->values[VALUE_HTTP_UNCOMPRESSED_BYTES], &av); } } - suffix = sdscatsds(client->buffer, message); - sdsfree(message); - client->buffer = NULL; - } else { - suffix = sdsempty(); - } + buffer = http_response_header(client, sdslen(suffix), sts, type); } @@ -567,7 +570,7 @@ http_transfer(struct client *client) if (pmDebugOptions.http) fprintf(stderr, "Length before compression: %llu\n", (unsigned long long)sdslen(client->buffer)); - compress_GZIP(client); + client->buffer = compress_GZIP(client, client->buffer); av.ull = sdslen(client->buffer); if (pmDebugOptions.http) fprintf(stderr, "Length after compression: %llu\n", @@ -1109,7 +1112,7 @@ setup_http_module(struct proxy *proxy) "Count of uncompresed transfers", "Number of uncompressed HTTP transfers"); mmv_stats_add_metric(registry, "uncompressed.bytes", 3, MMV_TYPE_U64, MMV_SEM_COUNTER, units_bytes, MMV_INDOM_NULL, - "Count of uncompressed bytes sent", "Total number of uncompressed bytes sent "); + "Count of uncompressed bytes sent", "Total number of uncompressed bytes sent"); mmv_stats_add_metric(registry, "compressed.bytes", 4, MMV_TYPE_U64, MMV_SEM_COUNTER, units_bytes, MMV_INDOM_NULL, "Count of compressed bytes sent", "Total number of compressed bytes sent");