Skip to content

Commit

Permalink
npf: Eliminate __HAVE_ATOMIC_AS_MEMBAR conditionals.
Browse files Browse the repository at this point in the history
  • Loading branch information
riastradh committed Feb 24, 2023
1 parent 98b4941 commit 4bd2bfb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
6 changes: 1 addition & 5 deletions sys/net/npf/npf_nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

#ifdef _KERNEL
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: npf_nat.c,v 1.52 2022/04/09 23:38:33 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: npf_nat.c,v 1.53 2023/02/24 11:03:01 riastradh Exp $");

#include <sys/param.h>
#include <sys/types.h>
Expand Down Expand Up @@ -279,15 +279,11 @@ npf_natpolicy_release(npf_natpolicy_t *np)
{
KASSERT(atomic_load_relaxed(&np->n_refcnt) > 0);

#ifndef __HAVE_ATOMIC_AS_MEMBAR
membar_release();
#endif
if (atomic_dec_uint_nv(&np->n_refcnt) != 0) {
return;
}
#ifndef __HAVE_ATOMIC_AS_MEMBAR
membar_acquire();
#endif
KASSERT(LIST_EMPTY(&np->n_nat_list));
mutex_destroy(&np->n_lock);
kmem_free(np, sizeof(npf_natpolicy_t));
Expand Down
7 changes: 2 additions & 5 deletions sys/net/npf/npf_rproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#ifdef _KERNEL
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: npf_rproc.c,v 1.22 2022/04/09 23:38:33 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: npf_rproc.c,v 1.23 2023/02/24 11:03:01 riastradh Exp $");

#include <sys/param.h>
#include <sys/types.h>
Expand Down Expand Up @@ -330,15 +330,12 @@ npf_rproc_release(npf_rproc_t *rp)
{
KASSERT(atomic_load_relaxed(&rp->rp_refcnt) > 0);

#ifndef __HAVE_ATOMIC_AS_MEMBAR
membar_release();
#endif
if (atomic_dec_uint_nv(&rp->rp_refcnt) != 0) {
return;
}
#ifndef __HAVE_ATOMIC_AS_MEMBAR
membar_acquire();
#endif

/* XXXintr */
for (unsigned i = 0; i < rp->rp_ext_count; i++) {
npf_ext_t *ext = rp->rp_ext[i];
Expand Down
6 changes: 1 addition & 5 deletions sys/net/npf/npf_tableset.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#ifdef _KERNEL
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: npf_tableset.c,v 1.41 2023/01/23 13:40:04 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: npf_tableset.c,v 1.42 2023/02/24 11:03:01 riastradh Exp $");

#include <sys/param.h>
#include <sys/types.h>
Expand Down Expand Up @@ -160,14 +160,10 @@ npf_tableset_destroy(npf_tableset_t *ts)

if (t == NULL)
continue;
#ifndef __HAVE_ATOMIC_AS_MEMBAR
membar_release();
#endif
if (atomic_dec_uint_nv(&t->t_refcnt) > 0)
continue;
#ifndef __HAVE_ATOMIC_AS_MEMBAR
membar_acquire();
#endif
npf_table_destroy(t);
}
kmem_free(ts, NPF_TABLESET_SIZE(ts->ts_nitems));
Expand Down

0 comments on commit 4bd2bfb

Please sign in to comment.