From e2167a9fd527a8a7c9567c19e3b3a10062c617d0 Mon Sep 17 00:00:00 2001 From: wu siyuan Date: Tue, 21 Nov 2023 11:48:39 +0800 Subject: [PATCH] fix sysmem bug --- perfd.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/perfd.go b/perfd.go index bf25c7b..a616299 100644 --- a/perfd.go +++ b/perfd.go @@ -353,7 +353,7 @@ func (c *perfdSysmontap) parseSystemData(dataArray []interface{}) { var dataTime uint64 = 0 for _, value := range dataArray { t, ok := value.(map[string]interface{}) - if ok && t["SystemCPUUsage"] != nil && t["EndMachAbsTime"]!=nil && t["EndMachAbsTime"].(uint64) > dataTime { + if ok && t["SystemCPUUsage"] != nil && t["EndMachAbsTime"] != nil && t["EndMachAbsTime"].(uint64) > dataTime { systemInfo = t dataTime = t["EndMachAbsTime"].(uint64) } @@ -404,9 +404,10 @@ func (c *perfdSysmontap) parseSystemData(dataArray []interface{}) { } if c.options.SysMem { - kernelPageSize := int64(1) // why 16384 ? + kernelPageSize := int64(16384) // core_profile_session_tap get kernel_page_size + // kernelPageSize := int64(1) // why 16384 ? appMemory := (systemAttributesMap["vmIntPageCount"] - systemAttributesMap["vmPurgeableCount"]) * kernelPageSize - cachedFiles := (systemAttributesMap["vmExtPageCount"] - systemAttributesMap["vmPurgeableCount"]) * kernelPageSize + cachedFiles := (systemAttributesMap["vmExtPageCount"] + systemAttributesMap["vmPurgeableCount"]) * kernelPageSize compressed := systemAttributesMap["vmCompressorPageCount"] * kernelPageSize usedMemory := (systemAttributesMap["vmUsedCount"] - systemAttributesMap["vmExtPageCount"]) * kernelPageSize wiredMemory := systemAttributesMap["vmWireCount"] * kernelPageSize