mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-trx.git
				synced 2025-11-02 21:23:16 +00:00 
			
		
		
		
	Use new libosmovty cpu sched config features
Using the new libosmovty features allow for: * Setting different cpu-affinity masks for each thread in the process, both at startup through .cfg file as well as changing it at runtime. * Unified VTY interface to change the scheduling policy of the process inherited by all osmocom processes enabling the feature. Depends: libosmocore.git Change-Id If76a4bd2cc7b3c7adf5d84790a944d78be70e10a Depends: osmo-gsm-masnuals.git Change-Id Icd75769ef630c3fa985fc5e2154d5521689cdd3c Related: SYS#4986 Change-Id: I3798603779b88ea37da03033cf7737a6e4751d6e
This commit is contained in:
		@@ -291,7 +291,7 @@ DEFUN(cfg_ext_rach, cfg_ext_rach_cmd,
 | 
				
			|||||||
	return CMD_SUCCESS;
 | 
						return CMD_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DEFUN(cfg_rt_prio, cfg_rt_prio_cmd,
 | 
					DEFUN_DEPRECATED(cfg_rt_prio, cfg_rt_prio_cmd,
 | 
				
			||||||
	"rt-prio <1-32>",
 | 
						"rt-prio <1-32>",
 | 
				
			||||||
	"Set the SCHED_RR real-time priority\n"
 | 
						"Set the SCHED_RR real-time priority\n"
 | 
				
			||||||
	"Real time priority\n")
 | 
						"Real time priority\n")
 | 
				
			||||||
@@ -299,6 +299,8 @@ DEFUN(cfg_rt_prio, cfg_rt_prio_cmd,
 | 
				
			|||||||
	struct trx_ctx *trx = trx_from_vty(vty);
 | 
						struct trx_ctx *trx = trx_from_vty(vty);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	trx->cfg.sched_rr = atoi(argv[0]);
 | 
						trx->cfg.sched_rr = atoi(argv[0]);
 | 
				
			||||||
 | 
						vty_out (vty, "%% 'rt-prio %u' is deprecated, use 'policy rr %u' under 'sched' node instead%s",
 | 
				
			||||||
 | 
							 trx->cfg.sched_rr, trx->cfg.sched_rr, VTY_NEWLINE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return CMD_SUCCESS;
 | 
						return CMD_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								TODO-RELEASE
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								TODO-RELEASE
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					* update libosmocore dependency to > 1.3.x for osmo_sched_vty_init(), osmo_sched_vty_apply_localthread()
 | 
				
			||||||
 | 
					* update osmo-gsm-manuals dependency to > 0.3.0 for vty_cpu_sched.adoc include.
 | 
				
			||||||
@@ -37,6 +37,7 @@ extern "C" {
 | 
				
			|||||||
#include <osmocom/core/utils.h>
 | 
					#include <osmocom/core/utils.h>
 | 
				
			||||||
#include <osmocom/core/socket.h>
 | 
					#include <osmocom/core/socket.h>
 | 
				
			||||||
#include <osmocom/core/bits.h>
 | 
					#include <osmocom/core/bits.h>
 | 
				
			||||||
 | 
					#include <osmocom/vty/cpu_sched_vty.h>
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_CONFIG_H
 | 
					#ifdef HAVE_CONFIG_H
 | 
				
			||||||
@@ -1273,6 +1274,7 @@ void *RxUpperLoopAdapter(TrxChanThParams *params)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  snprintf(thread_name, 16, "RxUpper%zu", num);
 | 
					  snprintf(thread_name, 16, "RxUpper%zu", num);
 | 
				
			||||||
  set_selfthread_name(thread_name);
 | 
					  set_selfthread_name(thread_name);
 | 
				
			||||||
 | 
					  OSMO_ASSERT(osmo_cpu_sched_vty_apply_localthread() == 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  while (1) {
 | 
					  while (1) {
 | 
				
			||||||
    if (!trx->driveReceiveFIFO(num)) {
 | 
					    if (!trx->driveReceiveFIFO(num)) {
 | 
				
			||||||
@@ -1288,6 +1290,7 @@ void *RxUpperLoopAdapter(TrxChanThParams *params)
 | 
				
			|||||||
void *RxLowerLoopAdapter(Transceiver *transceiver)
 | 
					void *RxLowerLoopAdapter(Transceiver *transceiver)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  set_selfthread_name("RxLower");
 | 
					  set_selfthread_name("RxLower");
 | 
				
			||||||
 | 
					  OSMO_ASSERT(osmo_cpu_sched_vty_apply_localthread() == 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  while (1) {
 | 
					  while (1) {
 | 
				
			||||||
    if (!transceiver->driveReceiveRadio()) {
 | 
					    if (!transceiver->driveReceiveRadio()) {
 | 
				
			||||||
@@ -1303,6 +1306,7 @@ void *RxLowerLoopAdapter(Transceiver *transceiver)
 | 
				
			|||||||
void *TxLowerLoopAdapter(Transceiver *transceiver)
 | 
					void *TxLowerLoopAdapter(Transceiver *transceiver)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  set_selfthread_name("TxLower");
 | 
					  set_selfthread_name("TxLower");
 | 
				
			||||||
 | 
					  OSMO_ASSERT(osmo_cpu_sched_vty_apply_localthread() == 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  while (1) {
 | 
					  while (1) {
 | 
				
			||||||
    transceiver->driveTxFIFO();
 | 
					    transceiver->driveTxFIFO();
 | 
				
			||||||
@@ -1321,6 +1325,7 @@ void *TxUpperLoopAdapter(TrxChanThParams *params)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  snprintf(thread_name, 16, "TxUpper%zu", num);
 | 
					  snprintf(thread_name, 16, "TxUpper%zu", num);
 | 
				
			||||||
  set_selfthread_name(thread_name);
 | 
					  set_selfthread_name(thread_name);
 | 
				
			||||||
 | 
					  OSMO_ASSERT(osmo_cpu_sched_vty_apply_localthread() == 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  while (1) {
 | 
					  while (1) {
 | 
				
			||||||
    if (!trx->driveTxPriorityQueue(num)) {
 | 
					    if (!trx->driveTxPriorityQueue(num)) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,7 +34,9 @@
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#include <osmocom/core/utils.h>
 | 
				
			||||||
#include <osmocom/gsm/gsm_utils.h>
 | 
					#include <osmocom/gsm/gsm_utils.h>
 | 
				
			||||||
 | 
					#include <osmocom/vty/cpu_sched_vty.h>
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef USE_UHD_3_11
 | 
					#ifdef USE_UHD_3_11
 | 
				
			||||||
@@ -150,6 +152,7 @@ static const std::map<dev_band_key, dev_band_desc> dev_band_nom_power_param_map
 | 
				
			|||||||
void *async_event_loop(uhd_device *dev)
 | 
					void *async_event_loop(uhd_device *dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	set_selfthread_name("UHDAsyncEvent");
 | 
						set_selfthread_name("UHDAsyncEvent");
 | 
				
			||||||
 | 
						OSMO_ASSERT(osmo_cpu_sched_vty_apply_localthread() == 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (1) {
 | 
						while (1) {
 | 
				
			||||||
		dev->recv_async_msg();
 | 
							dev->recv_async_msg();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,6 +55,7 @@ extern "C" {
 | 
				
			|||||||
#include <osmocom/ctrl/control_if.h>
 | 
					#include <osmocom/ctrl/control_if.h>
 | 
				
			||||||
#include <osmocom/vty/stats.h>
 | 
					#include <osmocom/vty/stats.h>
 | 
				
			||||||
#include <osmocom/vty/command.h>
 | 
					#include <osmocom/vty/command.h>
 | 
				
			||||||
 | 
					#include <osmocom/vty/cpu_sched_vty.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "convolve.h"
 | 
					#include "convolve.h"
 | 
				
			||||||
#include "convert.h"
 | 
					#include "convert.h"
 | 
				
			||||||
@@ -435,7 +436,9 @@ static int set_sched_rr(unsigned int prio)
 | 
				
			|||||||
	int rc;
 | 
						int rc;
 | 
				
			||||||
	memset(¶m, 0, sizeof(param));
 | 
						memset(¶m, 0, sizeof(param));
 | 
				
			||||||
	param.sched_priority = prio;
 | 
						param.sched_priority = prio;
 | 
				
			||||||
	LOG(INFO) << "Setting SCHED_RR priority " << param.sched_priority;
 | 
						LOG(INFO) << "Setting SCHED_RR priority " << param.sched_priority
 | 
				
			||||||
 | 
							  << ". This setting is DEPRECATED, please use 'policy rr " << param.sched_priority
 | 
				
			||||||
 | 
							  << "' under the 'sched' VTY node instead.";
 | 
				
			||||||
	rc = sched_setscheduler(getpid(), SCHED_RR, ¶m);
 | 
						rc = sched_setscheduler(getpid(), SCHED_RR, ¶m);
 | 
				
			||||||
	if (rc != 0) {
 | 
						if (rc != 0) {
 | 
				
			||||||
		LOG(ERROR) << "Config: Setting SCHED_RR failed";
 | 
							LOG(ERROR) << "Config: Setting SCHED_RR failed";
 | 
				
			||||||
@@ -589,6 +592,7 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
	vty_init(&g_vty_info);
 | 
						vty_init(&g_vty_info);
 | 
				
			||||||
	logging_vty_add_cmds();
 | 
						logging_vty_add_cmds();
 | 
				
			||||||
	ctrl_vty_init(tall_trx_ctx);
 | 
						ctrl_vty_init(tall_trx_ctx);
 | 
				
			||||||
 | 
						osmo_cpu_sched_vty_init(tall_trx_ctx);
 | 
				
			||||||
	trx_vty_init(g_trx_ctx);
 | 
						trx_vty_init(g_trx_ctx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	osmo_talloc_vty_add_cmds();
 | 
						osmo_talloc_vty_add_cmds();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,6 +27,9 @@
 | 
				
			|||||||
#include <Threads.h>
 | 
					#include <Threads.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#include <osmocom/core/utils.h>
 | 
				
			||||||
 | 
					#include <osmocom/vty/cpu_sched_vty.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "convert.h"
 | 
					#include "convert.h"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -171,6 +174,7 @@ bool RadioInterface::tuneRx(double freq, size_t chan)
 | 
				
			|||||||
void *AlignRadioServiceLoopAdapter(RadioInterface *radioInterface)
 | 
					void *AlignRadioServiceLoopAdapter(RadioInterface *radioInterface)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  set_selfthread_name("AlignRadio");
 | 
					  set_selfthread_name("AlignRadio");
 | 
				
			||||||
 | 
					  OSMO_ASSERT(osmo_cpu_sched_vty_apply_localthread() == 0);
 | 
				
			||||||
  while (1) {
 | 
					  while (1) {
 | 
				
			||||||
    sleep(60);
 | 
					    sleep(60);
 | 
				
			||||||
    radioInterface->alignRadio();
 | 
					    radioInterface->alignRadio();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,13 +9,14 @@ log stderr
 | 
				
			|||||||
line vty
 | 
					line vty
 | 
				
			||||||
 no login
 | 
					 no login
 | 
				
			||||||
!
 | 
					!
 | 
				
			||||||
 | 
					cpu-sched
 | 
				
			||||||
 | 
					 policy rr 18
 | 
				
			||||||
trx
 | 
					trx
 | 
				
			||||||
 bind-ip 127.0.0.1
 | 
					 bind-ip 127.0.0.1
 | 
				
			||||||
 remote-ip 127.0.0.1
 | 
					 remote-ip 127.0.0.1
 | 
				
			||||||
 egprs disable
 | 
					 egprs disable
 | 
				
			||||||
 tx-sps 4
 | 
					 tx-sps 4
 | 
				
			||||||
 rx-sps 4
 | 
					 rx-sps 4
 | 
				
			||||||
 rt-prio 18
 | 
					 | 
				
			||||||
 chan 0
 | 
					 chan 0
 | 
				
			||||||
  tx-path BAND1
 | 
					  tx-path BAND1
 | 
				
			||||||
  rx-path LNAW
 | 
					  rx-path LNAW
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,13 +9,14 @@ log stderr
 | 
				
			|||||||
line vty
 | 
					line vty
 | 
				
			||||||
 no login
 | 
					 no login
 | 
				
			||||||
!
 | 
					!
 | 
				
			||||||
 | 
					cpu-sched
 | 
				
			||||||
 | 
					 policy rr 18
 | 
				
			||||||
trx
 | 
					trx
 | 
				
			||||||
 bind-ip 127.0.0.1
 | 
					 bind-ip 127.0.0.1
 | 
				
			||||||
 remote-ip 127.0.0.1
 | 
					 remote-ip 127.0.0.1
 | 
				
			||||||
 egprs disable
 | 
					 egprs disable
 | 
				
			||||||
 tx-sps 4
 | 
					 tx-sps 4
 | 
				
			||||||
 rx-sps 4
 | 
					 rx-sps 4
 | 
				
			||||||
 rt-prio 18
 | 
					 | 
				
			||||||
 chan 0
 | 
					 chan 0
 | 
				
			||||||
  tx-path BAND1
 | 
					  tx-path BAND1
 | 
				
			||||||
  rx-path LNAW
 | 
					  rx-path LNAW
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,8 @@ log stderr
 | 
				
			|||||||
line vty
 | 
					line vty
 | 
				
			||||||
 no login
 | 
					 no login
 | 
				
			||||||
!
 | 
					!
 | 
				
			||||||
 | 
					cpu-sched
 | 
				
			||||||
 | 
					 policy rr 18
 | 
				
			||||||
trx
 | 
					trx
 | 
				
			||||||
 bind-ip 127.0.0.1
 | 
					 bind-ip 127.0.0.1
 | 
				
			||||||
 remote-ip 127.0.0.1
 | 
					 remote-ip 127.0.0.1
 | 
				
			||||||
@@ -17,6 +19,5 @@ trx
 | 
				
			|||||||
 tx-sps 4
 | 
					 tx-sps 4
 | 
				
			||||||
 rx-sps 4
 | 
					 rx-sps 4
 | 
				
			||||||
 rssi-offset 38
 | 
					 rssi-offset 38
 | 
				
			||||||
 rt-prio 18
 | 
					 | 
				
			||||||
 chan 0
 | 
					 chan 0
 | 
				
			||||||
 chan 1
 | 
					 chan 1
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,8 @@ log stderr
 | 
				
			|||||||
line vty
 | 
					line vty
 | 
				
			||||||
 no login
 | 
					 no login
 | 
				
			||||||
!
 | 
					!
 | 
				
			||||||
 | 
					cpu-sched
 | 
				
			||||||
 | 
					 policy rr 18
 | 
				
			||||||
trx
 | 
					trx
 | 
				
			||||||
 bind-ip 127.0.0.1
 | 
					 bind-ip 127.0.0.1
 | 
				
			||||||
 remote-ip 127.0.0.1
 | 
					 remote-ip 127.0.0.1
 | 
				
			||||||
@@ -19,6 +21,4 @@ trx
 | 
				
			|||||||
 tx-sps 4
 | 
					 tx-sps 4
 | 
				
			||||||
 rx-sps 4
 | 
					 rx-sps 4
 | 
				
			||||||
 clock-ref external
 | 
					 clock-ref external
 | 
				
			||||||
 rt-prio 18
 | 
					 | 
				
			||||||
 chan 0
 | 
					 chan 0
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,6 +31,8 @@ include::{srcdir}/chapters/trx-backends.adoc[]
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
include::{srcdir}/chapters/code-architecture.adoc[]
 | 
					include::{srcdir}/chapters/code-architecture.adoc[]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					include::./common/chapters/vty_cpu_sched.adoc[]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
include::./common/chapters/trx_if.adoc[]
 | 
					include::./common/chapters/trx_if.adoc[]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
include::./common/chapters/port_numbers.adoc[]
 | 
					include::./common/chapters/port_numbers.adoc[]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user