svn commit: r260077 - stable/10/sys/net

Scott Long scottl at FreeBSD.org
Mon Dec 30 05:19:28 UTC 2013


Author: scottl
Date: Mon Dec 30 05:19:27 2013
New Revision: 260077
URL: http://svnweb.freebsd.org/changeset/base/260077

Log:
  Merge r256563:
  
  In the flowtable scanner, restart the scan at the last found position,
  not at position 0.  Changes the scanner from O(N^2) to O(N).
  
  Reviewed by:    emax
  Obtained from:  Netflix

Modified:
  stable/10/sys/net/flowtable.c

Modified: stable/10/sys/net/flowtable.c
==============================================================================
--- stable/10/sys/net/flowtable.c	Mon Dec 30 05:02:57 2013	(r260076)
+++ stable/10/sys/net/flowtable.c	Mon Dec 30 05:19:27 2013	(r260077)
@@ -1401,7 +1401,7 @@ fle_free(struct flentry *fle, struct flo
 static void
 flowtable_free_stale(struct flowtable *ft, struct rtentry *rt)
 {
-	int curbit = 0, count;
+	int curbit = 0, count, tmpsize;
 	struct flentry *fle,  **flehead, *fleprev;
 	struct flentry *flefreehead, *flefreetail, *fletmp;
 	bitstr_t *mask, *tmpmask;
@@ -1410,6 +1410,7 @@ flowtable_free_stale(struct flowtable *f
 	flefreehead = flefreetail = NULL;
 	mask = flowtable_mask(ft);
 	tmpmask = ft->ft_tmpmask;
+	tmpsize = ft->ft_size;
 	memcpy(tmpmask, mask, ft->ft_size/8);
 	/*
 	 * XXX Note to self, bit_ffs operates at the byte level
@@ -1479,7 +1480,9 @@ flowtable_free_stale(struct flowtable *f
 			bit_clear(mask, curbit);
 		FL_ENTRY_UNLOCK(ft, curbit);
 		bit_clear(tmpmask, curbit);
-		bit_ffs(tmpmask, ft->ft_size, &curbit);
+		tmpmask += (curbit / 8);
+		tmpsize -= (curbit / 8) * 8;
+		bit_ffs(tmpmask, tmpsize, &curbit);
 	}
 	count = 0;
 	while ((fle = flefreehead) != NULL) {


More information about the svn-src-stable-10 mailing list