Author: andre
Date: Fri Jul  5 15:18:54 2013
New Revision: 252790
URL: http://svnweb.freebsd.org/changeset/base/252790

Log:
  MFC r242253:
  
   Simplify implementation of net.inet.tcp.reass.maxsegments and
   net.inet.tcp.reass.cursegments.
  
  MFC r242254:
  
   Change the syncache count reporting the current number of entries
   from an unprotected u_int that reports garbage on SMP to a function
   based sysctl obtaining the current value from UMA.
  
   Also read back the actual cache_limit after page size rounding by UMA.
   PR:          kern/165879
  
  MFC r244680:
  
   Fix sysctl_handle_int() usage. Either arg1 or arg2 should be supplied,
   and arg2 doesn't pass size of arg1.
  
  MFC r246208:
  
   uma_zone_set_max() directly returns the rounded effective zone
   limit.  Use the return value directly instead of doing a second
   uma_zone_set_max() step.

Modified:
  stable/9/sys/netinet/tcp_reass.c
  stable/9/sys/netinet/tcp_syncache.c
  stable/9/sys/netinet/tcp_syncache.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netinet/tcp_reass.c
==============================================================================
--- stable/9/sys/netinet/tcp_reass.c    Fri Jul  5 14:58:24 2013        
(r252789)
+++ stable/9/sys/netinet/tcp_reass.c    Fri Jul  5 15:18:54 2013        
(r252790)
@@ -74,7 +74,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/tcp_debug.h>
 #endif /* TCPDEBUG */
 
