Change in ...osmo-trx[master]: Add option to set stack size in config file, default == 0 == OS default

Hoernchen gerrit-no-reply at lists.osmocom.org
Mon Jun 17 12:57:20 UTC 2019


Hoernchen has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-trx/+/14488 )

Change subject: Add option to set stack size in config file, default == 0 == OS default
......................................................................

Add option to set stack size in config file, default == 0 == OS default

Change-Id: Id752f6b5ce9a96a67cd1ff835687ce0e03d3a50d
---
M CommonLibs/Threads.cpp
M CommonLibs/Threads.h
M CommonLibs/trx_vty.c
M CommonLibs/trx_vty.h
M Transceiver52M/Transceiver.cpp
M Transceiver52M/Transceiver.h
M Transceiver52M/osmo-trx.cpp
M doc/manuals/vty/trx_vty_reference.xml
8 files changed, 38 insertions(+), 12 deletions(-)

Approvals:
  pespin: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/CommonLibs/Threads.cpp b/CommonLibs/Threads.cpp
index c056d69..ccea1e7 100644
--- a/CommonLibs/Threads.cpp
+++ b/CommonLibs/Threads.cpp
@@ -135,8 +135,10 @@
 	// (pat) Moved initialization to constructor to avoid crash in destructor.
 	//res = pthread_attr_init(&mAttrib);
 	//assert(!res);
-	res = pthread_attr_setstacksize(&mAttrib, mStackSize);
-	assert(!res);
+	if (mStackSize != 0) {
+		res = pthread_attr_setstacksize(&mAttrib, mStackSize);
+		assert(!res);
+	}
 	res = pthread_create(&mThread, &mAttrib, task, arg);
 	assert(!res);
 }
diff --git a/CommonLibs/Threads.h b/CommonLibs/Threads.h
index 4c5b9ee..8a6ba47 100644
--- a/CommonLibs/Threads.h
+++ b/CommonLibs/Threads.h
@@ -158,7 +158,7 @@
 	public:
 
 	/** Create a thread in a non-running state. */
-	Thread(size_t wStackSize = (65536*4)):mThread((pthread_t)0) {
+	Thread(size_t wStackSize = 0):mThread((pthread_t)0) {
 		pthread_attr_init(&mAttrib);	// (pat) moved this here.
 		mStackSize=wStackSize;
 	}
diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c
index 4cc827b..795ec7b 100644
--- a/CommonLibs/trx_vty.c
+++ b/CommonLibs/trx_vty.c
@@ -336,6 +336,18 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_stack_size, cfg_stack_size_cmd,
+	"stack-size <0-2147483647>",
+	"Set the stack size per thread in BYTE, 0 = OS default\n"
+	"Stack size per thread in BYTE\n")
+{
+	struct trx_ctx *trx = trx_from_vty(vty);
+
+	trx->cfg.stack_size = atoi(argv[0]);
+
+	return CMD_SUCCESS;
+}
+
 DEFUN(cfg_filler, cfg_filler_cmd,
 	"filler dummy",
 	"Enable C0 filler table\n"
@@ -546,6 +558,8 @@
 	vty_out(vty, " ext-rach %s%s", trx->cfg.ext_rach ? "enable" : "disable", VTY_NEWLINE);
 	if (trx->cfg.sched_rr != 0)
 		vty_out(vty, " rt-prio %u%s", trx->cfg.sched_rr, VTY_NEWLINE);
+	if (trx->cfg.stack_size != 0)
+		vty_out(vty, " stack-size %u%s", trx->cfg.stack_size, VTY_NEWLINE);
 	trx_rate_ctr_threshold_write_config(vty, " ");
 
 	for (i = 0; i < trx->cfg.num_chans; i++) {
@@ -585,6 +599,7 @@
 	vty_out(vty, " Extended RACH support: %s%s", trx->cfg.ext_rach ? "Enabled" : "Disabled", VTY_NEWLINE);
 	vty_out(vty, " Real Time Priority: %u (%s)%s", trx->cfg.sched_rr,
 		trx->cfg.sched_rr ? "Enabled" : "Disabled", VTY_NEWLINE);
+	vty_out(vty, " Stack size per Thread in BYTE (0 = OS default): %u%s", trx->cfg.stack_size, VTY_NEWLINE);
 	vty_out(vty, " Channels: %u%s", trx->cfg.num_chans, VTY_NEWLINE);
 	for (i = 0; i < trx->cfg.num_chans; i++) {
 		chan = &trx->cfg.chans[i];
@@ -698,6 +713,7 @@
 	install_element(TRX_NODE, &cfg_filler_cmd);
 	install_element(TRX_NODE, &cfg_ctr_error_threshold_cmd);
 	install_element(TRX_NODE, &cfg_no_ctr_error_threshold_cmd);
+	install_element(TRX_NODE, &cfg_stack_size_cmd);
 
 	install_element(TRX_NODE, &cfg_chan_cmd);
 	install_node(&chan_node, dummy_config_write);
diff --git a/CommonLibs/trx_vty.h b/CommonLibs/trx_vty.h
index 8e91113..d939051 100644
--- a/CommonLibs/trx_vty.h
+++ b/CommonLibs/trx_vty.h
@@ -63,6 +63,7 @@
 		bool ext_rach;
 		bool egprs;
 		unsigned int sched_rr;
+		unsigned int stack_size;
 		unsigned int num_chans;
 		struct trx_chan chans[TRX_CHAN_MAX];
 	} cfg;
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index 9c55d02..0aa4ff5 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -115,11 +115,11 @@
                          size_t tx_sps, size_t rx_sps, size_t chans,
                          GSM::Time wTransmitLatency,
                          RadioInterface *wRadioInterface,
-                         double wRssiOffset)
+                         double wRssiOffset, int wStackSize)
   : mBasePort(wBasePort), mLocalAddr(TRXAddress), mRemoteAddr(GSMcoreAddress),
     mClockSocket(TRXAddress, wBasePort, GSMcoreAddress, wBasePort + 100),
     mTransmitLatency(wTransmitLatency), mRadioInterface(wRadioInterface),
