Commit Graph

75 Commits

Author SHA1 Message Date
Oliver Smith 40f5b3ff97 Fix various typos
Change-Id: I2726f18156f96999159f7b5f7c6c5a2d93667131
2023-07-11 12:48:27 +02:00
Pau Espin d38ccedad7 Move paging queue specific handling to signal callback outside RSL code
The signal is already there but not being used.
Let's further split generic paging code from RSL specificites.

Change-Id: Iabc1c29908a5136501d6dc6e60f8777dab511b86
2023-03-31 12:12:21 +02:00
Pau Espin 867e73e96b paging: Optimize retrieving number of request per paging group
This patch caches the counts of initial paging requests for each paging
group. This count is needed to estimate T3113 when a new incoming paging
request is received and it has to be inserted into the queue.
With this there's no need to traverse the whole initial_req_list every
time a new incoming paging request is receiving, potentially saving lots
of iteration and hence lots of CPU when the queue is long.

Related: SYS#6200
Change-Id: I6994127827d120a0b4dd3de51e1ddde39f2fe531
2022-11-30 20:23:39 +01:00
Pau Espin d681b897b6 paging: Replace reqs waiting for retransmission with new incoming inital req if queue is full
If queue size (in transmit delay of requests) is too long (above
threshold) when a new initial incoming request arrives, instead of
directly discarding it, see if we can drop a pending retransmission and
insert the new one instead, in order to avoid losing initial requests.

This is done under the assumption that it is more important to transmit
intial requests than to retransmit already transmitted ones. The
rationale is that there's lower chances that an MS which didn't answer
lately will answer now (aka being reachable at the cell), so it's better
to allocate resources for new requests (new MS) which may be available
in the cell.

Change-Id: Idfd93254ae456b1ee08416e05479488299dd063d
Related: OS#5552
2022-11-30 20:23:34 +01:00
Pau Espin 3b5e898271 paging: Split paging queue into 2 queues: initial and retrans
Initial requests: paging requests which haven't been yet transmitted
Retrans requests: paging requests which have already been transmitted at
least once.
Until now one queue was used (llist) to store both. The initial requests
were stored at the start of the queue in FIFO order. After the last
initial requests, the retrans requests followed also in FIFO.

This ordering was used in order to prioritze scheduling of initial
paging requests over retransmit paging requests.
In the end, having both types in the same list only make code handling
the list more complex.
Hence, this patch splits the shared llist into 2 llists.

Related: SYS#6200
Change-Id: Ib68f2169e3790aea4ac77ec20ad79f242b7c2747
2022-11-30 20:10:35 +01:00
Pau Espin 8c723f5157 paging: Fix wrong count of reqs_before if queue only contains retransmissions
When adding a new incoming request (aka "initial_req"), if the queue is
full only of retransmis (no not-yet-ever-transmitted initial requests
queued), then the new incoming request is inserted at the start of the
queue, in order to take scheduling priority over retransmits.

This was already fine before this patch, but the counting of requests
before it (used to calculate its T3113) was wrong, because it counted all
the retransmissions. This patch fixes it to end up with
reqs_before(_same_group)=0.

Change-Id: Ib2e810b0bcc51eac117713584310272462c58867
2022-11-28 19:01:46 +01:00
Pau Espin 671811f4fc paging: Introduce VTY configurable X3113 (Maximum Paging Request Transmit Delay Threshold)
This allows configuring the maximum delay of paging requests to be
queued according to other parameters, such as MSC paging request
timeouts, etc.

Related: OS#5552
Change-Id: Ia556ef4e474e6a2d0d1618bab680a3330a3c062b
2022-11-28 16:30:12 +01:00
Pau Espin 882602cdd8 paging: paging: Drop unneeded extra param in paging_remove_request()
The BTS can be obtained easily from the backpointer in req->bts. Having
the extra param can only lead to confusion and introduction of bugs, as
happened in bug fixed by Change-Id
I8c6828f86b7ccbb2c4a09ca1aec859a2c597b679.

