Date: Tue, 17 Jul 2012 13:38:31 +0400 From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: Luigi Rizzo <rizzo@iet.unipi.it> Cc: Doug Barton <dougb@freebsd.org>, net@freebsd.org Subject: Re: FreeBSD 10G forwarding performance @Intel Message-ID: <50053297.8060008@FreeBSD.org> In-Reply-To: <50052419.7010601@FreeBSD.org> References: <4FF36438.2030902@FreeBSD.org> <4FF3E2C4.7050701@FreeBSD.org> <4FF3FB14.8020006@FreeBSD.org> <4FF402D1.4000505@FreeBSD.org> <20120704091241.GA99164@onelab2.iet.unipi.it> <4FF412B9.3000406@FreeBSD.org> <20120704154856.GC3680@onelab2.iet.unipi.it> <4FF59955.5090406@FreeBSD.org> <20120706061126.GA65432@onelab2.iet.unipi.it> <500452A5.3070501@FreeBSD.org> <20120716212249.GA14607@onelab2.iet.unipi.it> <50052419.7010601@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------000002080600050305070803 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 17.07.2012 12:36, Alexander V. Chernikov wrote: > On 17.07.2012 01:22, Luigi Rizzo wrote: >> On Mon, Jul 16, 2012 at 09:43:01PM +0400, Alexander V. Chernikov wrote: >>> On 06.07.2012 10:11, Luigi Rizzo wrote: >>>> On Thu, Jul 05, 2012 at 05:40:37PM +0400, Alexander V. Chernikov wrote: >>>>> On 04.07.2012 19:48, Luigi Rizzo wrote: > >> well, it seems that the counters are costing some 10% which is >> not negligible (60ns per packet according to your test). >> Also i'd be curious if you get better savings if you >> have actual conflicts on the rulesets (e.g. what happens >> with a ruleset that has, say, ten "count ip from any to any" rules) ? > > It is a bit difficult to get _exact_ performance numbers since 0.5% of > linerate is ~ 70kpps, however > > 1.98 MPPS > >> net.inet.ip.fw.update_counters=1 > >> net.inet.ip.fw.enable=1 > 1.67 MPPS > > .. And here it is time to check ipfw rmlock performance another time, > since we're acquiring recursive rmlock (pfil) and rwlock (ipfw) twice. Merged r234648 for optimized rmlocks + conversion code attached. .. No significant improvement: The same 240kpps loss as in first test. 2123542 0 0 140309220 2125793 0 191227258 0 2125316 0 0 140167332 2119988 0 140427764 0 2121195 0 0 140353100 2126753 0 140264154 0 1995783 64677 0 137285216 1987194 0 132939934 0 1929111 170532 0 139248154 1927044 0 127285506 0 1905240 213804 0 140059092 1906731 0 78969668 0 1908064 219536 0 140444988 1907710 0 173344532 0 1906948 218554 0 140365550 1906791 0 79015778 0 1910961 214023 0 140395374 1911046 0 173126686 0 1913418 211265 0 140275990 1913272 0 126596628 0 Another try without these changes: 2141665 0 0 141533920 2143295 0 141662810 0 2141647 0 0 141536144 2142662 0 89849076 0 2143523 0 0 113655814 2142859 0 89734352 0 2024970 1528 0 164095778 2011710 0 241024066 0 1905563 239180 0 141749498 1909889 0 83090452 0 1906343 237516 0 141518736 1903779 0 168894600 0 1907890 235413 0 141558608 1907365 0 126036784 0 ... 1894339 1267 0 125099880 1892903 0 125032806 0 1885989 0 0 124627036 1894571 0 82456512 0 1889637 0 0 124735294 1890231 0 167681224 0 -- WBR, Alexander --------------000002080600050305070803 Content-Type: text/plain; charset=UTF-8; name="ipfw_rmlocks.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ipfw_rmlocks.diff" Index: sys/netinet/ipfw/ip_fw_private.h =================================================================== --- sys/netinet/ipfw/ip_fw_private.h (revision 234657) +++ sys/netinet/ipfw/ip_fw_private.h (working copy) @@ -226,7 +226,7 @@ struct ip_fw_chain { spinlock_t rwmtx; spinlock_t uh_lock; #else - struct rwlock rwmtx; + struct rmlock st_lock; /* chain lock */ struct rwlock uh_lock; /* lock for upper half */ #endif uint32_t id; /* ruleset id */ @@ -241,21 +241,21 @@ struct sockopt; /* used by tcp_var.h */ */ #define IPFW_LOCK_INIT(_chain) do { \ - rw_init(&(_chain)->rwmtx, "IPFW static rules"); \ + rm_init(&(_chain)->st_lock, "IPFW static rules"); \ rw_init(&(_chain)->uh_lock, "IPFW UH lock"); \ } while (0) #define IPFW_LOCK_DESTROY(_chain) do { \ - rw_destroy(&(_chain)->rwmtx); \ + rm_destroy(&(_chain)->st_lock); \ rw_destroy(&(_chain)->uh_lock); \ } while (0) -#define IPFW_WLOCK_ASSERT(_chain) rw_assert(&(_chain)->rwmtx, RA_WLOCKED) +#define IPFW_WLOCK_ASSERT(_chain) rm_wowned(&(_chain)->st_lock) -#define IPFW_RLOCK(p) rw_rlock(&(p)->rwmtx) -#define IPFW_RUNLOCK(p) rw_runlock(&(p)->rwmtx) -#define IPFW_WLOCK(p) rw_wlock(&(p)->rwmtx) -#define IPFW_WUNLOCK(p) rw_wunlock(&(p)->rwmtx) +#define IPFW_RLOCK(p) rm_rlock(&(p)->st_lock, &tracker) +#define IPFW_RUNLOCK(p) rm_runlock(&(p)->st_lock, &tracker) +#define IPFW_WLOCK(p) rm_wlock(&(p)->st_lock) +#define IPFW_WUNLOCK(p) rm_wunlock(&(p)->st_lock) #define IPFW_UH_RLOCK(p) rw_rlock(&(p)->uh_lock) #define IPFW_UH_RUNLOCK(p) rw_runlock(&(p)->uh_lock) Index: sys/netinet/ipfw/ip_dn_glue.c =================================================================== --- sys/netinet/ipfw/ip_dn_glue.c (revision 234657) +++ sys/netinet/ipfw/ip_dn_glue.c (working copy) @@ -42,6 +42,7 @@ #include <sys/priv.h> #include <sys/proc.h> #include <sys/rwlock.h> +#include <sys/rmlock.h> #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/time.h> Index: sys/netinet/ipfw/ip_fw_log.c =================================================================== --- sys/netinet/ipfw/ip_fw_log.c (revision 234657) +++ sys/netinet/ipfw/ip_fw_log.c (working copy) @@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/mbuf.h> #include <sys/kernel.h> +#include <sys/lock.h> +#include <sys/rmlock.h> #include <sys/socket.h> #include <sys/sysctl.h> #include <sys/syslog.h> Index: sys/netinet/ipfw/ip_fw_sockopt.c =================================================================== --- sys/netinet/ipfw/ip_fw_sockopt.c (revision 234657) +++ sys/netinet/ipfw/ip_fw_sockopt.c (working copy) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include <sys/priv.h> #include <sys/proc.h> #include <sys/rwlock.h> +#include <sys/rmlock.h> #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/sysctl.h> @@ -944,6 +945,7 @@ ipfw_ctl(struct sockopt *sopt) uint32_t opt; char xbuf[128]; ip_fw3_opheader *op3 = NULL; + struct rm_priotracker tracker; /* rmlock tracker */ error = priv_check(sopt->sopt_td, PRIV_NETINET_IPFW); if (error) Index: sys/netinet/ipfw/ip_fw_nat.c =================================================================== --- sys/netinet/ipfw/ip_fw_nat.c (revision 234657) +++ sys/netinet/ipfw/ip_fw_nat.c (working copy) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/lock.h> #include <sys/module.h> #include <sys/rwlock.h> +#include <sys/rmlock.h> #define IPFW_INTERNAL /* Access to protected data structures in ip_fw.h. */ @@ -210,6 +211,7 @@ ipfw_nat(struct ip_fw_args *args, struct cfg_nat * int ldt, retval, found; struct ip_fw_chain *chain; char *c; + struct rm_priotracker tracker; /* rmlock tracker */ ldt = 0; retval = 0; @@ -493,6 +495,7 @@ ipfw_nat_get_cfg(struct sockopt *sopt) struct cfg_spool *s; char *data; int gencnt, nat_cnt, len, error; + struct rm_priotracker tracker; /* rmlock tracker */ nat_cnt = 0; len = sizeof(nat_cnt); @@ -551,6 +554,7 @@ ipfw_nat_get_log(struct sockopt *sopt) struct cfg_nat *ptr; int i, size; struct ip_fw_chain *chain; + struct rm_priotracker tracker; /* rmlock tracker */ chain = &V_layer3_chain; Index: sys/netinet/ipfw/ip_fw_dynamic.c =================================================================== --- sys/netinet/ipfw/ip_fw_dynamic.c (revision 234657) +++ sys/netinet/ipfw/ip_fw_dynamic.c (working copy) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include <sys/mbuf.h> #include <sys/kernel.h> #include <sys/lock.h> +#include <sys/rmlock.h> #include <sys/socket.h> #include <sys/sysctl.h> #include <sys/syslog.h> Index: sys/netinet/ipfw/ip_fw_table.c =================================================================== --- sys/netinet/ipfw/ip_fw_table.c (revision 234657) +++ sys/netinet/ipfw/ip_fw_table.c (working copy) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/lock.h> #include <sys/rwlock.h> +#include <sys/rmlock.h> #include <sys/socket.h> #include <net/if.h> /* ip_fw.h requires IFNAMSIZ */ #include <net/radix.h> Index: sys/netinet/ipfw/ip_dn_io.c =================================================================== --- sys/netinet/ipfw/ip_dn_io.c (revision 234657) +++ sys/netinet/ipfw/ip_dn_io.c (working copy) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include <sys/priv.h> #include <sys/proc.h> #include <sys/rwlock.h> +#include <sys/rmlock.h> #include <sys/socket.h> #include <sys/time.h> #include <sys/sysctl.h> Index: sys/netinet/ipfw/ip_fw2.c =================================================================== --- sys/netinet/ipfw/ip_fw2.c (revision 234657) +++ sys/netinet/ipfw/ip_fw2.c (working copy) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include <sys/priv.h> #include <sys/proc.h> #include <sys/rwlock.h> +#include <sys/rmlock.h> #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/sysctl.h> @@ -907,6 +908,7 @@ ipfw_chk(struct ip_fw_args *args) int is_ipv4 = 0; int done = 0; /* flag to exit the outer loop */ + struct rm_priotracker tracker; /* rmlock tracker */ if (m->m_flags & M_SKIP_FIREWALL || (! V_ipfw_vnet_ready)) return (IP_FW_PASS); /* accept */ Index: sys/netinet/ipfw/ip_dummynet.c =================================================================== --- sys/netinet/ipfw/ip_dummynet.c (revision 234657) +++ sys/netinet/ipfw/ip_dummynet.c (working copy) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include <sys/priv.h> #include <sys/proc.h> #include <sys/rwlock.h> +#include <sys/rmlock.h> #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/time.h> Index: sys/netgraph/ng_ipfw.c =================================================================== --- sys/netgraph/ng_ipfw.c (revision 234657) +++ sys/netgraph/ng_ipfw.c (working copy) @@ -33,6 +33,7 @@ #include <sys/systm.h> #include <sys/kernel.h> #include <sys/lock.h> +#include <sys/rmlock.h> #include <sys/mbuf.h> #include <sys/malloc.h> #include <sys/ctype.h> Index: sys/net/if_ethersubr.c =================================================================== --- sys/net/if_ethersubr.c (revision 234657) +++ sys/net/if_ethersubr.c (working copy) @@ -41,6 +41,7 @@ #include <sys/systm.h> #include <sys/kernel.h> #include <sys/lock.h> +#include <sys/rmlock.h> #include <sys/malloc.h> #include <sys/module.h> #include <sys/mbuf.h> --------------000002080600050305070803--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50053297.8060008>