From 5be5409f6248db5a8ce4e68136b0c6675f8b1c31 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Fri, 14 Aug 2020 11:54:27 +0100 Subject: [PATCH] scaling governor function moved to common header file --- lib/include/srslte/common/common_helper.h | 24 ++++++++++++++++++++++- srsenb/src/main.cc | 23 +--------------------- srsue/src/main.cc | 23 +--------------------- 3 files changed, 25 insertions(+), 45 deletions(-) diff --git a/lib/include/srslte/common/common_helper.h b/lib/include/srslte/common/common_helper.h index df990aa89..781ca4c50 100644 --- a/lib/include/srslte/common/common_helper.h +++ b/lib/include/srslte/common/common_helper.h @@ -28,12 +28,13 @@ #define SRSLTE_COMMON_HELPER_H #include "srslte/common/logmap.h" +#include #ifdef __cplusplus extern "C" { #endif // __cplusplus -void log_args(int argc, char* argv[], std::string service) +inline void log_args(int argc, char* argv[], std::string service) { std::ostringstream s1; s1 << "Using binary " << argv[0] << " with arguments: "; @@ -46,6 +47,27 @@ void log_args(int argc, char* argv[], std::string service) srslte::logmap::get(service)->info("%s", s1.str().c_str()); } +inline void check_scaling_governor(const std::string& device_name) +{ + if (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) { + printf("WARNING: cpu scaling governor is not set to performance mode.\n"); + } +} + #ifdef __cplusplus } #endif // __cplusplus diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index e95c63b20..66b98281c 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -424,27 +424,6 @@ 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(); @@ -478,7 +457,7 @@ 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); + check_scaling_governor(args.rf.device_name); // Create eNB unique_ptr enb{new srsenb::enb}; diff --git a/srsue/src/main.cc b/srsue/src/main.cc index d823aa36d..b2cda4576 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -608,27 +608,6 @@ 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(); @@ -658,7 +637,7 @@ int main(int argc, char* argv[]) srslte::logmap::set_default_logger(&log_wrapper); log_args(argc, argv, "UE"); - check_scaling_governor(args); + check_scaling_governor(args.rf.device_name); // Create UE instance srsue::ue ue;