aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-03-15 18:24:59 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2021-03-15 18:33:14 +0100
commit29c4f3173f80cd7fecb1bb69c318a4a5894b156d (patch)
treeed8daf5ff94d76492949d8f83474cecf0e014d38 /src
parent8593b386167e285b467d1a8b4feb3842f83dd211 (diff)
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, CLOCK IND time + GSM_TDMA_FN_DURATION_nS. 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
Diffstat (limited to 'src')
-rw-r--r--src/osmo-bts-trx/scheduler_trx.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 6e54d43d..efd49543 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -369,15 +369,14 @@ int trx_sched_clock_stopped(struct gsm_bts *bts)
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->last_fn_timer.tv = *tv_now;
+ /* call trx scheduler function for new 'last' FN */
+ trx_sched_fn(bts, tcs->last_fn_timer.fn);
return 0;
}