diff --git a/DisplayOptionsPanel.c b/DisplayOptionsPanel.c index f9fa9b12b..7478ba2d2 100644 --- a/DisplayOptionsPanel.c +++ b/DisplayOptionsPanel.c @@ -128,6 +128,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* Panel_add(super, (Object*) CheckItem_newByRef("- Try to strip exe from cmdline (when Command is merged)", &(settings->stripExeFromCmdline))); Panel_add(super, (Object*) CheckItem_newByRef("Highlight large numbers in memory counters", &(settings->highlightMegabytes))); Panel_add(super, (Object*) CheckItem_newByRef("Leave a margin around header", &(settings->headerMargin))); + Panel_add(super, (Object*) CheckItem_newByRef("Exclude HugePages from memory", &(settings->excludeHugepages))); Panel_add(super, (Object*) CheckItem_newByRef("Detailed CPU time (System/IO-Wait/Hard-IRQ/Soft-IRQ/Steal/Guest)", &(settings->detailedCPUTime))); Panel_add(super, (Object*) CheckItem_newByRef("Count CPUs from 1 instead of 0", &(settings->countCPUsFromOne))); Panel_add(super, (Object*) CheckItem_newByRef("Update process names on every refresh", &(settings->updateProcessNames))); diff --git a/Settings.c b/Settings.c index c712966e3..5cd868981 100644 --- a/Settings.c +++ b/Settings.c @@ -413,6 +413,8 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini this->headerMargin = atoi(option[1]); } else if (String_eq(option[0], "screen_tabs")) { this->screenTabs = atoi(option[1]); + } else if (String_eq(option[0], "exclude_hugepages")) { + this->excludeHugepages = atoi(option[1]); } else if (String_eq(option[0], "expand_system_time")) { // Compatibility option. this->detailedCPUTime = atoi(option[1]); @@ -599,6 +601,7 @@ int Settings_write(const Settings* this, bool onCrash) { printSettingInteger("show_merged_command", this->showMergedCommand); printSettingInteger("header_margin", this->headerMargin); printSettingInteger("screen_tabs", this->screenTabs); + printSettingInteger("exclude_hugepages", this->excludeHugepages); printSettingInteger("detailed_cpu_time", this->detailedCPUTime); printSettingInteger("cpu_count_from_one", this->countCPUsFromOne); printSettingInteger("show_cpu_usage", this->showCPUUsage); @@ -684,6 +687,7 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicMeters, H this->highlightDeletedExe = true; this->shadowDistPathPrefix = false; this->highlightMegabytes = true; + this->excludeHugepages = false; this->detailedCPUTime = false; this->countCPUsFromOne = false; this->showCPUUsage = true; diff --git a/Settings.h b/Settings.h index 48c62590a..aadd0d953 100644 --- a/Settings.h +++ b/Settings.h @@ -90,6 +90,7 @@ typedef struct Settings_ { bool accountGuestInCPUMeter; bool headerMargin; bool screenTabs; + bool excludeHugepages; #ifdef HAVE_GETMOUSE bool enableMouse; #endif diff --git a/linux/Platform.c b/linux/Platform.c index 693044af1..4715f6b20 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -356,8 +356,13 @@ void Platform_setMemoryValues(Meter* this) { const Machine* host = this->host; const LinuxMachine* lhost = (const LinuxMachine*) host; - this->total = host->totalMem; - this->values[MEMORY_METER_USED] = host->usedMem; + if (host->settings->excludeHugepages) { + this->total = host->totalMem > lhost->totalHugePageMem ? host->totalMem - lhost->totalHugePageMem : host->totalMem; + this->values[MEMORY_METER_USED] = host->usedMem > lhost->totalHugePageMem ? host->usedMem - lhost->totalHugePageMem : host->usedMem; + } else { + this->total = host->totalMem; + this->values[MEMORY_METER_USED] = host->usedMem; + } this->values[MEMORY_METER_BUFFERS] = host->buffersMem; this->values[MEMORY_METER_SHARED] = host->sharedMem; this->values[MEMORY_METER_COMPRESSED] = 0; /* compressed */