-static int tcp_reass_sysctl_maxseg(SYSCTL_HANDLER_ARGS);
 static int tcp_reass_sysctl_qsize(SYSCTL_HANDLER_ARGS);
 
 static SYSCTL_NODE(_net_inet_tcp, OID_AUTO, reass, CTLFLAG_RW, 0,
@@ -82,16 +81,12 @@ static SYSCTL_NODE(_net_inet_tcp, OID_AU
 
 static VNET_DEFINE(int, tcp_reass_maxseg) = 0;
 #define        V_tcp_reass_maxseg              VNET(tcp_reass_maxseg)
-SYSCTL_VNET_PROC(_net_inet_tcp_reass, OID_AUTO, maxsegments,
-    CTLTYPE_INT | CTLFLAG_RDTUN,
-    &VNET_NAME(tcp_reass_maxseg), 0, &tcp_reass_sysctl_maxseg, "I",
+SYSCTL_VNET_INT(_net_inet_tcp_reass, OID_AUTO, maxsegments, CTLFLAG_RDTUN,
+    &VNET_NAME(tcp_reass_maxseg), 0,
     "Global maximum number of TCP Segments in Reassembly Queue");
 
-static VNET_DEFINE(int, tcp_reass_qsize) = 0;
-#define        V_tcp_reass_qsize               VNET(tcp_reass_qsize)
 SYSCTL_VNET_PROC(_net_inet_tcp_reass, OID_AUTO, cursegments,
-    CTLTYPE_INT | CTLFLAG_RD,
-    &VNET_NAME(tcp_reass_qsize), 0, &tcp_reass_sysctl_qsize, "I",
+    (CTLTYPE_INT | CTLFLAG_RD), NULL, 0, &tcp_reass_sysctl_qsize, "I",
     "Global number of TCP Segments currently in Reassembly Queue");
 
 static VNET_DEFINE(int, tcp_reass_overflows) = 0;
@@ -109,8 +104,10 @@ static void
 tcp_reass_zone_change(void *tag)
 {
 
+       /* Set the zone limit and read back the effective value. */
        V_tcp_reass_maxseg = nmbclusters / 16;
-       uma_zone_set_max(V_tcp_reass_zone, V_tcp_reass_maxseg);
+       V_tcp_reass_maxseg = uma_zone_set_max(V_tcp_reass_zone,
+           V_tcp_reass_maxseg);
 }
 
 void
@@ -122,7 +119,9 @@ tcp_reass_init(void)
            &V_tcp_reass_maxseg);
        V_tcp_reass_zone = uma_zcreate("tcpreass", sizeof (struct tseg_qent),
            NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
-       uma_zone_set_max(V_tcp_reass_zone, V_tcp_reass_maxseg);
+       /* Set the zone limit and read back the effective value. */
+       V_tcp_reass_maxseg = uma_zone_set_max(V_tcp_reass_zone,
+           V_tcp_reass_maxseg);
        EVENTHANDLER_REGISTER(nmbclusters_change,
            tcp_reass_zone_change, NULL, EVENTHANDLER_PRI_ANY);
 }
@@ -156,17 +155,12 @@ tcp_reass_flush(struct tcpcb *tp)
 }
 
 static int
-tcp_reass_sysctl_maxseg(SYSCTL_HANDLER_ARGS)
-{
-       V_tcp_reass_maxseg = uma_zone_get_max(V_tcp_reass_zone);
-       return (sysctl_handle_int(oidp, arg1, arg2, req));
-}
-
-static int
 tcp_reass_sysctl_qsize(SYSCTL_HANDLER_ARGS)
 {
-       V_tcp_reass_qsize = uma_zone_get_cur(V_tcp_reass_zone);
-       return (sysctl_handle_int(oidp, arg1, arg2, req));
+       int qsize;
+
+       qsize = uma_zone_get_cur(V_tcp_reass_zone);
+       return (sysctl_handle_int(oidp, &qsize, 0, req));
 }
 
 int

Modified: stable/9/sys/netinet/tcp_syncache.c
==============================================================================
--- stable/9/sys/netinet/tcp_syncache.c Fri Jul  5 14:58:24 2013        
(r252789)
+++ stable/9/sys/netinet/tcp_syncache.c Fri Jul  5 15:18:54 2013        
(r252790)
@@ -123,6 +123,7 @@ struct syncache *syncache_lookup(struct 
 static int      syncache_respond(struct syncache *);
 static struct   socket *syncache_socket(struct syncache *, struct socket *,
                    struct mbuf *m);
+static int      syncache_sysctl_count(SYSCTL_HANDLER_ARGS);
 static void     syncache_timeout(struct syncache *sc, struct syncache_head 
*sch,
                    int docallout);
 static void     syncache_timer(void *);
@@ -158,8 +159,8 @@ SYSCTL_VNET_UINT(_net_inet_tcp_syncache,
     &VNET_NAME(tcp_syncache.cache_limit), 0,
     "Overall entry limit for syncache");
 
-SYSCTL_VNET_UINT(_net_inet_tcp_syncache, OID_AUTO, count, CTLFLAG_RD,
-    &VNET_NAME(tcp_syncache.cache_count), 0,
+SYSCTL_VNET_PROC(_net_inet_tcp_syncache, OID_AUTO, count, 
(CTLTYPE_UINT|CTLFLAG_RD),
+    NULL, 0, &syncache_sysctl_count, "IU",
     "Current number of entries in syncache");
 
 SYSCTL_VNET_UINT(_net_inet_tcp_syncache, OID_AUTO, hashsize, CTLFLAG_RDTUN,
@@ -225,7 +226,6 @@ syncache_init(void)
 {
        int i;
 
-       V_tcp_syncache.cache_count = 0;
        V_tcp_syncache.hashsize = TCP_SYNCACHE_HASHSIZE;
        V_tcp_syncache.bucket_limit = TCP_SYNCACHE_BUCKETLIMIT;
        V_tcp_syncache.rexmt_limit = SYNCACHE_MAXREXMTS;
@@ -268,7 +268,8 @@ syncache_init(void)
        /* Create the syncache entry zone. */
        V_tcp_syncache.zone = uma_zcreate("syncache", sizeof(struct syncache),
            NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
-       uma_zone_set_max(V_tcp_syncache.zone, V_tcp_syncache.cache_limit);
+       V_tcp_syncache.cache_limit = uma_zone_set_max(V_tcp_syncache.zone,
+           V_tcp_syncache.cache_limit);
 }
 
 #ifdef VIMAGE
@@ -296,8 +297,8 @@ syncache_destroy(void)
                mtx_destroy(&sch->sch_mtx);
        }
 
-       KASSERT(V_tcp_syncache.cache_count == 0, ("%s: cache_count %d not 0",
-           __func__, V_tcp_syncache.cache_count));
+       KASSERT(uma_zone_get_cur(V_tcp_syncache.zone) == 0,
+           ("%s: cache_count not 0", __func__));
 
        /* Free the allocated global resources. */
        uma_zdestroy(V_tcp_syncache.zone);
@@ -305,6 +306,15 @@ syncache_destroy(void)
 }
 #endif
 
+static int
+syncache_sysctl_count(SYSCTL_HANDLER_ARGS)
+{
+       int count;
+
+       count = uma_zone_get_cur(V_tcp_syncache.zone);
+       return (sysctl_handle_int(oidp, &count, 0, req));
+}
+
 /*
  * Inserts a syncache entry into the specified bucket row.
  * Locks and unlocks the syncache_head autonomously.
@@ -347,7 +357,6 @@ syncache_insert(struct syncache *sc, str
 
        SCH_UNLOCK(sch);
 
-       V_tcp_syncache.cache_count++;
        TCPSTAT_INC(tcps_sc_added);
 }
 
@@ -373,7 +382,6 @@ syncache_drop(struct syncache *sc, struc
 #endif
 
        syncache_free(sc);
-       V_tcp_syncache.cache_count--;
 }
 
 /*
@@ -958,7 +966,6 @@ syncache_expand(struct in_conninfo *inc,
                        tod->tod_syncache_removed(tod, sc->sc_todctx);
                }
 #endif
-               V_tcp_syncache.cache_count--;
                SCH_UNLOCK(sch);
        }
 

Modified: stable/9/sys/netinet/tcp_syncache.h
==============================================================================
--- stable/9/sys/netinet/tcp_syncache.h Fri Jul  5 14:58:24 2013        
(r252789)
+++ stable/9/sys/netinet/tcp_syncache.h Fri Jul  5 15:18:54 2013        
(r252790)
@@ -113,7 +113,6 @@ struct tcp_syncache {
        u_int   hashsize;
        u_int   hashmask;
        u_int   bucket_limit;
-       u_int   cache_count;            /* XXX: unprotected */
        u_int   cache_limit;
        u_int   rexmt_limit;
        u_int   hash_secret;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to