scaling governor function moved to common header file

master
Francisco Paisana 4 years ago
parent 087805d222
commit 5be5409f62

@ -28,12 +28,13 @@
#define SRSLTE_COMMON_HELPER_H
#include "srslte/common/logmap.h"
#include <fstream>
#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

@ -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<srsenb::enb> enb{new srsenb::enb};

@ -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;

Loading…
Cancel
Save