Skip to content

Commit

Permalink
Added ZSwapShrinkerEnabled support to the application.
Browse files Browse the repository at this point in the history
  • Loading branch information
xvitaly committed Jun 7, 2024
1 parent 78eefe3 commit f4e8ee1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/app/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ 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(),
ZSwap -> GetZSwapCompressor(),
ZSwap -> GetZSwapZpool(),
ZSwap -> GetZSwapAcceptThresholdPercent(),
ZSwap -> GetZSwapNonSameFilledPages(),
ZSwap -> GetZSwapExclusiveLoads())
ZSwap -> GetZSwapExclusiveLoads(),
ZSwap -> GetZSwapShrinkerEnabled())
<< std::endl;
}

Expand Down Expand Up @@ -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);
Expand All @@ -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;
}

Expand All @@ -188,6 +192,7 @@ int Application::ExecuteConfig(const std::string& ConfigFile)
("zswap.accept_threshold_percent", boost::program_options::value<std::string>(), "The threshold at which ZSwap would start accepting pages again after it became full.")
("zswap.non_same_filled_pages_enabled", boost::program_options::value<std::string>(), "Enable or disable accepting non same filled memory pages.")
("zswap.exclusive_loads", boost::program_options::value<std::string>(), "Enable or disable entries invalidation when memory pages are loaded from compressed pool.")
("zswap.shrinker_enabled", boost::program_options::value<std::string>(), "Enable or disable pool shrinking based on memory pressure.")
;

if (!fs::exists(ConfigFile)) throw std::invalid_argument("Configuration file does not exist!");
Expand All @@ -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<std::string>());
if (Config -> count("zswap.non_same_filled_pages_enabled")) ZSwap -> SetZSwapNonSameFilledPages(Config -> at("zswap.non_same_filled_pages_enabled").as<std::string>());
if (Config -> count("zswap.exclusive_loads")) ZSwap -> SetZSwapExclusiveLoads(Config -> at("zswap.exclusive_loads").as<std::string>());
if (Config -> count("zswap.shrinker_enabled")) ZSwap -> SetZSwapShrinkerEnabled(Config -> at("zswap.shrinker_enabled").as<std::string>());
return 0;
}

Expand All @@ -217,6 +223,7 @@ int Application::ExecuteCmdLine()
if (CmdLine -> count("accept_threshold_percent")) ZSwap -> SetZSwapAcceptThresholdPercent(CmdLine -> at("accept_threshold_percent").as<std::string>());
if (CmdLine -> count("non_same_filled_pages_enabled")) ZSwap -> SetZSwapNonSameFilledPages(CmdLine -> at("non_same_filled_pages_enabled").as<std::string>());
if (CmdLine -> count("exclusive_loads")) ZSwap -> SetZSwapExclusiveLoads(CmdLine -> at("exclusive_loads").as<std::string>());
if (CmdLine -> count("shrinker_enabled")) ZSwap -> SetZSwapShrinkerEnabled(CmdLine -> at("shrinker_enabled").as<std::string>());
return 0;
}

Expand Down Expand Up @@ -270,6 +277,7 @@ void Application::InitCmdLineOptions()
("accept_threshold_percent,a", boost::program_options::value<std::string>(), "The threshold at which ZSwap would start accepting pages again after it became full.")
("non_same_filled_pages_enabled,n", boost::program_options::value<std::string>(), "Enable or disable accepting non same filled memory pages.")
("exclusive_loads,x", boost::program_options::value<std::string>(), "Enable or disable entries invalidation when memory pages are loaded from compressed pool.")
("shrinker_enabled,r", boost::program_options::value<std::string>(), "Enable or disable pool shrinking based on memory pressure.")
;

CmdLineOptions -> add(OptionsGeneral).add(OptionsConfiguration).add(OptionsZSwap);
Expand Down

0 comments on commit f4e8ee1

Please sign in to comment.