From owner-dev-commits-src-branches@freebsd.org Thu May 27 11:07:50 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 4690363A143; Thu, 27 May 2021 11:07:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FrQ5f18Wbz3C13; Thu, 27 May 2021 11:07:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0FD4C23118; Thu, 27 May 2021 11:07:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14RB7ncL014024; Thu, 27 May 2021 11:07:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14RB7nOJ014023; Thu, 27 May 2021 11:07:49 GMT (envelope-from git) Date: Thu, 27 May 2021 11:07:49 GMT Message-Id: <202105271107.14RB7nOJ014023@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Lutz Donnerhacke Subject: git: 83a8e97fd3c2 - stable/12 - netgraph/ng_bridge: Avoid cache thrashing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: donner X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 83a8e97fd3c27e9a4a03823705074a0471d0b6cc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 May 2021 11:07:50 -0000 The branch stable/12 has been updated by donner: URL: https://cgit.FreeBSD.org/src/commit/?id=83a8e97fd3c27e9a4a03823705074a0471d0b6cc commit 83a8e97fd3c27e9a4a03823705074a0471d0b6cc Author: Lutz Donnerhacke AuthorDate: 2021-02-11 22:59:11 +0000 Commit: Lutz Donnerhacke CommitDate: 2021-05-27 11:05:00 +0000 netgraph/ng_bridge: Avoid cache thrashing Hint the compiler, that this update is needed at most once per second. Only in this case the memory line needs to be written. This will reduce the amount of cache trashing during forward of most frames. Suggested by: zec Approved by: zec Differential Revision: https://reviews.freebsd.org/D28601 (cherry picked from commit 4dfe70fdbda05453e824bc9edfc0d09eab7b2929) --- sys/netgraph/ng_bridge.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 66dcf03acf2e..5a8c1731aa3f 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -862,7 +862,8 @@ ng_bridge_rcvdata(hook_p hook, item_p item) * This is safe without locking, because it's * the only operation during shared access. */ - host->staleness = 0; + if (__predict_false(host->staleness > 0)) + host->staleness = 0; if ((host == NULL && ctx.incoming->learnMac) || (host != NULL && host->link != ctx.incoming)) {