Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 May 2021 11:07:49 GMT
From:      Lutz Donnerhacke <donner@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 83a8e97fd3c2 - stable/12 - netgraph/ng_bridge: Avoid cache thrashing
Message-ID:  <202105271107.14RB7nOJ014023@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by donner:

URL: https://cgit.FreeBSD.org/src/commit/?id=83a8e97fd3c27e9a4a03823705074a0471d0b6cc

commit 83a8e97fd3c27e9a4a03823705074a0471d0b6cc
Author:     Lutz Donnerhacke <donner@FreeBSD.org>
AuthorDate: 2021-02-11 22:59:11 +0000
Commit:     Lutz Donnerhacke <donner@FreeBSD.org>
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)) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105271107.14RB7nOJ014023>