From 37e186fd6626e83f51d0267052677355575964d4 Mon Sep 17 00:00:00 2001 From: David Zarzycki Date: Thu, 7 Jan 2021 08:38:18 -0500 Subject: Linux: Add SwapCached to the swap meter According to the Linux kernel documentation, "SwapCached" tracks "memory that once was swapped out, is swapped back in but still also is in the swapfile (if memory is needed it doesn't need to be swapped out AGAIN because it is already in the swapfile. This saves I/O)." --- SwapMeter.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'SwapMeter.c') diff --git a/SwapMeter.c b/SwapMeter.c index e39cfd9f..81f006ec 100644 --- a/SwapMeter.c +++ b/SwapMeter.c @@ -14,7 +14,8 @@ in the source distribution for its full text. static const int SwapMeter_attributes[] = { - SWAP + SWAP, + SWAP_CACHE }; static void SwapMeter_updateValues(Meter* this, char* buffer, size_t size) { @@ -38,6 +39,12 @@ static void SwapMeter_display(const Object* cast, RichString* out) { Meter_humanUnit(buffer, this->values[0], sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:"); RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); + +#ifdef HTOP_LINUX + Meter_humanUnit(buffer, this->values[1], sizeof(buffer)); + RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:"); + RichString_appendAscii(out, CRT_colors[SWAP_CACHE], buffer); +#endif } const MeterClass SwapMeter_class = { @@ -48,7 +55,7 @@ const MeterClass SwapMeter_class = { }, .updateValues = SwapMeter_updateValues, .defaultMode = BAR_METERMODE, - .maxItems = 1, + .maxItems = 2, .total = 100.0, .attributes = SwapMeter_attributes, .name = "Swap", -- cgit v1.2.3