Source-Changes-HG archive

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

[src/trunk]: src/sys eliminate unnecessary splnet



details:   https://anonhg.NetBSD.org/src/rev/6b9df438ba6c
branches:  trunk
changeset: 816030:6b9df438ba6c
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Jun 13 08:37:15 2016 +0000

description:
eliminate unnecessary splnet

diffstat:

 sys/netinet/ip_flow.c   |  22 ++++++----------------
 sys/netinet6/ip6_flow.c |  22 ++++++----------------
 2 files changed, 12 insertions(+), 32 deletions(-)

diffs (216 lines):

diff -r b5a465d193f6 -r 6b9df438ba6c sys/netinet/ip_flow.c
--- a/sys/netinet/ip_flow.c     Mon Jun 13 08:34:23 2016 +0000
+++ b/sys/netinet/ip_flow.c     Mon Jun 13 08:37:15 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_flow.c,v 1.70 2016/06/13 08:34:23 knakahara Exp $   */
+/*     $NetBSD: ip_flow.c,v 1.71 2016/06/13 08:37:15 knakahara Exp $   */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.70 2016/06/13 08:34:23 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.71 2016/06/13 08:37:15 knakahara Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -357,7 +357,6 @@
 static void
 ipflow_free(struct ipflow *ipf)
 {
-       int s;
 
        KASSERT(mutex_owned(&ipflow_lock));
 
@@ -366,9 +365,8 @@
         * Once it's off the list, we can deal with it at normal
         * network IPL.
         */
-       s = splnet();
        IPFLOW_REMOVE(ipf);
-       splx(s);
+
        ipflow_addstats(ipf);
        rtcache_free(&ipf->ipf_ro);
        ipflow_inuse--;
@@ -383,7 +381,6 @@
 
        while (just_one || ipflow_inuse > ip_maxflows) {
                struct ipflow *ipf, *maybe_ipf = NULL;
-               int s;
 
                ipf = LIST_FIRST(&ipflowlist);
                while (ipf != NULL) {
@@ -412,9 +409,8 @@
                /*
                 * Remove the entry from the flow table.
                 */
-               s = splnet();
                IPFLOW_REMOVE(ipf);
-               splx(s);
+
                ipflow_addstats(ipf);
                rtcache_free(&ipf->ipf_ro);
                if (just_one)
@@ -462,7 +458,6 @@
        const struct ip *const ip = mtod(m, const struct ip *);
        struct ipflow *ipf;
        size_t hash;
-       int s;
 
        mutex_enter(&ipflow_lock);
 
@@ -493,9 +488,8 @@
                }
                memset(ipf, 0, sizeof(*ipf));
        } else {
-               s = splnet();
                IPFLOW_REMOVE(ipf);
-               splx(s);
+
                ipflow_addstats(ipf);
                rtcache_free(&ipf->ipf_ro);
                ipf->ipf_uses = ipf->ipf_last_uses = 0;
@@ -515,9 +509,7 @@
         * Insert into the approriate bucket of the flow table.
         */
        hash = ipflow_hash(ip);
-       s = splnet();
        IPFLOW_INSERT(&ipflowtable[hash], ipf);
-       splx(s);
 
  out:
        KERNEL_UNLOCK_ONE(NULL);
@@ -528,13 +520,12 @@
 ipflow_invalidate_all(int new_size)
 {
        struct ipflow *ipf, *next_ipf;
-       int s, error;
+       int error;
 
        error = 0;
 
        mutex_enter(&ipflow_lock);
 
-       s = splnet();
        for (ipf = LIST_FIRST(&ipflowlist); ipf != NULL; ipf = next_ipf) {
                next_ipf = LIST_NEXT(ipf, ipf_list);
                ipflow_free(ipf);
@@ -542,7 +533,6 @@
 
        if (new_size)
                error = ipflow_reinit(new_size);
-       splx(s);
 
        mutex_exit(&ipflow_lock);
 
diff -r b5a465d193f6 -r 6b9df438ba6c sys/netinet6/ip6_flow.c
--- a/sys/netinet6/ip6_flow.c   Mon Jun 13 08:34:23 2016 +0000
+++ b/sys/netinet6/ip6_flow.c   Mon Jun 13 08:37:15 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_flow.c,v 1.25 2016/06/13 08:34:23 knakahara Exp $  */
+/*     $NetBSD: ip6_flow.c,v 1.26 2016/06/13 08:37:15 knakahara Exp $  */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_flow.c,v 1.25 2016/06/13 08:34:23 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_flow.c,v 1.26 2016/06/13 08:37:15 knakahara Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -377,7 +377,6 @@
 static void
 ip6flow_free(struct ip6flow *ip6f)
 {
-       int s;
 
        KASSERT(mutex_owned(&ip6flow_lock));
 
@@ -386,9 +385,8 @@
         * Once it's off the list, we can deal with it at normal
         * network IPL.
         */
-       s = splnet();
        IP6FLOW_REMOVE(ip6f);
-       splx(s);
+
        ip6flow_inuse--;
        ip6flow_addstats(ip6f);
        rtcache_free(&ip6f->ip6f_ro);
@@ -403,7 +401,6 @@
 
        while (just_one || ip6flow_inuse > ip6_maxflows) {
                struct ip6flow *ip6f, *maybe_ip6f = NULL;
-               int s;
 
                ip6f = LIST_FIRST(&ip6flowlist);
                while (ip6f != NULL) {
@@ -432,9 +429,8 @@
                /*
                 * Remove the entry from the flow table
                 */
-               s = splnet();
                IP6FLOW_REMOVE(ip6f);
-               splx(s);
+
                rtcache_free(&ip6f->ip6f_ro);
                if (just_one) {
                        ip6flow_addstats(ip6f);
@@ -500,7 +496,6 @@
        const struct ip6_hdr *ip6;
        struct ip6flow *ip6f;
        size_t hash;
-       int s;
 
        mutex_enter(&ip6flow_lock);
 
@@ -542,9 +537,8 @@
                }
                memset(ip6f, 0, sizeof(*ip6f));
        } else {
-               s = splnet();
                IP6FLOW_REMOVE(ip6f);
-               splx(s);
+
                ip6flow_addstats(ip6f);
                rtcache_free(&ip6f->ip6f_ro);
                ip6f->ip6f_uses = 0;
@@ -566,9 +560,7 @@
         * Insert into the approriate bucket of the flow table.
         */
        hash = ip6flow_hash(ip6);
-       s = splnet();
        IP6FLOW_INSERT(&ip6flowtable[hash], ip6f);
-       splx(s);
 
  out:
        KERNEL_UNLOCK_ONE(NULL);
@@ -583,13 +575,12 @@
 ip6flow_invalidate_all(int new_size)
 {
        struct ip6flow *ip6f, *next_ip6f;
-       int s, error;
+       int error;
 
        error = 0;
 
        mutex_enter(&ip6flow_lock);
 
-       s = splnet();
        for (ip6f = LIST_FIRST(&ip6flowlist); ip6f != NULL; ip6f = next_ip6f) {
                next_ip6f = LIST_NEXT(ip6f, ip6f_list);
                ip6flow_free(ip6f);
@@ -597,7 +588,6 @@
 
        if (new_size) 
                error = ip6flow_init_locked(new_size);
-       splx(s);
 
        mutex_exit(&ip6flow_lock);
 



Home | Main Index | Thread Index | Old Index