Date: Tue, 9 Feb 2021 20:42:38 +0100 From: Mateusz Guzik <mjguzik@gmail.com> To: Lutz Donnerhacke <donner@freebsd.org> Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 011b7317dbb5 - main - netgraph/ng_bridge: Document staleness in multithreaded operation Message-ID: <CAGudoHFb6=LSs%2BU9_sY%2Bd1bZwEEdcyjuQQzihsctggqYOqYmnQ@mail.gmail.com> In-Reply-To: <202102091925.119JPSho062759@gitrepo.freebsd.org> References: <202102091925.119JPSho062759@gitrepo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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 On 2/9/21, Lutz Donnerhacke <donner@freebsd.org> wrote: > The branch main has been updated by donner: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=011b7317dbb5038a95b9b4fca050325a62f3991e > > commit 011b7317dbb5038a95b9b4fca050325a62f3991e > Author: Lutz Donnerhacke <donner@FreeBSD.org> > AuthorDate: 2021-02-09 11:32:46 +0000 > Commit: Lutz Donnerhacke <donner@FreeBSD.org> > CommitDate: 2021-02-09 19:09:05 +0000 > > netgraph/ng_bridge: Document staleness in multithreaded operation > > In the data path of ng_bridge(4), the only value of the host struct, > which needs to be modified, is the staleness, which is reset every > time a frame is received. It's save to leave the code as it is. > > This patch is part of a series to make ng_bridge(4) multithreaded. > > Reviewed by: kp > MFC after: 2 weeks > Differential Revision: https://reviews.freebsd.org/D28546 > --- > sys/netgraph/ng_bridge.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c > index 6e3f993d591b..29ab2c715aa7 100644 > --- a/sys/netgraph/ng_bridge.c > +++ b/sys/netgraph/ng_bridge.c > @@ -739,7 +739,10 @@ ng_bridge_rcvdata(hook_p hook, item_p item) > > /* Look up packet's source Ethernet address in hashtable */ > if ((host = ng_bridge_get(priv, eh->ether_shost)) != NULL) { > - /* Update time since last heard from this host */ > + /* Update time since last heard from this host. > + * This is safe without locking, because it's > + * the only operation during shared access. > + */ > host->staleness = 0; > > /* Did host jump to a different link? */ > _______________________________________________ > dev-commits-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all > To unsubscribe, send any mail to > "dev-commits-src-all-unsubscribe@freebsd.org" > -- Mateusz Guzik <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGudoHFb6=LSs%2BU9_sY%2Bd1bZwEEdcyjuQQzihsctggqYOqYmnQ>