From owner-dev-commits-src-all@freebsd.org Tue Feb 9 20:32:24 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ECA3D52A396; Tue, 9 Feb 2021 20:32:24 +0000 (UTC) (envelope-from lutz@iks-jena.de) Received: from annwfn.iks-jena.de (annwfn.iks-jena.de [IPv6:2001:4bd8::19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DZvhS4dZPz3p8C; Tue, 9 Feb 2021 20:32:24 +0000 (UTC) (envelope-from lutz@iks-jena.de) X-SMTP-Sender: IPv6:2001:4bd8:0:666:248:54ff:fe12:ee3f Received: from belenus.iks-jena.de (belenus.iks-jena.de [IPv6:2001:4bd8:0:666:248:54ff:fe12:ee3f]) by annwfn.iks-jena.de (8.15.2/8.15.2) with ESMTPS id 119KWAF1016221 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 9 Feb 2021 21:32:11 +0100 X-MSA-Host: belenus.iks-jena.de Received: (from lutz@localhost) by belenus.iks-jena.de (8.14.3/8.14.1/Submit) id 119KWAuR016420; Tue, 9 Feb 2021 21:32:10 +0100 Date: Tue, 9 Feb 2021 21:32:10 +0100 From: Lutz Donnerhacke To: Mateusz Guzik 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: <20210209203210.GA16222@belenus.iks-jena.de> References: <202102091925.119JPSho062759@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-message-flag: Please send plain text messages only. Thank you. User-Agent: Mutt/1.5.17 (2007-11-01) X-Rspamd-Queue-Id: 4DZvhS4dZPz3p8C X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Feb 2021 20:32:25 -0000 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.