From 8d1b9f9339babcb9d8e55d3989ec40ca0e324232 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 26 Oct 2011 11:39:40 -0700 Subject: [PATCH] kernel - remove MP lock from uipc socket functions, route table, and mld6 * Remove the MP lock from the uipc_socket.c kqueue filterops. * Remove the MP lock from the route table threads. * Remoev the MP lock from the IPV6 MLD6 implementation. --- sys/kern/uipc_socket.c | 8 ++++---- sys/net/route.c | 3 --- sys/netinet6/mld6.c | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 936158d569..013e464529 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -110,13 +110,13 @@ static int filt_sowrite(struct knote *kn, long hint); static int filt_solisten(struct knote *kn, long hint); static struct filterops solisten_filtops = - { FILTEROP_ISFD, NULL, filt_sordetach, filt_solisten }; + { FILTEROP_ISFD|FILTEROP_MPSAFE, NULL, filt_sordetach, filt_solisten }; static struct filterops soread_filtops = - { FILTEROP_ISFD, NULL, filt_sordetach, filt_soread }; + { FILTEROP_ISFD|FILTEROP_MPSAFE, NULL, filt_sordetach, filt_soread }; static struct filterops sowrite_filtops = - { FILTEROP_ISFD, NULL, filt_sowdetach, filt_sowrite }; + { FILTEROP_ISFD|FILTEROP_MPSAFE, NULL, filt_sowdetach, filt_sowrite }; static struct filterops soexcept_filtops = - { FILTEROP_ISFD, NULL, filt_sordetach, filt_soread }; + { FILTEROP_ISFD|FILTEROP_MPSAFE, NULL, filt_sordetach, filt_soread }; MALLOC_DEFINE(M_SOCKET, "socket", "socket struct"); MALLOC_DEFINE(M_SONAME, "soname", "socket name"); diff --git a/sys/net/route.c b/sys/net/route.c index 7c88f18f62..45fbb37f47 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -90,7 +90,6 @@ #include #include -#include #include #ifdef MPLS @@ -196,8 +195,6 @@ rtable_service_loop(void *dummy __unused) netmsg_base_t msg; thread_t td = curthread; - get_mplock(); /* XXX is this mpsafe yet? */ - while ((msg = lwkt_waitport(&td->td_msgport, 0)) != NULL) { msg->nm_dispatch((netmsg_t)msg); } diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c index 5f1088c9ad..826e4f95a2 100644 --- a/sys/netinet6/mld6.c +++ b/sys/netinet6/mld6.c @@ -112,6 +112,9 @@ static struct in6_addr mld6_all_routers_linklocal = IN6ADDR_LINKLOCAL_ALLROUTERS static void mld6_sendpkt (struct in6_multi *, int, const struct in6_addr *); +static struct lwkt_token mld6_token = LWKT_TOKEN_INITIALIZER(mp_token); + + void mld6_init(void) { @@ -138,7 +141,6 @@ mld6_init(void) void mld6_start_listening(struct in6_multi *in6m) { - crit_enter(); /* * RFC2710 page 10: * The node never sends a Report or Done for the link-scope all-nodes @@ -146,6 +148,7 @@ mld6_start_listening(struct in6_multi *in6m) * MLD messages are never sent for multicast addresses whose scope is 0 * (reserved) or 1 (node-local). */ + lwkt_gettoken(&mld6_token); mld6_all_nodes_linklocal.s6_addr16[1] = htons(in6m->in6m_ifp->if_index); /* XXX */ if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &mld6_all_nodes_linklocal) || @@ -159,7 +162,7 @@ mld6_start_listening(struct in6_multi *in6m) in6m->in6m_state = MLD6_IREPORTEDLAST; mld6_timers_are_running = 1; } - crit_exit(); + lwkt_reltoken(&mld6_token); } void @@ -199,6 +202,7 @@ mld6_input(struct mbuf *m, int off) } #endif + lwkt_gettoken(&mld6_token); /* source address validation */ ip6 = mtod(m, struct ip6_hdr *);/* in case mpullup */ if (!IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_src)) { @@ -213,6 +217,7 @@ mld6_input(struct mbuf *m, int off) * XXX: do we have to allow :: as source? */ m_freem(m); + lwkt_reltoken(&mld6_token); return; } @@ -337,6 +342,7 @@ mld6_input(struct mbuf *m, int off) } m_freem(m); + lwkt_reltoken(&mld6_token); } void @@ -349,10 +355,12 @@ mld6_fasttimeo(void) * Quick check to see if any work needs to be done, in order * to minimize the overhead of fasttimo processing. */ - if (!mld6_timers_are_running) + lwkt_gettoken(&mld6_token); + if (!mld6_timers_are_running) { + lwkt_reltoken(&mld6_token); return; + } - crit_enter(); mld6_timers_are_running = 0; IN6_FIRST_MULTI(step, in6m); while (in6m != NULL) { @@ -366,7 +374,7 @@ mld6_fasttimeo(void) } IN6_NEXT_MULTI(step, in6m); } - crit_exit(); + lwkt_reltoken(&mld6_token); } static void -- 2.41.0