Skip to content

Commit 96555d5

Browse files
alvasManasaezper
authored andcommitted
gnb: check for possible performance tunnig requirements
This includes CPU scaling governor and DRM KMS polling. We print a warning if they scaling governor is not performance and if KMS polling is enabled.
1 parent 7edede8 commit 96555d5

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

apps/gnb/gnb.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include "srsran/phy/lower/lower_phy_factory.h"
5656
#include "srsran/phy/upper/upper_phy_timing_notifier.h"
5757
#include "srsran/radio/radio_factory.h"
58+
#include "srsran/support/sysinfo.h"
5859
#include <atomic>
5960
#include <csignal>
6061
#include <unordered_map>
@@ -467,6 +468,11 @@ int main(int argc, char** argv)
467468
get_cpu_feature_info());
468469
}
469470

471+
// Check some common causes of performance issues and
472+
// print a warning if required.
473+
check_cpu_governor(gnb_logger);
474+
check_drm_kms_polling(gnb_logger);
475+
470476
// Set layer-specific pcap options.
471477
std::unique_ptr<ngap_pcap> ngap_p = std::make_unique<ngap_pcap_impl>();
472478
if (gnb_cfg.pcap_cfg.ngap.enabled) {

include/srsran/support/sysinfo.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
*
3+
* Copyright 2021-2023 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#include "srsran/srslog/srslog.h"
12+
#include <fstream>
13+
#include <string>
14+
#include <thread>
15+
16+
#pragma once
17+
18+
/// \brief Check whether the CPU scaling governor is set to performance.
19+
///
20+
/// \param[in] logger to print warnings.
21+
/// \return True if we were able to read the sysfs scaling governor information.
22+
inline bool check_cpu_governor(srslog::basic_logger& logger)
23+
{
24+
unsigned int n_cpus = std::thread::hardware_concurrency();
25+
std::string filename_base = "/sys/devices/system/cpu/cpu";
26+
for (unsigned int i = 0; i < n_cpus; ++i) {
27+
std::string filename = filename_base + std::to_string(i) + "/cpufreq/scaling_governor";
28+
std::ifstream input(filename);
29+
if (input.fail()) {
30+
logger.warning("Could not check scaling governor. filename={} error=\"{}\"", filename, strerror(errno));
31+
return false;
32+
}
33+
std::string gov;
34+
std::getline(input, gov);
35+
if (input.fail()) {
36+
logger.warning("Could not check scaling governor. filename={} error=\"{}\"", filename, strerror(errno));
37+
return false;
38+
}
39+
if (gov == "performance") {
40+
logger.debug("CPU{} scaling governor is set to performance", i);
41+
} else {
42+
logger.warning(
43+
"CPU{} scaling governor is not set to performance, which may hinder performance. You can set it to "
44+
"performance using the "
45+
"\"srsran_performance\" script",
46+
i);
47+
}
48+
}
49+
return true;
50+
}
51+
52+
/// \brief Check whether the DRM KMS polling is set.
53+
///
54+
/// \param[in] logger to print warnings.
55+
/// \return True if we were able to read the sysfs for the DRM KMS polling information.
56+
inline bool check_drm_kms_polling(srslog::basic_logger& logger)
57+
{
58+
std::string filename = "/sys/module/drm_kms_helper/parameters/poll";
59+
std::ifstream input(filename);
60+
if (input.fail()) {
61+
logger.warning("Could not check DRM KMS polling. filename={} error=\"{}\"", filename, strerror(errno));
62+
return false;
63+
}
64+
std::string polling;
65+
std::getline(input, polling);
66+
if (input.fail()) {
67+
logger.warning("Could not check DRM KMS polling. filename={} error=\"{}\"", filename, strerror(errno));
68+
return false;
69+
}
70+
if (polling == "N") {
71+
logger.debug("DRM KMS polling is disabled");
72+
} else {
73+
logger.warning("DRM KMS polling is enabled, which may hinder performance. You can disable it using the "
74+
"\"srsran_performance\" script");
75+
}
76+
return true;
77+
}

0 commit comments

Comments
 (0)