git: 011b7317dbb5 - main - netgraph/ng_bridge: Document staleness in multithreaded operation

Lutz Donnerhacke lutz at donnerhacke.de
Tue Feb 9 20:32:25 UTC 2021


On Tue, Feb 09, 2021 at 08:42:38PM +0100, Mateusz Guzik wrote:
> Things like this are best sorted out with atomic_store, otherwise you
> may fall victim of various compiler mischief (even if it happens to be
> harmless for the time being).
> 
> iow all ->staleness accesses should be converted to atomic_*.
> 
> grep finds this in ng_bridge_timeout:
> 
>                         if (++host->staleness >= priv->conf.maxStaleness) {
> 
> the code should probably explain how this is synchronized against said zeroing

There is no risk, because all other access to this variable is done under a
WRITER lock of the whole node.  Even this one, you are quoting here.  The
lock comes from the netgraph framework itself.

The only remaining access, which can be run in parallel, is the mentioned
setting to zero.  In order to document all this reasoning the comment was
extended.

At the moment the ng_bridge(4) node is completely singlethreaded, any call
runs under the WRITER lock.  The purpose of all the commits and all the open
reviews are to remove this limitation in order to give the node a major
performance boost.


More information about the dev-commits-src-main mailing list