From 087805d222569438e258604d2643e451631ebf03 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Fri, 14 Aug 2020 10:47:24 +0100 Subject: [PATCH] add warning if scaling governor is not performance mode --- srsenb/src/main.cc | 23 +++++++++++++++++++++++ srsue/src/main.cc | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index 17ffd8223..e95c63b20 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -424,6 +424,27 @@ static size_t fixup_log_file_maxsize(int x) return (x < 0) ? 0 : size_t(x) * 1024u; } +void check_scaling_governor(const all_args_t& args) +{ + if (args.rf.device_name == "zmq") { + return; + } + std::ifstream file("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"); + bool found = false; + if (file.is_open()) { + std::string line; + while (getline(file, line)) { + if (line.find("performance") != std::string::npos) { + found = true; + break; + } + } + } + if (not found) { + cout << "WARNING: cpu scaling governor is not set to performance mode."; + } +} + int main(int argc, char* argv[]) { srslte_register_signal_handler(); @@ -457,6 +478,8 @@ int main(int argc, char* argv[]) srslte::logmap::get("COMMON")->set_level(srslte::LOG_LEVEL_INFO); log_args(argc, argv, "ENB"); + check_scaling_governor(args); + // Create eNB unique_ptr enb{new srsenb::enb}; if (enb->init(args, &log_wrapper) != SRSLTE_SUCCESS) { diff --git a/srsue/src/main.cc b/srsue/src/main.cc index a2354a7cf..d823aa36d 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -608,6 +608,27 @@ static size_t fixup_log_file_maxsize(int x) return (x < 0) ? 0 : size_t(x) * 1024u; } +void check_scaling_governor(const all_args_t& args) +{ + if (args.rf.device_name == "zmq") { + return; + } + std::ifstream file("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"); + bool found = false; + if (file.is_open()) { + std::string line; + while (getline(file, line)) { + if (line.find("performance") != std::string::npos) { + found = true; + break; + } + } + } + if (not found) { + cout << "WARNING: cpu scaling governor is not set to performance mode."; + } +} + int main(int argc, char* argv[]) { srslte_register_signal_handler(); @@ -637,6 +658,8 @@ int main(int argc, char* argv[]) srslte::logmap::set_default_logger(&log_wrapper); log_args(argc, argv, "UE"); + check_scaling_governor(args); + // Create UE instance srsue::ue ue; if (ue.init(args, &log_wrapper)) {