Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Remove unnecessaly lock holdings to avoid dead lock
details: https://anonhg.NetBSD.org/src/rev/322b982594c0
branches: trunk
changeset: 982530:322b982594c0
user: yamaguchi <yamaguchi%NetBSD.org@localhost>
date: Fri Apr 16 02:12:00 2021 +0000
description:
Remove unnecessaly lock holdings to avoid dead lock
The locks were held while callout_halt() and workqueue_wait()
without reason.
And the locks also were held at callout and workqueue handler
so that the handler kicked by those function couldn't acquire
the lock.
The reasons why those are unneccesary are:
- Items of callout_t are protected by callout_lock
- Items of struct workqueue and struct work are protected
by q_mutex in struct workqueue
- Items of struct sppp_work protected by atomic_cas(3)
- struct pppoe_softc does not free before workqueue_wait() and
callout_halt() even if the locks are not held
diffstat:
sys/net/if_pppoe.c | 6 ++----
sys/net/if_spppsubr.c | 7 ++-----
2 files changed, 4 insertions(+), 9 deletions(-)
diffs (69 lines):
diff -r 9cc66dd8afbb -r 322b982594c0 sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c Fri Apr 16 02:05:37 2021 +0000
+++ b/sys/net/if_pppoe.c Fri Apr 16 02:12:00 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.167 2021/04/16 01:59:50 yamaguchi Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.168 2021/04/16 02:12:00 yamaguchi Exp $ */
/*
* Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.167 2021/04/16 01:59:50 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.168 2021/04/16 02:12:00 yamaguchi Exp $");
#ifdef _KERNEL_OPT
#include "pppoe.h"
@@ -436,7 +436,6 @@
}
rw_exit(&pppoe_softc_list_lock);
- PPPOE_LOCK(sc, RW_WRITER);
callout_setfunc(&sc->sc_timeout, pppoe_timeout_co_halt, sc);
workqueue_wait(sc->sc_timeout_wq, &sc->sc_timeout_wk);
callout_halt(&sc->sc_timeout, NULL);
@@ -455,7 +454,6 @@
callout_destroy(&sc->sc_timeout);
workqueue_destroy(sc->sc_timeout_wq);
- PPPOE_UNLOCK(sc);
rw_destroy(&sc->sc_lock);
kmem_free(sc, sizeof(*sc));
diff -r 9cc66dd8afbb -r 322b982594c0 sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c Fri Apr 16 02:05:37 2021 +0000
+++ b/sys/net/if_spppsubr.c Fri Apr 16 02:12:00 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_spppsubr.c,v 1.216 2021/04/16 02:05:37 yamaguchi Exp $ */
+/* $NetBSD: if_spppsubr.c,v 1.217 2021/04/16 02:12:00 yamaguchi Exp $ */
/*
* Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.216 2021/04/16 02:05:37 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.217 2021/04/16 02:12:00 yamaguchi Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -1074,8 +1074,6 @@
spppq_lock = NULL;
}
- SPPP_LOCK(sp, RW_WRITER);
-
sppp_cp_fini(&lcp, sp);
sppp_cp_fini(&ipcp, sp);
sppp_cp_fini(&pap, sp);
@@ -1090,7 +1088,6 @@
if (sp->myauth.secret) free(sp->myauth.secret, M_DEVBUF);
if (sp->hisauth.name) free(sp->hisauth.name, M_DEVBUF);
if (sp->hisauth.secret) free(sp->hisauth.secret, M_DEVBUF);
- SPPP_UNLOCK(sp);
rw_destroy(&sp->pp_lock);
}
Home |
Main Index |
Thread Index |
Old Index