Related: SYS#6200
Change-Id: I545fd853fdffce7f23f0d99203c66c3b39144e4b
2022-11-24 18:24:47 +01:00
Pau Espin 346c6011bc paging: Fix regression stopping active requests on unanswered BTS
When rewriting the loop, the pointer passed all the time to
paging_remove_request() was the one of the BTS which answered the
request, not the one actually handling the related unanwared still
active paging request.

Fixes: 70a1d60a83
Related: SYS#6200
Change-Id: I8c6828f86b7ccbb2c4a09ca1aec859a2c597b679
2022-11-24 18:14:26 +01:00
Pau Espin 934a9b06c7 paging: constify bts param in some functions
Related: libosmocore.git Change-Id Ib11bfe57f546a5618f70152b9b75115808e54bf6
Change-Id: Icb85fecba142151b05f289adae8894cd50396224
2022-11-24 17:15:36 +01:00
Pau Espin 94951af66a paging: Introduce BTS stat paging:available_slots
This allows analysing the behavior of paging queue at the BTS over time.

Related: SYS#6200
Change-Id: I5f44ac9b9da3ed7120b04d199e52215c0fd3e8a9
2022-11-23 11:09:05 +00:00
Pau Espin a3e5b0db7d paging: Introduce BTS stat paging:request_queue_length
This allows tracking each BTS active paging request queue length over
time, and evaluate CPU load based on the number of active paging
requests queued.

Related: SYS#6200
Change-Id: I6d296cdeba1392ef95fc31f6c04210c73f1b23e5
2022-11-23 11:09:05 +00:00
Pau Espin fd62ac483e paging: Rename stat t3113 -> paging:t3113
This way all paging related stats can be grouped  (more will be added in
follow-up commits).

Related: SYS#6200
Change-Id: Iede1b6f68df468c7a3b3bf5fce7f68bb08b78832
2022-11-23 11:09:05 +00:00
Pau Espin 27cb5d3e24 paging: Use bsub->active_paging_requests to optimize cancelling based on reason
Prior to this patch the whole paging queue of each BTS was iterated.
After the patch only the active paging_req for a given subscriber are
iterated.

Related: SYS#6200
Change-Id: I225d5e08427c6bb9d92ce6a1dccb6ce36053eab5
2022-11-22 19:55:46 +01:00
Pau Espin ccba3a9e4f lcs: Fix passing NULL bsc_subscr to paging_request_cancel()
This is triggered by BSC_Tests.TC_lcs_loc_req_no_subscriber.
Before, the NULL ptr was not a problem because paging_request_cancel()
only used the pointer to compare it against other pointers, but never
accessing it. A follow-up patch is, however, changing the implementation
to optimize the lookup by using the subscriber pointer, which generates
a crash.

Related: SYS#6200
Change-Id: Id0de43ac5bde0f52f258de6c9bf58b173301c8db
2022-11-22 19:55:46 +01:00
Pau Espin 0ed7700c1e paging: Use bsub->active_paging_requests to allow early loop termination adding paging_req
Before this patch, the entire queue of paging_request had to be iterated
in order to find if the subscriber already had an active paging request
(discarding duplicates).

Now that bsc_subscriber holds a list of its active paging requests, it's
easier to look at its list to find out if it is already active on that
BTS.

As a result, there's no need to unconditionally iterate the whole list
and we can optimize the loop finding the spot to insert the new queue:
- First the potentially way smaller loop over
  bsub->active_paging_requests is done
- Second, only if the first loop allowed, the bts->pending_requests is
  iterated and potentially early terminated.

Related: SYS#6200
Change-Id: I7912275026c4d4983269c8870aa5565c93277c5a
2022-11-22 19:55:10 +01:00
Pau Espin 70a1d60a83 paging: Store list of gsm_paging_request in bsc_subscr
This allows havily decreasing the algorithmic cost of removing all
pending active paging requests for a given subscriber once it answers
on a given BTS.

Beforehand, the whole paging queue of all BTS were iterated. Now, only
the active requests for that subscriber are iterated.

Related: SYS#6200
Change-Id: I831d0fe01d7812c34500362b90f47cd65645b666
2022-11-22 19:53:17 +01:00
Pau Espin 2709614011 paging: Get rid of unneeded count returned
The return count is not used since there's no use for it. Get rid of it
to simplify the code.

