Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toggle to exclude hugepages from memory bar #1123

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DisplayOptionsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
4 changes: 4 additions & 0 deletions Settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ typedef struct Settings_ {
bool accountGuestInCPUMeter;
bool headerMargin;
bool screenTabs;
bool excludeHugepages;
#ifdef HAVE_GETMOUSE
bool enableMouse;
#endif
Expand Down
9 changes: 7 additions & 2 deletions linux/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down