-    rssiOffset(wRssiOffset),
+    rssiOffset(wRssiOffset), stackSize(wStackSize),
     mSPSTx(tx_sps), mSPSRx(rx_sps), mChans(chans), mEdge(false), mOn(false), mForceClockInterface(false),
     mTxFreq(0.0), mRxFreq(0.0), mTSC(0), mMaxExpectedDelayAB(0), mMaxExpectedDelayNB(0),
     mWriteBurstToDiskMask(0)
@@ -212,7 +212,7 @@
   /* Start control threads */
   for (size_t i = 0; i < mChans; i++) {
     TransceiverChannel *chan = new TransceiverChannel(this, i);
-    mControlServiceLoopThreads[i] = new Thread(32768);
+    mControlServiceLoopThreads[i] = new Thread(stackSize);
     mControlServiceLoopThreads[i]->start((void * (*)(void*))
                                  ControlServiceLoopAdapter, (void*) chan);
 
@@ -254,8 +254,8 @@
   }
 
   /* Device is running - launch I/O threads */
-  mRxLowerLoopThread = new Thread(32768);
-  mTxLowerLoopThread = new Thread(32768);
+  mRxLowerLoopThread = new Thread(stackSize);
+  mTxLowerLoopThread = new Thread(stackSize);
   mTxLowerLoopThread->start((void * (*)(void*))
                             TxLowerLoopAdapter,(void*) this);
   mRxLowerLoopThread->start((void * (*)(void*))
@@ -264,12 +264,12 @@
   /* Launch uplink and downlink burst processing threads */
   for (size_t i = 0; i < mChans; i++) {
     TransceiverChannel *chan = new TransceiverChannel(this, i);
-    mRxServiceLoopThreads[i] = new Thread(32768);
+    mRxServiceLoopThreads[i] = new Thread(stackSize);
     mRxServiceLoopThreads[i]->start((void * (*)(void*))
                             RxUpperLoopAdapter, (void*) chan);
 
     chan = new TransceiverChannel(this, i);
-    mTxPriorityQueueServiceLoopThreads[i] = new Thread(32768);
+    mTxPriorityQueueServiceLoopThreads[i] = new Thread(stackSize);
     mTxPriorityQueueServiceLoopThreads[i]->start((void * (*)(void*))
                             TxUpperLoopAdapter, (void*) chan);
   }
diff --git a/Transceiver52M/Transceiver.h b/Transceiver52M/Transceiver.h
index 4614efe..ceb8c4a 100644
--- a/Transceiver52M/Transceiver.h
+++ b/Transceiver52M/Transceiver.h
@@ -108,7 +108,7 @@
               size_t tx_sps, size_t rx_sps, size_t chans,
               GSM::Time wTransmitLatency,
               RadioInterface *wRadioInterface,
-              double wRssiOffset);
+              double wRssiOffset, int stackSize);
 
   /** Destructor */
   ~Transceiver();
@@ -178,6 +178,7 @@
   double rxFullScale;                     ///< full scale output to radio
 
   double rssiOffset;                      ///< RSSI to dBm conversion offset
+  int stackSize;                      ///< stack size for threads, 0 = OS default
 
   /** modulate and add a burst to the transmit queue */
   void addRadioVector(size_t chan, BitVector &bits,
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index 05489bd..06b1a18 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -145,7 +145,7 @@
 	transceiver = new Transceiver(trx->cfg.base_port, trx->cfg.bind_addr,
 			      trx->cfg.remote_addr, trx->cfg.tx_sps,
 			      trx->cfg.rx_sps, trx->cfg.num_chans, GSM::Time(3,0),
-			      radio, trx->cfg.rssi_offset);
+			      radio, trx->cfg.rssi_offset, trx->cfg.stack_size);
 	if (!transceiver->init(trx->cfg.filler, trx->cfg.rtsc,
 		       trx->cfg.rach_delay, trx->cfg.egprs, trx->cfg.ext_rach)) {
 		LOG(ALERT) << "Failed to initialize transceiver";
diff --git a/doc/manuals/vty/trx_vty_reference.xml b/doc/manuals/vty/trx_vty_reference.xml
index e448a46..ce6d335 100644
--- a/doc/manuals/vty/trx_vty_reference.xml
+++ b/doc/manuals/vty/trx_vty_reference.xml
@@ -1247,6 +1247,12 @@
         <param name='<1-32>' doc='Real time priority' />
       </params>
     </command>
+    <command id='stack-size <0-2147483647>'>
+      <params>
+        <param name='stack-size' doc='Set the stack size for the spawned threads' />
+        <param name='<0-2147483647>' doc='Stack size in BYTE' />
+      </params>
+    </command>
     <command id='filler dummy'>
       <params>
         <param name='filler' doc='Enable C0 filler table' />

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/14488
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: Id752f6b5ce9a96a67cd1ff835687ce0e03d3a50d
Gerrit-Change-Number: 14488
Gerrit-PatchSet: 3
Gerrit-Owner: Hoernchen <ewild at sysmocom.de>
Gerrit-Reviewer: Hoernchen <ewild at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190617/39a0ebe3/attachment.html>


More information about the gerrit-log mailing list