Change-Id: I7bf04b94173f0ae7b26caf5d7f9abeeb9abf9b6c
2022-11-22 16:05:09 +01:00
Pau Espin ae07416208 paging: Avoid repeated paging req lookup on BTS receiving paging resp
This saves the BSC from iterating twice the whole paging list of the BTS
which received the paging response.

Related: SYS#6200
Change-Id: I5f9215f31428ce0249cd9ece6d2d4e93155f429f
2022-11-22 12:49:13 +01:00
Pau Espin 9f8137dc73 paging: start/stop credit_timer based on C0 running
This way we avoid triggering timers and doing extra poll loops for each
BTS which is configured but not up. It also has the effect of removing
logging about estimating paging buffers for BTS which are down, which
can be confusing.
Furthermore, since work is delayed until the TRX and cell in general is
configured, the first estimation is properly done now since the correct
configuration is in place at that time.

Related: SYS#5922
Change-Id: I1b5b1a98115b4e9d821eb3330fc5b970a0e78a44
2022-05-13 14:06:37 +02:00
Harald Welte d8cfd2fb24 Add stat_item for per-bts [dynamic] T3113 timer
This allows external monitoring to see where the T3113 timer has been
adjusted to, in case it is set dynamically.

Change-Id: I533f2ca3c8e66c143154cbf03b827c9cbbacccdf
2022-05-09 17:50:38 +02:00
Harald Welte 536390a7be paging: Implement upper bound of 60s for dynamic T3113
Change-Id: Ib8228f8485527d34794048a9927e62b6ec8d802a
Closes: OS#5553
2022-05-09 17:50:38 +02:00
Harald Welte 712a6647b1 paging: Avoid queueing more than 60 second estimated requests
Reaching this point will only make system load (CPU, mem) grow, making
it hard for the process to keep up with work to do, with no benefit
since the requests will anyway be scheduled too late.

Related: SYS#5922
Change-Id: I6523c6816a4d16b71084d004e979be40cf0aeeb0
2022-05-09 17:50:38 +02:00
Pau Espin 5a2347d4bc paging: Avoid unnecessary immediate polling in mainloop
We have seen an increased CPU load in osmo-bsc recently since the paging
improvements where merged, centered round poll() calls.
It is expected most of them will be fixed with previous patch. In any
case, let's avoid unnecessary poll() calls being called for no reason.

Related: OS#5922
Change-Id: Ie767bdc8d4353aafe375a424e02d698ef7fd3dea
2022-05-06 13:30:17 +00:00
Pau Espin cdd2bbd8b8 paging: Fix recalculate work timer if waiting for retrans
We want to recalculate the timer based on last time the work_timer was
triggered (that is, the time when the worker re-armed the pag req to
retransmit). We don't want to recalculate based on the last time the pag
ret tro retransmit was scheduled.

In loaded paging queue, there's lots of retrans (let's say 200) and it
may take more than 500ms to actually retransmit them. That means in most
cases we could end up in a situation where only pag req to retrans where
in the queue, hitting this recalculate path. Since the 500ms were for
sure elapsed, that would most probably schedule the work_timer at {0,0}
for each new paging request that arrived. As a result, the worker would
be scheduled lots of times per second (once for each new req arriving)
and only submitting 1 pag req (the new one) plus potentially 1 or
serveral pag req to retransmit.

In summary, there was not throthling applied in the scenario where only
pag req to retransmit where in the queue and new pag reqs kept arriving.
This incurrs into augmented paging throughput and also augmented
frequency of polls().

Related: OS#5922
Fixes: 4821c9f4df
Change-Id: I7ce6f436286b50dc31331d218ff256cf7be3f619
2022-05-06 13:30:17 +00:00
Pau Espin 38db714588 paging: Improve logging
Change-Id: I3186f841623cad8ed3296ac4d541e5cf4701132d
2022-05-06 13:30:17 +00:00
Pau Espin 780c8a76dc paging: Remove TODO comment
That function is used to get the number of paging groups, so it doesn't
apply here.

