`pppx_ifs_lk' used to protect `pppx_ifs' tree, But this tree is accessed under KERNL_LOCK() and there is no concurency. Also we don't sleep while holding this lock. So it's useless, kill it for simplification.
Index: sys/net/if_pppx.c =================================================================== RCS file: /cvs/src/sys/net/if_pppx.c,v retrieving revision 1.84 diff -u -p -r1.84 if_pppx.c --- sys/net/if_pppx.c 18 Apr 2020 04:03:56 -0000 1.84 +++ sys/net/if_pppx.c 25 May 2020 08:31:20 -0000 @@ -165,7 +165,6 @@ pppx_if_cmp(const struct pppx_if *a, con return memcmp(&a->pxi_key, &b->pxi_key, sizeof(a->pxi_key)); } -struct rwlock pppx_ifs_lk = RWLOCK_INITIALIZER("pppxifs"); RBT_HEAD(pppx_ifs, pppx_if) pppx_ifs = RBT_INITIALIZER(&pppx_ifs); RBT_PROTOTYPE(pppx_ifs, pppx_if, pxi_entry, pppx_if_cmp); @@ -620,8 +619,6 @@ pppx_if_next_unit(void) struct pppx_if *pxi; int unit = 0; - rw_assert_wrlock(&pppx_ifs_lk); - /* this is safe without splnet since we're not modifying it */ do { int found = 0; @@ -650,11 +647,9 @@ pppx_if_find(struct pppx_dev *pxd, int s key.pxik_session_id = session_id; key.pxik_protocol = protocol; - rw_enter_read(&pppx_ifs_lk); pxi = RBT_FIND(pppx_ifs, &pppx_ifs, (struct pppx_if *)&key); if (pxi && pxi->pxi_ready == 0) pxi = NULL; - rw_exit_read(&pppx_ifs_lk); return pxi; } @@ -828,12 +823,10 @@ pppx_add_session(struct pppx_dev *pxd, s #endif /* try to set the interface up */ - rw_enter_write(&pppx_ifs_lk); unit = pppx_if_next_unit(); if (unit < 0) { pool_put(pppx_if_pl, pxi); error = ENOMEM; - rw_exit_write(&pppx_ifs_lk); goto out; } @@ -846,14 +839,12 @@ pppx_add_session(struct pppx_dev *pxd, s if (RBT_FIND(pppx_ifs, &pppx_ifs, pxi) != NULL) { pool_put(pppx_if_pl, pxi); error = EADDRINUSE; - rw_exit_write(&pppx_ifs_lk); goto out; } if (RBT_INSERT(pppx_ifs, &pppx_ifs, pxi) != NULL) panic("%s: pppx_ifs modified while lock was held", __func__); LIST_INSERT_HEAD(&pxd->pxd_pxis, pxi, pxi_list); - rw_exit_write(&pppx_ifs_lk); snprintf(ifp->if_xname, sizeof(ifp->if_xname), "%s%d", "pppx", unit); ifp->if_mtu = req->pr_peer_mru; /* XXX */ @@ -935,9 +926,7 @@ pppx_add_session(struct pppx_dev *pxd, s } else { if_addrhooks_run(ifp); } - rw_enter_write(&pppx_ifs_lk); pxi->pxi_ready = 1; - rw_exit_write(&pppx_ifs_lk); out: return (error); @@ -1038,11 +1027,9 @@ pppx_if_destroy(struct pppx_dev *pxd, st if_detach(ifp); NET_LOCK(); - rw_enter_write(&pppx_ifs_lk); if (RBT_REMOVE(pppx_ifs, &pppx_ifs, pxi) == NULL) panic("%s: pppx_ifs modified while lock was held", __func__); LIST_REMOVE(pxi, pxi_list); - rw_exit_write(&pppx_ifs_lk); pool_put(pppx_if_pl, pxi); }