From f4e8ee14badcd942e8466e8e152ad06a046fd668 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Fri, 7 Jun 2024 08:28:46 +0200 Subject: [PATCH] Added ZSwapShrinkerEnabled support to the application. --- src/app/application/application.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/application/application.cpp b/src/app/application/application.cpp index 6e0ae3c..1c305a5 100644 --- a/src/app/application/application.cpp +++ b/src/app/application/application.cpp @@ -63,7 +63,8 @@ void Application::PrintSettings() "Kernel's zpool type: {4}.\n" "Accept threshold percentage: {5}.\n" "Non same filled pages enabled: {6}.\n" - "Exclusive loads: {7}.", + "Exclusive loads: {7}.\n" + "Shrinker enabled: {8}.", ZSwap -> GetZSwapEnabled(), ZSwap -> GetZSwapSameFilledPages(), ZSwap -> GetZSwapMaxPoolPercent(), @@ -71,7 +72,8 @@ void Application::PrintSettings() ZSwap -> GetZSwapZpool(), ZSwap -> GetZSwapAcceptThresholdPercent(), ZSwap -> GetZSwapNonSameFilledPages(), - ZSwap -> GetZSwapExclusiveLoads()) + ZSwap -> GetZSwapExclusiveLoads(), + ZSwap -> GetZSwapShrinkerEnabled()) << std::endl; } @@ -163,6 +165,7 @@ int Application::ExecuteEnv() const std::string ZSwapAcceptThresholdPercentEnv = CWrappers::GetEnv("ZSWAP_ACCEPT_THRESHOLD_PERCENT_VALUE"); const std::string ZSwapNonSameFilledPagesEnv = CWrappers::GetEnv("ZSWAP_NON_SAME_FILLED_PAGES_ENABLED_VALUE"); const std::string ZSwapExclusiveLoadsEnv = CWrappers::GetEnv("ZSWAP_EXCLUSIVE_LOADS_VALUE"); + const std::string ZSwapShrinkerEnabledEnv = CWrappers::GetEnv("ZSWAP_SHRINKER_ENABLED_VALUE"); if (!ZSwapEnabledEnv.empty()) ZSwap -> SetZSwapEnabled(ZSwapEnabledEnv); if (!ZSwapSameFilledPagesEnv.empty()) ZSwap -> SetZSwapSameFilledPages(ZSwapSameFilledPagesEnv); @@ -172,6 +175,7 @@ int Application::ExecuteEnv() if (!ZSwapAcceptThresholdPercentEnv.empty()) ZSwap -> SetZSwapAcceptThresholdPercent(ZSwapAcceptThresholdPercentEnv); if (!ZSwapNonSameFilledPagesEnv.empty()) ZSwap -> SetZSwapNonSameFilledPages(ZSwapNonSameFilledPagesEnv); if (!ZSwapExclusiveLoadsEnv.empty()) ZSwap -> SetZSwapExclusiveLoads(ZSwapExclusiveLoadsEnv); + if (!ZSwapShrinkerEnabledEnv.empty()) ZSwap -> SetZSwapShrinkerEnabled(ZSwapShrinkerEnabledEnv); return 0; } @@ -188,6 +192,7 @@ int Application::ExecuteConfig(const std::string& ConfigFile) ("zswap.accept_threshold_percent", boost::program_options::value(), "The threshold at which ZSwap would start accepting pages again after it became full.") ("zswap.non_same_filled_pages_enabled", boost::program_options::value(), "Enable or disable accepting non same filled memory pages.") ("zswap.exclusive_loads", boost::program_options::value(), "Enable or disable entries invalidation when memory pages are loaded from compressed pool.") + ("zswap.shrinker_enabled", boost::program_options::value(), "Enable or disable pool shrinking based on memory pressure.") ; if (!fs::exists(ConfigFile)) throw std::invalid_argument("Configuration file does not exist!"); @@ -204,6 +209,7 @@ int Application::ExecuteConfig(const std::string& ConfigFile) if (Config -> count("zswap.accept_threshold_percent")) ZSwap -> SetZSwapAcceptThresholdPercent(Config -> at("zswap.accept_threshold_percent").as()); if (Config -> count("zswap.non_same_filled_pages_enabled")) ZSwap -> SetZSwapNonSameFilledPages(Config -> at("zswap.non_same_filled_pages_enabled").as()); if (Config -> count("zswap.exclusive_loads")) ZSwap -> SetZSwapExclusiveLoads(Config -> at("zswap.exclusive_loads").as()); + if (Config -> count("zswap.shrinker_enabled")) ZSwap -> SetZSwapShrinkerEnabled(Config -> at("zswap.shrinker_enabled").as()); return 0; } @@ -217,6 +223,7 @@ int Application::ExecuteCmdLine() if (CmdLine -> count("accept_threshold_percent")) ZSwap -> SetZSwapAcceptThresholdPercent(CmdLine -> at("accept_threshold_percent").as()); if (CmdLine -> count("non_same_filled_pages_enabled")) ZSwap -> SetZSwapNonSameFilledPages(CmdLine -> at("non_same_filled_pages_enabled").as()); if (CmdLine -> count("exclusive_loads")) ZSwap -> SetZSwapExclusiveLoads(CmdLine -> at("exclusive_loads").as()); + if (CmdLine -> count("shrinker_enabled")) ZSwap -> SetZSwapShrinkerEnabled(CmdLine -> at("shrinker_enabled").as()); return 0; } @@ -270,6 +277,7 @@ void Application::InitCmdLineOptions() ("accept_threshold_percent,a", boost::program_options::value(), "The threshold at which ZSwap would start accepting pages again after it became full.") ("non_same_filled_pages_enabled,n", boost::program_options::value(), "Enable or disable accepting non same filled memory pages.") ("exclusive_loads,x", boost::program_options::value(), "Enable or disable entries invalidation when memory pages are loaded from compressed pool.") + ("shrinker_enabled,r", boost::program_options::value(), "Enable or disable pool shrinking based on memory pressure.") ; CmdLineOptions -> add(OptionsGeneral).add(OptionsConfiguration).add(OptionsZSwap);