summaryrefslogtreecommitdiffstats
path: root/SwapMeter.c
diff options
context:
space:
mode:
authorIvan Shapovalov <intelfx@intelfx.name>2022-12-27 04:57:52 +0400
committerBenBE <BenBE@geshi.org>2023-04-23 16:00:17 +0200
commitb29b33ebb9ae80a95e7d09eb537e0fccc5043d68 (patch)
treebbd2c2642784757885d150ba0c598877f6f3e9d7 /SwapMeter.c
parentb2ada278403e643a3bc339783740f262b7879803 (diff)
{Memory,Swap}Meter: add "compressed memory" metrics
For now, the semantics are mostly fit for Linux zswap subsystem. For instance, we add the third swap usage metric that indicates the amount of memory that is accounted to swap but in fact stored elsewhere. This exactly matches the definition of frontswap/zswap, and is probably of little use to all other platforms.
Diffstat (limited to 'SwapMeter.c')
-rw-r--r--SwapMeter.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/SwapMeter.c b/SwapMeter.c
index fea8e88b..84e58a26 100644
--- a/SwapMeter.c
+++ b/SwapMeter.c
@@ -20,7 +20,8 @@ in the source distribution for its full text.
static const int SwapMeter_attributes[] = {
SWAP,
- SWAP_CACHE
+ SWAP_CACHE,
+ SWAP_FRONTSWAP,
};
static void SwapMeter_updateValues(Meter* this) {
@@ -29,6 +30,7 @@ static void SwapMeter_updateValues(Meter* this) {
int written;
this->values[SWAP_METER_CACHE] = NAN; /* 'cached' not present on all platforms */
+ this->values[SWAP_METER_FRONTSWAP] = NAN; /* 'frontswap' not present on all platforms */
Platform_setSwapValues(this);
written = Meter_humanUnit(buffer, this->values[SWAP_METER_USED], size);
@@ -54,6 +56,12 @@ static void SwapMeter_display(const Object* cast, RichString* out) {
RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:");
RichString_appendAscii(out, CRT_colors[SWAP_CACHE], buffer);
}
+
+ if (!isnan(this->values[SWAP_METER_FRONTSWAP])) {
+ Meter_humanUnit(buffer, this->values[SWAP_METER_FRONTSWAP], sizeof(buffer));
+ RichString_appendAscii(out, CRT_colors[METER_TEXT], " frontswap:");
+ RichString_appendAscii(out, CRT_colors[SWAP_FRONTSWAP], buffer);
+ }
}
const MeterClass SwapMeter_class = {

© 2014-2024 Faster IT GmbH | imprint | privacy policy