Change-Id: I980c0961e86d9464235ea9c403adba6b0eded58e
2022-05-04 11:37:06 +02:00
Pau Espin 5f2a4a9fb3 paging: Take into account extra delay of all paging groups in BSC queue
So far we only calculated the expiration time based on the amount of
requests of the same paging group in the BSC queue.
However, also extra time has to be taken into account regarding requests
of other paging groups. This is important because requests of all paging
groups are mixed in the BSC queue, meaning having a lot of requests from
other groups before a certain req will anyway delay transmit of that
req to some extend.

Related: OS#5537
Change-Id: Ib55f947c5d3490b27e1d08d39392992919512f9a
2022-05-03 10:41:22 +02:00
Pau Espin 6b51f3d725 paging: Flush pending paging requests when bts obj freed
Change-Id: I3a81eda48cd44c70a2a690a0814a296ba22eaa8e
2022-05-03 10:27:19 +02:00
Pau Espin ad1f436512 paging: Document 'ccch_load_ind_period * 2' value
Change-Id: Ie88bb0f9859bcf4b3b4a07ccf3b1791cb50163f1
2022-04-29 17:10:57 +02:00
Pau Espin 4821c9f4df paging: Recalculate work timer if waiting for retrans
If the queue is only holding requests in retransmition state, when we
add a new one, we have to re-calculate the work timer to a lower value
instead of letting it wait for the first retransmit to be ready.

Change-Id: Ibd4f8921c92f7481f0b9943041c141640ab812c8
2022-04-28 16:04:04 +02:00
Pau Espin e731301c25 paging: Early stop work_timer when paging queue becomes empty
There's no need to keep the timer running, since anyway upon next
trigger it will simply early exit in paging_handle_pending_requests()
becuase there's no more work to do.

Change-Id: I096ab7231f52c741c5fded37acd5b309e1de06e3
2022-04-28 16:04:04 +02:00
Pau Espin 26d55777fa paging: Increase T3113 based on paging group load in BSC queue
Related: OS#5536
Change-Id: I904c008222ddc3d92843d87fb3182c30b484c8a2
2022-04-28 16:04:04 +02:00
Pau Espin 98ff9bbb2a paging: Improve logging
Change-Id: I8a83352d6f2370bafa5acb0caba6b2f352263b5c
2022-04-28 16:04:04 +02:00
Pau Espin 5cfb63f4b0 paging: Improve calculate_timer_3113()
Depends: libosmocore.git Change-Id I6ef085ee92b2064cb46fa5ec3ae98a0ca59ad599
Change-Id: Id7d6bf93537bcef6658ec72e3ebedcedf64690ed
2022-04-28 16:04:04 +02:00
Pau Espin 1e79745e80 paging: Decouple retransmit period from regular worker interval
Before this patch, on each BTS a 500ms timer was used to schedule some
work, sending up to 20 paging requests verytime.

This means, however, for an initial paging request it may take up to
500ms delay to be scheduled to the BTS, which is huge.

While we still want to maintain this 500ms interval for retransmits, it
doesn't make sense to wait that much for other cases. It's far better
sending less requests (10 instead of 20) every half time (250ms instead
of 500ms), since it will spread the load and paging more over time,
allowing for other work to be done in the middle.

Change-Id: I7a1297452cc4734b6ee8c38fb94cf32f38d57c3d
2022-04-28 16:04:04 +02:00
Pau Espin a6474172e4 paging: Check C0 RSL link instead of OML link
PAging happens over C0 RSL link, not over OML, so let's actually
validate that the C0 RSL link is up before paging instead of the OML
one.

Change-Id: I11e5bb6f952534763935aa01470e514d4af247ed
2022-04-28 16:04:04 +02:00
Pau Espin 525567de74 paging: Rework timer lifecycle logic
Decouple credit_timer from event "available_slots became 0".
Let's actually relate credit_timer to the fact of not receiving CCCH
Load Indication: If no CCCH Load Indication is received (cch_load_ind_period * 2),
then assume we are below CCH Load Indication threshold (10% load) and
start estimating the available_slots in a cch_load_ind_period*2 time
frame.

Moreover, in paging_schedule_if_needed(), there's no use in delaying
start of processing work if the work_timer is not already doing work.

