svn commit: r276484 - in head/sys: netinet netinet6

Adrian Chadd adrian at FreeBSD.org
Wed Dec 31 22:52:45 UTC 2014


Author: adrian
Date: Wed Dec 31 22:52:43 2014
New Revision: 276484
URL: https://svnweb.freebsd.org/changeset/base/276484

Log:
  Migrate the RSS IPv6 hash code to use pointers to the v6 addresses
  rather than passing them in by value.
  
  The eventual aim is to do incremental hash construction rather than
  all of the memcpy()'ing into a contiguous buffer for the hash
  function, which does show up as taking quite a bit of CPU during
  profiling.
  
  Tested:
  
  * a variety of laptops/desktop setups I have, with v6 connectivity
  
  Differential Revision:	D1404
  Reviewed by:	bz, rpaulo

Modified:
  head/sys/netinet/in_rss.c
  head/sys/netinet/in_rss.h
  head/sys/netinet6/in6_pcbgroup.c
  head/sys/netinet6/udp6_usrreq.c

Modified: head/sys/netinet/in_rss.c
==============================================================================
--- head/sys/netinet/in_rss.c	Wed Dec 31 22:49:02 2014	(r276483)
+++ head/sys/netinet/in_rss.c	Wed Dec 31 22:52:43 2014	(r276484)
@@ -346,16 +346,16 @@ rss_hash_ip4_4tuple(struct in_addr src, 
  * Hash an IPv6 2-tuple.
  */
 uint32_t
-rss_hash_ip6_2tuple(struct in6_addr src, struct in6_addr dst)
+rss_hash_ip6_2tuple(const struct in6_addr *src, const struct in6_addr *dst)
 {
-	uint8_t data[sizeof(src) + sizeof(dst)];
+	uint8_t data[sizeof(*src) + sizeof(*dst)];
 	u_int datalen;
 
 	datalen = 0;
-	bcopy(&src, &data[datalen], sizeof(src));
-	datalen += sizeof(src);
-	bcopy(&dst, &data[datalen], sizeof(dst));
-	datalen += sizeof(dst);
+	bcopy(src, &data[datalen], sizeof(*src));
+	datalen += sizeof(*src);
+	bcopy(dst, &data[datalen], sizeof(*dst));
+	datalen += sizeof(*dst);
 	return (rss_hash(datalen, data));
 }
 
@@ -363,18 +363,18 @@ rss_hash_ip6_2tuple(struct in6_addr src,
  * Hash an IPv6 4-tuple.
  */
 uint32_t
-rss_hash_ip6_4tuple(struct in6_addr src, u_short srcport,
-    struct in6_addr dst, u_short dstport)
+rss_hash_ip6_4tuple(const struct in6_addr *src, u_short srcport,
+    const struct in6_addr *dst, u_short dstport)
 {
-	uint8_t data[sizeof(src) + sizeof(dst) + sizeof(srcport) +
+	uint8_t data[sizeof(*src) + sizeof(*dst) + sizeof(srcport) +
 	    sizeof(dstport)];
 	u_int datalen;
 
 	datalen = 0;
-	bcopy(&src, &data[datalen], sizeof(src));
-	datalen += sizeof(src);
-	bcopy(&dst, &data[datalen], sizeof(dst));
-	datalen += sizeof(dst);
+	bcopy(src, &data[datalen], sizeof(*src));
+	datalen += sizeof(*src);
+	bcopy(dst, &data[datalen], sizeof(*dst));
+	datalen += sizeof(*dst);
 	bcopy(&srcport, &data[datalen], sizeof(srcport));
 	datalen += sizeof(srcport);
 	bcopy(&dstport, &data[datalen], sizeof(dstport));

Modified: head/sys/netinet/in_rss.h
==============================================================================
--- head/sys/netinet/in_rss.h	Wed Dec 31 22:49:02 2014	(r276483)
+++ head/sys/netinet/in_rss.h	Wed Dec 31 22:52:43 2014	(r276484)
@@ -112,10 +112,10 @@ u_int	rss_gethashconfig(void);
 uint32_t	rss_hash_ip4_4tuple(struct in_addr src, u_short srcport,
 		    struct in_addr dst, u_short dstport);
 uint32_t	rss_hash_ip4_2tuple(struct in_addr src, struct in_addr dst);
-uint32_t	rss_hash_ip6_4tuple(struct in6_addr src, u_short srcport,
-		    struct in6_addr dst, u_short dstport);
-uint32_t	rss_hash_ip6_2tuple(struct in6_addr src,
-		    struct in6_addr dst);
+uint32_t	rss_hash_ip6_4tuple(const struct in6_addr *src, u_short srcport,
+		    const struct in6_addr *dst, u_short dstport);
+uint32_t	rss_hash_ip6_2tuple(const struct in6_addr *src,
+		    const struct in6_addr *dst);
 
 /*
  * Network stack interface to query desired CPU affinity of a packet.

Modified: head/sys/netinet6/in6_pcbgroup.c
==============================================================================
--- head/sys/netinet6/in6_pcbgroup.c	Wed Dec 31 22:49:02 2014	(r276483)
+++ head/sys/netinet6/in6_pcbgroup.c	Wed Dec 31 22:52:43 2014	(r276484)
@@ -105,7 +105,7 @@ in6_pcbgroup_bytuple(struct inpcbinfo *p
 	switch (pcbinfo->ipi_hashfields) {
 	case IPI_HASHFIELDS_4TUPLE:
 #ifdef RSS
-		hash = rss_hash_ip6_4tuple(*faddrp, fport, *laddrp, lport);
+		hash = rss_hash_ip6_4tuple(faddrp, fport, laddrp, lport);
 #else
 		hash = faddrp->s6_addr32[3] ^ fport;
 #endif
@@ -113,7 +113,7 @@ in6_pcbgroup_bytuple(struct inpcbinfo *p
 
 	case IPI_HASHFIELDS_2TUPLE:
 #ifdef RSS
-		hash = rss_hash_ip6_2tuple(*faddrp, *laddrp);
+		hash = rss_hash_ip6_2tuple(faddrp, laddrp);
 #else
 		hash = faddrp->s6_addr32[3] ^ laddrp->s6_addr32[3];
 #endif

Modified: head/sys/netinet6/udp6_usrreq.c
==============================================================================
--- head/sys/netinet6/udp6_usrreq.c	Wed Dec 31 22:49:02 2014	(r276483)
+++ head/sys/netinet6/udp6_usrreq.c	Wed Dec 31 22:52:43 2014	(r276484)
@@ -841,7 +841,7 @@ udp6_output(struct inpcb *inp, struct mb
 		 * XXX .. and we should likely cache this in the inpcb.
 		 */
 #ifdef	RSS
-		m->m_pkthdr.flowid = rss_hash_ip6_2tuple(*faddr, *laddr);
+		m->m_pkthdr.flowid = rss_hash_ip6_2tuple(faddr, laddr);
 		M_HASHTYPE_SET(m, M_HASHTYPE_RSS_IPV6);
 #endif
 		flags = 0;


More information about the svn-src-head mailing list