Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net/npf npf(4): Use atomic_store_release and atomic_load...
details: https://anonhg.NetBSD.org/src/rev/1e330892c5c5
branches: trunk
changeset: 361553:1e330892c5c5
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Feb 13 19:20:23 2022 +0000
description:
npf(4): Use atomic_store_release and atomic_load_consume for conn_db.
...or atomic_load_relaxed, when npf->conn_lock is held, for the sake
of C11.
No need for store-before-load implied by membar_sync.
diffstat:
sys/net/npf/npf_conn.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diffs (49 lines):
diff -r d16ca8ac9df6 -r 1e330892c5c5 sys/net/npf/npf_conn.c
--- a/sys/net/npf/npf_conn.c Sun Feb 13 19:20:11 2022 +0000
+++ b/sys/net/npf/npf_conn.c Sun Feb 13 19:20:23 2022 +0000
@@ -104,7 +104,7 @@
#ifdef _KERNEL
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_conn.c,v 1.33 2021/01/25 17:18:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_conn.c,v 1.34 2022/02/13 19:20:23 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -221,8 +221,7 @@
KASSERT(atomic_load_relaxed(&npf->conn_tracking)
== CONN_TRACKING_OFF);
odb = atomic_load_relaxed(&npf->conn_db);
- membar_sync();
- atomic_store_relaxed(&npf->conn_db, ndb);
+ atomic_store_release(&npf->conn_db, ndb);
}
if (track) {
/* After this point lookups start flying in. */
@@ -492,7 +491,7 @@
* the connection later.
*/
mutex_enter(&con->c_lock);
- conn_db = atomic_load_relaxed(&npf->conn_db);
+ conn_db = atomic_load_consume(&npf->conn_db);
if (!npf_conndb_insert(conn_db, fw, con, NPF_FLOW_FORW)) {
error = EISCONN;
goto err;
@@ -597,7 +596,7 @@
}
/* Remove the "backwards" key. */
- conn_db = atomic_load_relaxed(&npf->conn_db);
+ conn_db = atomic_load_consume(&npf->conn_db);
bk = npf_conn_getbackkey(con, con->c_alen);
ret = npf_conndb_remove(conn_db, bk);
KASSERT(ret == con);
@@ -762,7 +761,7 @@
void
npf_conn_worker(npf_t *npf)
{
- npf_conndb_t *conn_db = atomic_load_relaxed(&npf->conn_db);
+ npf_conndb_t *conn_db = atomic_load_consume(&npf->conn_db);
npf_conndb_gc(npf, conn_db, false, true);
}
Home |
Main Index |
Thread Index |
Old Index