Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Fix wrong memory order and switch pfil to atomic_loa...



details:   https://anonhg.NetBSD.org/src/rev/cb2365b354e9
branches:  trunk
changeset: 744412:cb2365b354e9
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Feb 01 02:54:31 2020 +0000

description:
Fix wrong memory order and switch pfil to atomic_load/store_*.

diffstat:

 sys/net/pfil.c |  16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

diffs (58 lines):

diff -r 6086d9315add -r cb2365b354e9 sys/net/pfil.c
--- a/sys/net/pfil.c    Sat Feb 01 02:54:02 2020 +0000
+++ b/sys/net/pfil.c    Sat Feb 01 02:54:31 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pfil.c,v 1.35 2017/03/10 07:35:58 ryo Exp $    */
+/*     $NetBSD: pfil.c,v 1.36 2020/02/01 02:54:31 riastradh Exp $      */
 
 /*
  * Copyright (c) 2013 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pfil.c,v 1.35 2017/03/10 07:35:58 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pfil.c,v 1.36 2020/02/01 02:54:31 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_net_mpsafe.h"
@@ -232,8 +232,7 @@
        pfh->pfil_arg  = arg;
 
        /* switch from oldlist to newlist */
-       membar_producer();
-       phlistset->active = newlist;
+       atomic_store_release(&phlistset->active, newlist);
 #ifdef NET_MPSAFE
        pserialize_perform(pfil_psz);
 #endif
@@ -336,8 +335,7 @@
                newlist->nhooks--;
 
                /* switch from oldlist to newlist */
-               phlistset->active = newlist;
-               membar_producer();
+               atomic_store_release(&phlistset->active, newlist);
 #ifdef NET_MPSAFE
                pserialize_perform(pfil_psz);
 #endif
@@ -406,8 +404,7 @@
 
        bound = curlwp_bind();
        s = pserialize_read_enter();
-       phlist = phlistset->active;
-       membar_datadep_consumer();
+       phlist = atomic_load_consume(&phlistset->active);
        psref_acquire(&psref, &phlist->psref, pfil_psref_class);
        pserialize_read_exit(s);
        for (u_int i = 0; i < phlist->nhooks; i++) {
@@ -436,8 +433,7 @@
 
        bound = curlwp_bind();
        s = pserialize_read_enter();
-       phlist = phlistset->active;
-       membar_datadep_consumer();
+       phlist = atomic_load_consume(&phlistset->active);
        psref_acquire(&psref, &phlist->psref, pfil_psref_class);
        pserialize_read_exit(s);
        for (u_int i = 0; i < phlist->nhooks; i++) {



Home | Main Index | Thread Index | Old Index