diff options
author | Ivan Shapovalov <intelfx@intelfx.name> | 2022-12-27 17:39:05 +0400 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2023-04-23 16:00:17 +0200 |
commit | 71f2e66126286540ca88d8c36f81008ba5181f89 (patch) | |
tree | ac5c001f77da802e88b43ffa8c05853e5decaf4c /linux/Platform.c | |
parent | 71f5a80d9e312375eff28d2fbb7d8add81f6793c (diff) |
Linux: (hack) work around the fact that Zswapped pages may be SwapCached
Diffstat (limited to 'linux/Platform.c')
-rw-r--r-- | linux/Platform.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/linux/Platform.c b/linux/Platform.c index 8015f55b..782f1546 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -389,7 +389,22 @@ void Platform_setSwapValues(Meter* this) { this->values[SWAP_METER_FRONTSWAP] = 0; /* frontswap -- memory that is accounted to swap but resides elsewhere */ if (lpl->zswap.usedZswapOrig > 0 || lpl->zswap.usedZswapComp > 0) { + /* + * FIXME: Zswapped pages can be both SwapUsed and SwapCached, and we do not know which. + * + * Apparently, it is possible that Zswapped > SwapUsed. This means that some of Zswapped pages + * were actually SwapCached, nor SwapUsed. Unfortunately, we cannot tell what exactly portion + * of Zswapped pages were SwapCached. + * + * For now, subtract Zswapped from SwapUsed and only if Zswapped > SwapUsed, subtract the + * overflow from SwapCached. + */ this->values[SWAP_METER_USED] -= lpl->zswap.usedZswapOrig; + if (this->values[SWAP_METER_USED] < 0) { + /* subtract the overflow from SwapCached */ + this->values[SWAP_METER_CACHE] += this->values[SWAP_METER_USED]; + this->values[SWAP_METER_USED] = 0; + } this->values[SWAP_METER_FRONTSWAP] += lpl->zswap.usedZswapOrig; } } |