Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Use if_acquire and if_release instead of using psref API...
details: https://anonhg.NetBSD.org/src/rev/dbbb760ab2b6
branches: trunk
changeset: 352078:dbbb760ab2b6
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Tue Mar 14 09:03:08 2017 +0000
description:
Use if_acquire and if_release instead of using psref API directly
- Provide if_release for consistency to if_acquire
- Use if_acquire and if_release for ifp iterations
- Make ifnet_psref_class static
diffstat:
sys/altq/altq_subr.c | 8 ++++----
sys/compat/common/uipc_syscalls_40.c | 10 +++++-----
sys/compat/linux/common/linux_socket.c | 10 +++++-----
sys/compat/linux32/common/linux32_socket.c | 10 +++++-----
sys/dist/pf/net/pf_if.c | 12 ++++++------
sys/kern/uipc_mbuf.c | 10 ++++------
sys/net/if.c | 6 +++---
sys/net/if.h | 4 ++--
sys/net/rtsock.c | 10 +++++-----
sys/netinet/ip_carp.c | 8 ++++----
sys/rump/librump/rumpnet/net_stub.c | 5 ++---
11 files changed, 45 insertions(+), 48 deletions(-)
diffs (truncated from 414 to 300 lines):
diff -r 0ed28ff06122 -r dbbb760ab2b6 sys/altq/altq_subr.c
--- a/sys/altq/altq_subr.c Tue Mar 14 08:35:55 2017 +0000
+++ b/sys/altq/altq_subr.c Tue Mar 14 09:03:08 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: altq_subr.c,v 1.32 2016/06/20 08:30:58 knakahara Exp $ */
+/* $NetBSD: altq_subr.c,v 1.33 2017/03/14 09:03:08 ozaki-r Exp $ */
/* $KAME: altq_subr.c,v 1.24 2005/04/13 03:44:25 suz Exp $ */
/*
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: altq_subr.c,v 1.32 2016/06/20 08:30:58 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_subr.c,v 1.33 2017/03/14 09:03:08 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_altq.h"
@@ -360,7 +360,7 @@
struct psref psref;
if (!TBR_IS_ENABLED(&ifp->if_snd))
continue;
- psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_acquire(ifp, &psref);
pserialize_read_exit(s);
active++;
@@ -371,7 +371,7 @@
}
s = pserialize_read_enter();
- psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_release(ifp, &psref);
}
pserialize_read_exit(s);
diff -r 0ed28ff06122 -r dbbb760ab2b6 sys/compat/common/uipc_syscalls_40.c
--- a/sys/compat/common/uipc_syscalls_40.c Tue Mar 14 08:35:55 2017 +0000
+++ b/sys/compat/common/uipc_syscalls_40.c Tue Mar 14 09:03:08 2017 +0000
@@ -1,9 +1,9 @@
-/* $NetBSD: uipc_syscalls_40.c,v 1.12 2016/08/01 03:15:30 ozaki-r Exp $ */
+/* $NetBSD: uipc_syscalls_40.c,v 1.13 2017/03/14 09:03:08 ozaki-r Exp $ */
/* written by Pavel Cahyna, 2006. Public domain. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.12 2016/08/01 03:15:30 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.13 2017/03/14 09:03:08 ozaki-r Exp $");
/*
* System call interface to the socket abstraction.
@@ -52,7 +52,7 @@
IFNET_READER_FOREACH(ifp) {
struct ifaddr *ifa;
- psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_acquire(ifp, &psref);
(void)strncpy(ifr.ifr_name, ifp->if_xname,
sizeof(ifr.ifr_name));
@@ -126,7 +126,7 @@
space -= sz;
}
- psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_release(ifp, &psref);
}
pserialize_read_exit(s);
curlwp_bindx(bound);
@@ -139,7 +139,7 @@
release_exit:
pserialize_read_exit(s);
- psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_release(ifp, &psref);
curlwp_bindx(bound);
return error;
}
diff -r 0ed28ff06122 -r dbbb760ab2b6 sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c Tue Mar 14 08:35:55 2017 +0000
+++ b/sys/compat/linux/common/linux_socket.c Tue Mar 14 09:03:08 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_socket.c,v 1.137 2017/02/03 16:57:39 christos Exp $ */
+/* $NetBSD: linux_socket.c,v 1.138 2017/03/14 09:03:08 ozaki-r Exp $ */
/*-
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.137 2017/02/03 16:57:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.138 2017/03/14 09:03:08 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -1143,7 +1143,7 @@
s = pserialize_read_enter();
IFNET_READER_FOREACH(ifp) {
struct ifaddr *ifa;
- psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_acquire(ifp, &psref);
(void)strncpy(ifr.ifr_name, ifp->if_xname,
sizeof(ifr.ifr_name));
@@ -1179,7 +1179,7 @@
ifa_release(ifa, &psref_ifa);
}
- psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_release(ifp, &psref);
}
pserialize_read_exit(s);
curlwp_bindx(bound);
@@ -1193,7 +1193,7 @@
release_exit:
pserialize_read_exit(s);
- psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_release(ifp, &psref);
curlwp_bindx(bound);
return error;
}
diff -r 0ed28ff06122 -r dbbb760ab2b6 sys/compat/linux32/common/linux32_socket.c
--- a/sys/compat/linux32/common/linux32_socket.c Tue Mar 14 08:35:55 2017 +0000
+++ b/sys/compat/linux32/common/linux32_socket.c Tue Mar 14 09:03:08 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_socket.c,v 1.26 2016/08/01 03:15:30 ozaki-r Exp $ */
+/* $NetBSD: linux32_socket.c,v 1.27 2017/03/14 09:03:08 ozaki-r Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.26 2016/08/01 03:15:30 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.27 2017/03/14 09:03:08 ozaki-r Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -441,7 +441,7 @@
s = pserialize_read_enter();
IFNET_READER_FOREACH(ifp) {
struct ifaddr *ifa;
- psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_acquire(ifp, &psref);
(void)strncpy(ifr.ifr_name, ifp->if_xname,
sizeof(ifr.ifr_name));
@@ -477,7 +477,7 @@
ifa_release(ifa, &psref_ifa);
}
- psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_release(ifp, &psref);
}
pserialize_read_exit(s);
curlwp_bindx(bound);
@@ -491,7 +491,7 @@
release_exit:
pserialize_read_exit(s);
- psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_release(ifp, &psref);
curlwp_bindx(bound);
return error;
}
diff -r 0ed28ff06122 -r dbbb760ab2b6 sys/dist/pf/net/pf_if.c
--- a/sys/dist/pf/net/pf_if.c Tue Mar 14 08:35:55 2017 +0000
+++ b/sys/dist/pf/net/pf_if.c Tue Mar 14 09:03:08 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pf_if.c,v 1.32 2016/12/26 23:21:49 christos Exp $ */
+/* $NetBSD: pf_if.c,v 1.33 2017/03/14 09:03:08 ozaki-r Exp $ */
/* $OpenBSD: pf_if.c,v 1.47 2007/07/13 09:17:48 markus Exp $ */
/*
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.32 2016/12/26 23:21:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.33 2017/03/14 09:03:08 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -126,14 +126,14 @@
s = pserialize_read_enter();
IFNET_READER_FOREACH(ifp) {
struct psref psref;
- psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_acquire(ifp, &psref);
pserialize_read_exit(s);
pfi_init_groups(ifp);
pfi_attach_ifnet(ifp);
s = pserialize_read_enter();
- psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_release(ifp, &psref);
}
pserialize_read_exit(s);
curlwp_bindx(bound);
@@ -159,14 +159,14 @@
s = pserialize_read_enter();
IFNET_READER_FOREACH(ifp) {
struct psref psref;
- psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_acquire(ifp, &psref);
pserialize_read_exit(s);
pfi_detach_ifnet(ifp);
pfi_destroy_groups(ifp);
s = pserialize_read_enter();
- psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
+ if_release(ifp, &psref);
}
pserialize_read_exit(s);
curlwp_bindx(bound);
diff -r 0ed28ff06122 -r dbbb760ab2b6 sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c Tue Mar 14 08:35:55 2017 +0000
+++ b/sys/kern/uipc_mbuf.c Tue Mar 14 09:03:08 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_mbuf.c,v 1.170 2017/01/09 14:25:52 christos Exp $ */
+/* $NetBSD: uipc_mbuf.c,v 1.171 2017/03/14 09:03:08 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.170 2017/01/09 14:25:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.171 2017/03/14 09:03:08 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_mbuftrace.h"
@@ -562,14 +562,12 @@
IFNET_READER_FOREACH(ifp) {
struct psref psref;
- psref_acquire(&psref, &ifp->if_psref,
- ifnet_psref_class);
+ if_acquire(ifp, &psref);
if (ifp->if_drain)
(*ifp->if_drain)(ifp);
- psref_release(&psref, &ifp->if_psref,
- ifnet_psref_class);
+ if_release(ifp, &psref);
}
curlwp_bindx(bound);
}
diff -r 0ed28ff06122 -r dbbb760ab2b6 sys/net/if.c
--- a/sys/net/if.c Tue Mar 14 08:35:55 2017 +0000
+++ b/sys/net/if.c Tue Mar 14 09:03:08 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.384 2017/03/14 04:25:10 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.385 2017/03/14 09:03:08 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.384 2017/03/14 04:25:10 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.385 2017/03/14 09:03:08 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -176,7 +176,7 @@
static uint64_t index_gen;
/* Mutex to protect the above objects. */
kmutex_t ifnet_mtx __cacheline_aligned;
-struct psref_class *ifnet_psref_class __read_mostly;
+static struct psref_class *ifnet_psref_class __read_mostly;
static pserialize_t ifnet_psz;
static kmutex_t if_clone_mtx;
diff -r 0ed28ff06122 -r dbbb760ab2b6 sys/net/if.h
--- a/sys/net/if.h Tue Mar 14 08:35:55 2017 +0000
+++ b/sys/net/if.h Tue Mar 14 09:03:08 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.235 2017/02/23 07:57:10 ozaki-r Exp $ */
+/* $NetBSD: if.h,v 1.236 2017/03/14 09:03:08 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -975,6 +975,7 @@
ifnet_t *if_get_byindex(u_int, struct psref *);
void if_put(const struct ifnet *, struct psref *);
void if_acquire(struct ifnet *, struct psref *);
+#define if_release if_put
static inline if_index_t
if_get_index(const struct ifnet *ifp)
@@ -1170,7 +1171,6 @@
Home |
Main Index |
Thread Index |
Old Index