Attention is currently required from: fixeria, laforge, neels.
neels uploaded patch set #3 to this change.
add osmo_stats_report_lock api
Allow multi-threaded access to reported stats:
- enable use of a stats mutex with osmo_stats_report_use_lock(true).
- lock/unlock externally with osmo_stats_report_lock(true/false).
Rationale:
A mutex lock around stats reporting is a very basic and very powerful
tool. It allows a multi-threaded application to decide which stats
updates will always be in sync.
For example, what if the main thread reports rate counters at exactly
the time a second thread updates rate counter values?
- is writing to stats atomic on a data type level?
- do applications need stats to be "atomic" as a whole?
We probably have (or can make) int64_t atomic, so that individual
counters will always be reported correctly.
But often, separate stats correspond to each other, which should not be
reported out of sync with each other. The simplest way to manage stats
sync in all cases is a mutex around the stats reporting.
But such a mutex isn't needed in most programs, with stats happening in
a single thread only. To completely avoid any overhead the mutex may
bring, make using a mutex optional with a global flag.
Related: SYS#6773
Related: osmo-hnbgw I9dc54e6bc94c553f45adfa71ae8ad70be4afbc8f
Change-Id: Ib335bea7d2a440ca284e6c439066f96456bf2c2d
---
M include/osmocom/core/stats.h
M src/core/libosmocore.map
M src/core/stats.c
M src/vty/stats_vty.c
4 files changed, 126 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/38/36538/3
To view, visit change 36538. To unsubscribe, or for help writing mail filters, visit settings.