Related: OS#5537
Change-Id: I6a0da03c408270044079e81d431f6641527c00cd
2022-04-28 16:04:04 +02:00
Pau Espin c9ac7cb91f paging: Estimate available_slots based on BTS config when no CCCH Load Ind received
Related: OS#5537
Change-Id: I2df68e10eb549d62765ad3b25429f7fe2d5bb0b9
2022-04-28 16:04:04 +02:00
Pau Espin 0bcd47f014 bts: Make sure paging timers are deleted when struct gsm_bts is freed
Change-Id: If8dffc948a3a9d8bdd9237f644e7f10f41c64853
2022-04-27 10:03:01 +00:00
Pau Espin 08446e5b89 paging: Prioritize requests for new subscribers over retransmitions
Currently, the Tx paging_req queue at the BSC always has new paging
requests adding at the end (as long as the subscriber is not already in
the queue).
That means, if the queue is full of retransmitions, it will take a long
time until the first paging_req is sent towards that subscriber.
The rationale here is that it makes sense to attempt the first paging
ASAP, and give lower prio to paging_req retransmitions, since it may
well be that those other subsribers are not available/reachable and
won't answer.

Related: SYS#5922
Change-Id: I1ae6d97152c458247bc538233b97c2d245196359
2022-04-25 14:12:59 +00:00
Pau Espin 7ed160afd2 paging: Submit up to 20 paging requests in a single work iteration
Having one paging request being sent every PAGING_TIMER (500msec) is too
slow in case BSC is serving lots of subscribers on a BTS. Hence, we want
to send many paging requests at once while still trying not to fill the
BTS buffer.
Morever, we don't want to send tons of paging requests at once, hence we
limit the amount of paging requests sent in one timer iteration
(MAX_PAGE_REQ_PER_ITER) in order to avoid the BSC doing lots of work
there at once, keeping it busy from processing other tasks.

Related: SYS#5922
Change-Id: I609fa67834b426456f48f6fb2acb601c5905f178
2022-04-25 14:12:59 +00:00
Pau Espin 63f9a04bcc paging: Log skip paging due to not enough free channels
Change-Id: I311f90be99c4561b45f99ce98533aab5909301d0
2022-04-25 11:31:16 +02:00
Pau Espin 35778138a8 paging: Use llist_first_entry() macro
Change-Id: I83e88de6f48cc8aad18ed80ab981b0b438e72b1a
2022-04-25 11:31:16 +02:00
Pau Espin fc90e56178 paging: Avoid setting up credit_timer every time
Change-Id: Id4da0ab094ffe939cad9ff5708721e25b5a1a984
2022-04-25 11:31:16 +02:00
Pau Espin 81abce68a6 paging: Use define available in libosmogsm
Change-Id: I6425a9cb1100391404d79ead66dfb1337bbcbcab
2022-04-25 08:35:57 +00:00
Pau Espin e11910a8cf bts: Simplify bts->paging initialization
Related: SYS#5922
Change-Id: Id103d5f3d437065abcd32788caef339343b1e96
2022-04-21 16:08:40 +00:00
Oliver Smith 2df65db3da stats: add bsc.paging:expired
Similar to paging:attempted, count paging:expired not only per BTS, but
also for the whole BSC. Add active_paging_requests to struct bsc_subscr,
to increase the counter only once if paging expires, and not once per
BTS where paging expired.

Related: SYS#4878
Change-Id: I9c118e7e3d61ed8c9f1951111255b196905eba4d
2021-11-29 11:33:34 +01:00
Neels Hofmeyr a5d3c9d0f2 move BSC level stats and rate counters to new bsc_stats.[hc]
Instead of having static const structs in header files (which end up
duplicated in each and every compile unit!), have one .c file with the
rate_ctr and stat_item descriptions.

Related: SYS#5542
Change-Id: I8fd6380b5ae8ed2d3347e7cfbf674c30b6841ed9
2021-08-30 16:18:52 +00:00
Pau Espin 8971d6b98f Use new stat item/ctr getter APIs
Generated with  following and similar spatch snippets:
"""
@@
expression E1, E2;
@@
- &E2->ctr[E1]
+ rate_ctr_group_get_ctr(E2, E1)
"""

Change-Id: I0b43f922a595d694ac0aeda80107ef9bf4e755e7
2021-06-04 17:48:43 +02:00