Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Don't grab KERNEL_LOCK during if_output when NET_MPSAFE



details:   https://anonhg.NetBSD.org/src/rev/f5039f561ff5
branches:  trunk
changeset: 807257:f5039f561ff5
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Fri Apr 03 07:55:18 2015 +0000

description:
Don't grab KERNEL_LOCK during if_output when NET_MPSAFE

The change makes L3 MP-safe work easy. At this point
we deal with only IP forwarding.

No functional change when NET_MPSAFE isn't enabled.

diffstat:

 sys/net/if_ethersubr.c  |   7 +++++--
 sys/net/if_loop.c       |   8 +++++---
 sys/netinet/ip_output.c |  17 +++++++++++++++--
 3 files changed, 25 insertions(+), 7 deletions(-)

diffs (137 lines):

diff -r d481bbb61331 -r f5039f561ff5 sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Fri Apr 03 07:28:41 2015 +0000
+++ b/sys/net/if_ethersubr.c    Fri Apr 03 07:55:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.205 2014/11/28 08:29:00 ozaki-r Exp $       */
+/*     $NetBSD: if_ethersubr.c,v 1.206 2015/04/03 07:55:18 ozaki-r Exp $       */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.205 2014/11/28 08:29:00 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.206 2015/04/03 07:55:18 ozaki-r Exp $");
 
 #include "opt_inet.h"
 #include "opt_atalk.h"
@@ -70,6 +70,7 @@
 #include "opt_mpls.h"
 #include "opt_gateway.h"
 #include "opt_pppoe.h"
+#include "opt_net_mpsafe.h"
 #include "vlan.h"
 #include "pppoe.h"
 #include "bridge.h"
@@ -214,7 +215,9 @@
        struct at_ifaddr *aa;
 #endif /* NETATALK */
 
+#ifndef NET_MPSAFE
        KASSERT(KERNEL_LOCKED_P());
+#endif
 
 #ifdef MBUFTRACE
        m_claimm(m, ifp->if_mowner);
diff -r d481bbb61331 -r f5039f561ff5 sys/net/if_loop.c
--- a/sys/net/if_loop.c Fri Apr 03 07:28:41 2015 +0000
+++ b/sys/net/if_loop.c Fri Apr 03 07:55:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_loop.c,v 1.80 2014/06/07 11:00:29 rmind Exp $       */
+/*     $NetBSD: if_loop.c,v 1.81 2015/04/03 07:55:18 ozaki-r Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,14 +65,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.80 2014/06/07 11:00:29 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.81 2015/04/03 07:55:18 ozaki-r Exp $");
 
 #include "opt_inet.h"
 #include "opt_atalk.h"
 #include "opt_ipx.h"
 #include "opt_mbuftrace.h"
 #include "opt_mpls.h"
-
+#include "opt_net_mpsafe.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -218,7 +218,9 @@
        size_t pktlen;
 
        MCLAIM(m, ifp->if_mowner);
+#ifndef NET_MPSAFE
        KASSERT(KERNEL_LOCKED_P());
+#endif
 
        if ((m->m_flags & M_PKTHDR) == 0)
                panic("looutput: no header mbuf");
diff -r d481bbb61331 -r f5039f561ff5 sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c   Fri Apr 03 07:28:41 2015 +0000
+++ b/sys/netinet/ip_output.c   Fri Apr 03 07:55:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_output.c,v 1.235 2015/03/31 08:44:43 ozaki-r Exp $  */
+/*     $NetBSD: ip_output.c,v 1.236 2015/04/03 07:55:18 ozaki-r Exp $  */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,11 +91,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.235 2015/03/31 08:44:43 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.236 2015/04/03 07:55:18 ozaki-r Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
 #include "opt_mrouting.h"
+#include "opt_net_mpsafe.h"
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -557,9 +558,13 @@
                if (__predict_true(
                    (m->m_pkthdr.csum_flags & M_CSUM_TSOv4) == 0 ||
                    (ifp->if_capenable & IFCAP_TSOv4) != 0)) {
+#ifndef NET_MPSAFE
                        KERNEL_LOCK(1, NULL);
+#endif
                        error = (*ifp->if_output)(ifp, m, sa, rt);
+#ifndef NET_MPSAFE
                        KERNEL_UNLOCK_ONE(NULL);
+#endif
                } else {
                        error = ip_tso_output(ifp, m, sa, rt);
                }
@@ -627,11 +632,15 @@
                } else {
                        KASSERT((m->m_pkthdr.csum_flags &
                            (M_CSUM_UDPv4 | M_CSUM_TCPv4)) == 0);
+#ifndef NET_MPSAFE
                        KERNEL_LOCK(1, NULL);
+#endif
                        error = (*ifp->if_output)(ifp, m,
                            (m->m_flags & M_MCAST) ?
                            sintocsa(rdst) : sintocsa(dst), rt);
+#ifndef NET_MPSAFE
                        KERNEL_UNLOCK_ONE(NULL);
+#endif
                }
        }
        if (error == 0) {
@@ -1722,7 +1731,11 @@
 
        ip->ip_sum = 0;
        ip->ip_sum = in_cksum(copym, ip->ip_hl << 2);
+#ifndef NET_MPSAFE
        KERNEL_LOCK(1, NULL);
+#endif
        (void)looutput(ifp, copym, sintocsa(dst), NULL);
+#ifndef NET_MPSAFE
        KERNEL_UNLOCK_ONE(NULL);
+#endif
 }



Home | Main Index | Thread Index | Old Index