Module Name:    src
Committed By:   knakahara
Date:           Fri Jan 25 08:51:29 UTC 2019

Modified Files:
        src/sys/net: if_ppp.c

Log Message:
Add __cacheline_aligned to ppp softc list and its mutex just in case.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/sys/net/if_ppp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_ppp.c
diff -u src/sys/net/if_ppp.c:1.163 src/sys/net/if_ppp.c:1.164
--- src/sys/net/if_ppp.c:1.163	Fri Jan 11 02:57:21 2019
+++ src/sys/net/if_ppp.c	Fri Jan 25 08:51:29 2019
@@ -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 int ppp_clone_destroy(struct ifne
 
 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 @@ pppinit(void)
 	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 @@ pppdetach(void)
 {
 	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 @@ ppp_create(const char *name, int unit)
 
 	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 @@ ppp_create(const char *name, int unit)
 		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 @@ ppp_create(const char *name, int unit)
 	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 @@ ppp_clone_destroy(struct ifnet *ifp)
 	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 @@ pppalloc(pid_t pid)
 	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);

Reply via email to