Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Add __cacheline_aligned to ppp softc list and its mu...
details: https://anonhg.NetBSD.org/src/rev/571002d97a1f
branches: trunk
changeset: 996237:571002d97a1f
user: knakahara <knakahara%NetBSD.org@localhost>
date: Fri Jan 25 08:51:29 2019 +0000
description:
Add __cacheline_aligned to ppp softc list and its mutex just in case.
diffstat:
sys/net/if_ppp.c | 43 +++++++++++++++++++++++--------------------
1 files changed, 23 insertions(+), 20 deletions(-)
diffs (135 lines):
diff -r c51c6f897176 -r 571002d97a1f sys/net/if_ppp.c
--- a/sys/net/if_ppp.c Fri Jan 25 08:04:07 2019 +0000
+++ b/sys/net/if_ppp.c Fri Jan 25 08:51:29 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ppp.c,v 1.163 2019/01/11 02:57:21 knakahara Exp $ */
+/* $NetBSD: if_ppp.c,v 1.164 2019/01/25 08:51:29 knakahara Exp $ */
/* Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp */
/*
@@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.163 2019/01/11 02:57:21 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.164 2019/01/25 08:51:29 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "ppp.h"
@@ -206,8 +206,11 @@
static struct ppp_softc *ppp_create(const char *, int);
-static LIST_HEAD(, ppp_softc) ppp_softc_list;
-static kmutex_t ppp_list_lock;
+LIST_HEAD(ppp_sclist, ppp_softc);
+static struct {
+ struct ppp_sclist list;
+ kmutex_t lock;
+} ppp_softcs __cacheline_aligned;
struct if_clone ppp_cloner =
IF_CLONE_INITIALIZER("ppp", ppp_clone_create, ppp_clone_destroy);
@@ -245,8 +248,8 @@
if (ttyldisc_attach(&ppp_disc) != 0)
panic("%s", __func__);
- mutex_init(&ppp_list_lock, MUTEX_DEFAULT, IPL_NONE);
- LIST_INIT(&ppp_softc_list);
+ mutex_init(&ppp_softcs.lock, MUTEX_DEFAULT, IPL_NONE);
+ LIST_INIT(&ppp_softcs.list);
if_clone_attach(&ppp_cloner);
}
@@ -255,14 +258,14 @@
{
int error = 0;
- if (!LIST_EMPTY(&ppp_softc_list))
+ if (!LIST_EMPTY(&ppp_softcs.list))
error = EBUSY;
if (error == 0)
error = ttyldisc_detach(&ppp_disc);
if (error == 0) {
- mutex_destroy(&ppp_list_lock);
+ mutex_destroy(&ppp_softcs.lock);
if_clone_detach(&ppp_cloner);
ppp_compressor_destroy();
}
@@ -277,10 +280,10 @@
sc = malloc(sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO);
- mutex_enter(&ppp_list_lock);
+ mutex_enter(&ppp_softcs.lock);
if (unit == -1) {
int i = 0;
- LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) {
+ LIST_FOREACH(sci, &ppp_softcs.list, sc_iflist) {
scl = sci;
if (i < sci->sc_unit) {
unit = i;
@@ -295,13 +298,13 @@
if (unit == -1)
unit = i;
} else {
- LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) {
+ LIST_FOREACH(sci, &ppp_softcs.list, sc_iflist) {
scl = sci;
if (unit < sci->sc_unit)
break;
else if (unit == sci->sc_unit) {
free(sc, M_DEVBUF);
- mutex_exit(&ppp_list_lock);
+ mutex_exit(&ppp_softcs.lock);
return NULL;
}
}
@@ -312,9 +315,9 @@
else if (scl != NULL)
LIST_INSERT_AFTER(scl, sc, sc_iflist);
else
- LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_iflist);
+ LIST_INSERT_HEAD(&ppp_softcs.list, sc, sc_iflist);
- mutex_exit(&ppp_list_lock);
+ mutex_exit(&ppp_softcs.lock);
if_initname(&sc->sc_if, name, sc->sc_unit = unit);
callout_init(&sc->sc_timo_ch, 0);
@@ -356,9 +359,9 @@
if (sc->sc_devp != NULL)
return EBUSY; /* Not removing it */
- mutex_enter(&ppp_list_lock);
+ mutex_enter(&ppp_softcs.lock);
LIST_REMOVE(sc, sc_iflist);
- mutex_exit(&ppp_list_lock);
+ mutex_exit(&ppp_softcs.lock);
bpf_detach(ifp);
if_detach(ifp);
@@ -376,17 +379,17 @@
struct ppp_softc *sc = NULL, *scf;
int i;
- mutex_enter(&ppp_list_lock);
- LIST_FOREACH(scf, &ppp_softc_list, sc_iflist) {
+ mutex_enter(&ppp_softcs.lock);
+ LIST_FOREACH(scf, &ppp_softcs.list, sc_iflist) {
if (scf->sc_xfer == pid) {
scf->sc_xfer = 0;
- mutex_exit(&ppp_list_lock);
+ mutex_exit(&ppp_softcs.lock);
return scf;
}
if (scf->sc_devp == NULL && sc == NULL)
sc = scf;
}
- mutex_exit(&ppp_list_lock);
+ mutex_exit(&ppp_softcs.lock);
if (sc == NULL)
sc = ppp_create(ppp_cloner.ifc_name, -1);
Home |
Main Index |
Thread Index |
Old Index