Change in osmo-bts[master]: bts-trx: reorder first timerfd schedule to decrease first timeout skew

pespin gerrit-no-reply at
Mon Mar 15 17:33:28 UTC 2021

pespin has uploaded this change for review. ( )

Change subject: bts-trx: reorder first timerfd schedule to decrease first timeout skew

bts-trx: reorder first timerfd schedule to decrease first timeout skew

By reordering the instruction, we scheduler the timerfd prior to
processing the FN on the upper layers. This means the first timerfd
expiration even will happen more inline with the expected time, that is,

Let T(trx_sched_fn) be the time spent executing function trx_sched_fn().
With previous order, the timerfd would have been scheduled later, which
in the end would mean expiration would happen at time CLOCK_IND +
GSM_TDMA_FN_DURATION_nS + T(trx_sched_fn), hence ending up with an extra
skew of T(trx_sched_fn) added by ourselves.
This extra skew added may be important specially at startup time (when
this code path is used), since usually the load in the system is high
and skew is usually already higher, which means helping crossing
unacceptable thresholds which may end up in osmo-bts-trx stopping with
"No clock from osmo-trx" reason.

Change-Id: Ie2ba35cd87f0bd4078ac3b4b5ec2eacad36c4258
M src/osmo-bts-trx/scheduler_trx.c
1 file changed, 3 insertions(+), 4 deletions(-)

  git pull ssh:// refs/changes/68/23368/1

diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 6e54d43..efd4954 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -369,15 +369,14 @@
 static int trx_setup_clock(struct gsm_bts *bts, struct osmo_trx_clock_state *tcs,
 	struct timespec *tv_now, const struct timespec *interval, uint32_t fn)
-	tcs->last_fn_timer.fn = fn;
-	/* call trx cheduler function for new 'last' FN */
-	trx_sched_fn(bts, tcs->last_fn_timer.fn);
 	/* schedule first FN clock timer */
 	osmo_timerfd_setup(&tcs->fn_timer_ofd, trx_fn_timer_cb, bts);
 	osmo_timerfd_schedule(&tcs->fn_timer_ofd, NULL, interval);
+	tcs->last_fn_timer.fn = fn;
 	tcs-> = *tv_now;
+	/* call trx scheduler function for new 'last' FN */
+	trx_sched_fn(bts, tcs->last_fn_timer.fn);
 	return 0;

To view, visit
To unsubscribe, or for help writing mail filters, visit

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Ie2ba35cd87f0bd4078ac3b4b5ec2eacad36c4258
Gerrit-Change-Number: 23368
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gerrit-log mailing list