Skip to content

Commit

Permalink
Add toggle to exclude hugepages from memory bar
Browse files Browse the repository at this point in the history
  • Loading branch information
SunRed committed Oct 31, 2022
1 parent e28ac5f commit e1154d3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions DisplayOptionsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,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 @@ -412,6 +412,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 @@ -593,6 +595,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 @@ -676,6 +679,7 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicColumns)
this->highlightBaseName = false;
this->highlightDeletedExe = true;
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 @@ -88,6 +88,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 @@ -350,8 +350,13 @@ void Platform_setMemoryValues(Meter* this) {
const ProcessList* pl = this->pl;
const LinuxProcessList* lpl = (const LinuxProcessList*) pl;

this->total = pl->totalMem;
this->values[0] = pl->usedMem;
if (this->pl->settings->excludeHugepages) {
this->total = pl->totalMem > lpl->totalHugePageMem ? pl->totalMem - lpl->totalHugePageMem : pl->totalMem;
this->values[0] = pl->usedMem > lpl->totalHugePageMem ? pl->usedMem - lpl->totalHugePageMem : pl->usedMem;
} else {
this->total = pl->totalMem;
this->values[0] = pl->usedMem;
}
this->values[1] = pl->buffersMem;
this->values[2] = pl->sharedMem;
this->values[3] = pl->cachedMem;
Expand Down

0 comments on commit e1154d3

Please sign in to comment.