From owner-dev-commits-src-all@freebsd.org Tue Feb 9 19:42:42 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 0DBCE5290DE; Tue, 9 Feb 2021 19:42:42 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DZtb56KZtz3kt0; Tue, 9 Feb 2021 19:42:41 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x435.google.com with SMTP id z6so23440206wrq.10; Tue, 09 Feb 2021 11:42:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=t4FaPt3ikaJ/gM21Q+TwStAk47VKDCpSF3wXu9Bybrk=; b=TjENia3br3D61iMSURVtUzkr7INbAejDR1E7cqY/ID50+tyx4czvEUMf7JjZcV59Ny flrxQwc8SQJwMaB2Bz1wlmZW25IcSnAEg5jLnk1ORArcQnHfh1Crm6wqoOepT9xLGEDa UUvinMGT7/xlLocVgVacFU8HkZaQm2VqQb596IVyPZHkOIDO55reBephyJU3+rD43vh6 Mgi8B+iOrESxnoIzvIAFqp+qzddlPRTDf/VMnYnv/7IpHH16kuF+yjHUAvgBiFW3/eIw +L/LaRgkGqqj6OHjAGlhIO+57s7laho2lMesV0PAbsnrvl7aTKPEck7uLhuzDjQhqNip LV4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=t4FaPt3ikaJ/gM21Q+TwStAk47VKDCpSF3wXu9Bybrk=; b=KsvZaUgHpTAkKbH50Mb+MaTIX/+ExrTXea9V8/OB9SGVPJRZ2jZ2zruRYJk5W+gTLK UgZ2Fyr2aGFkE/MOnPkbdooelPASy40FN1XozROwrWvqvrL81SplgrlNYd/JSXJSQY1/ xB94VpZo+TQum0GEFbZrCTYQzJYHtEIYItHYcZB/5jsrZ8UO+mABzBy4n7fGZwGpnqik ZIf/Il8IpBka7nGhzufz8xR00ttmZb1AtdqRbp4Q4gsEeTT0cbYTf7g7OfK0LU0WeO0x bc2bbYS/PKFDY0seJW/QDCavqd4+Lt9umAy7qvH1mfU+VBCmt1OLo93SBlFRFfdIswCU 6Q8w== X-Gm-Message-State: AOAM533jRorysHY9VIX1wlnTAn6GAYbM/zusocL2qQAObpOIK6qtPLok gL+1DOEhm9Vrrj8vSxRIbW84Z94z9PJqKTEWftgQKZ2PeGI= X-Google-Smtp-Source: ABdhPJz9ROuTHzYqXxqZO3nDVvETYsD8m2Czwo9onWMzJnTjq5/egG/qKFHIc+PuXHTfhmvgk07kaBD0TTlWoMlBhb0= X-Received: by 2002:a05:6000:1565:: with SMTP id 5mr28044591wrz.109.1612899759560; Tue, 09 Feb 2021 11:42:39 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a5d:464c:0:0:0:0:0 with HTTP; Tue, 9 Feb 2021 11:42:38 -0800 (PST) In-Reply-To: <202102091925.119JPSho062759@gitrepo.freebsd.org> References: <202102091925.119JPSho062759@gitrepo.freebsd.org> From: Mateusz Guzik Date: Tue, 9 Feb 2021 20:42:38 +0100 Message-ID: Subject: Re: git: 011b7317dbb5 - main - netgraph/ng_bridge: Document staleness in multithreaded operation To: Lutz Donnerhacke Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4DZtb56KZtz3kt0 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 19:42:42 -0000 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 wrote: > The branch main has been updated by donner: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=011b7317dbb5038a95b9b4fca050325a62f3991e > > commit 011b7317dbb5038a95b9b4fca050325a62f3991e > Author: Lutz Donnerhacke > AuthorDate: 2021-02-09 11:32:46 +0000 > Commit: Lutz Donnerhacke > 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