Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 May 2018 14:13:57 +0200
From:      "Hartmann, O." <ohartmann@walstatt.org>
To:        Kristof Provost <kp@FreeBSD.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r334375 - in head/sys: net netpfil/pf
Message-ID:  <20180530141347.1bf868ac@hermann>
In-Reply-To: <201805300711.w4U7BYjS066960@repo.freebsd.org>
References:  <201805300711.w4U7BYjS066960@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 30 May 2018 07:11:34 +0000 (UTC)
Kristof Provost <kp@FreeBSD.org> wrote:

> Author: kp
> Date: Wed May 30 07:11:33 2018
> New Revision: 334375
> URL: https://svnweb.freebsd.org/changeset/base/334375
> 
> Log:
>   pf: Replace rwlock on PF_RULES_LOCK with rmlock
>   
>   Given that PF_RULES_LOCK is a mostly read lock, replace the rwlock
> with rmlock. This change improves packet processing rate in high pps
> environments. Benchmarking by olivier@ shows a 65% improvement in pps.
>   
>   While here, also eliminate all appearances of "sys/rwlock.h"
> includes since it is not used anymore.
>   
>   Submitted by:	farrokhi@
>   Differential Revision:	https://reviews.freebsd.org/D15502
> 
> Modified:
>   head/sys/net/pfvar.h
>   head/sys/netpfil/pf/if_pfsync.c
>   head/sys/netpfil/pf/pf.c
>   head/sys/netpfil/pf/pf_if.c
>   head/sys/netpfil/pf/pf_ioctl.c
>   head/sys/netpfil/pf/pf_lb.c
>   head/sys/netpfil/pf/pf_norm.c
>   head/sys/netpfil/pf/pf_osfp.c
>   head/sys/netpfil/pf/pf_table.c
> 
> Modified: head/sys/net/pfvar.h
> ==============================================================================
> --- head/sys/net/pfvar.h	Wed May 30 06:29:22 2018
> (r334374) +++ head/sys/net/pfvar.h	Wed May 30 07:11:33
> 2018	(r334375) @@ -38,8 +38,10 @@
>  #include <sys/param.h>
>  #include <sys/queue.h>
>  #include <sys/counter.h>
> +#include <sys/cpuset.h>
>  #include <sys/malloc.h>
>  #include <sys/refcount.h>
> +#include <sys/rmlock.h>
>  #include <sys/tree.h>
>  #include <vm/uma.h>
>  
> @@ -147,14 +149,15 @@ extern struct mtx pf_unlnkdrules_mtx;
>  #define	PF_UNLNKDRULES_LOCK()
> mtx_lock(&pf_unlnkdrules_mtx) #define
> PF_UNLNKDRULES_UNLOCK()	mtx_unlock(&pf_unlnkdrules_mtx) 
> -extern struct rwlock pf_rules_lock;
> -#define	PF_RULES_RLOCK()	rw_rlock(&pf_rules_lock)
> -#define	PF_RULES_RUNLOCK()	rw_runlock(&pf_rules_lock)
> -#define	PF_RULES_WLOCK()	rw_wlock(&pf_rules_lock)
> -#define	PF_RULES_WUNLOCK()	rw_wunlock(&pf_rules_lock)
> -#define	PF_RULES_ASSERT()	rw_assert(&pf_rules_lock,
> RA_LOCKED) -#define	PF_RULES_RASSERT()
> rw_assert(&pf_rules_lock, RA_RLOCKED) -#define
> PF_RULES_WASSERT()	rw_assert(&pf_rules_lock, RA_WLOCKED)
> +extern struct rmlock pf_rules_lock; +#define
> PF_RULES_RLOCK_TRACKER	struct rm_priotracker _pf_rules_tracker
> +#define	PF_RULES_RLOCK()	rm_rlock(&pf_rules_lock,
> &_pf_rules_tracker) +#define	PF_RULES_RUNLOCK()
> rm_runlock(&pf_rules_lock, &_pf_rules_tracker) +#define
> PF_RULES_WLOCK()	rm_wlock(&pf_rules_lock) +#define
> PF_RULES_WUNLOCK()	rm_wunlock(&pf_rules_lock) +#define
> PF_RULES_ASSERT()	rm_assert(&pf_rules_lock, RA_LOCKED)
> +#define	PF_RULES_RASSERT()	rm_assert(&pf_rules_lock,
> RA_RLOCKED) +#define	PF_RULES_WASSERT()
> rm_assert(&pf_rules_lock, RA_WLOCKED) extern struct sx pf_end_lock; 
> 
> Modified: head/sys/netpfil/pf/if_pfsync.c
> ==============================================================================
> --- head/sys/netpfil/pf/if_pfsync.c	Wed May 30 06:29:22
> 2018	(r334374) +++ head/sys/netpfil/pf/if_pfsync.c	Wed
> May 30 07:11:33 2018	(r334375) @@ -587,6 +587,8 @@
> pfsync_input(struct mbuf **mp, int *offp __unused, int int rv;
>  	uint16_t count;
>  
> +	PF_RULES_RLOCK_TRACKER;
> +
>  	*mp = NULL;
>  	V_pfsyncstats.pfsyncs_ipackets++;
>  
> 
> Modified: head/sys/netpfil/pf/pf.c
> ==============================================================================
> --- head/sys/netpfil/pf/pf.c	Wed May 30 06:29:22 2018
> (r334374) +++ head/sys/netpfil/pf/pf.c	Wed May 30 07:11:33
> 2018	(r334375) @@ -5874,6 +5874,8 @@ pf_test(int dir, int
> pflags, struct ifnet *ifp, struct struct pf_pdesc		 pd;
>  	int			 off, dirndx, pqid = 0;
>  
> +	PF_RULES_RLOCK_TRACKER;
> +
>  	M_ASSERTPKTHDR(m);
>  
>  	if (!V_pf_status.running)
> @@ -6261,6 +6263,7 @@ pf_test6(int dir, int pflags, struct ifnet
> *ifp, struc struct pf_pdesc		 pd;
>  	int			 off, terminal = 0, dirndx,
> rh_cnt = 0, pqid = 0; 
> +	PF_RULES_RLOCK_TRACKER;
>  	M_ASSERTPKTHDR(m);
>  
>  	if (!V_pf_status.running)
> 
> Modified: head/sys/netpfil/pf/pf_if.c
> ==============================================================================
> --- head/sys/netpfil/pf/pf_if.c	Wed May 30 06:29:22
> 2018	(r334374) +++ head/sys/netpfil/pf/pf_if.c	Wed May
> 30 07:11:33 2018	(r334375) @@ -46,7 +46,6 @@
> __FBSDID("$FreeBSD$"); #include <sys/eventhandler.h>
>  #include <sys/lock.h>
>  #include <sys/mbuf.h>
> -#include <sys/rwlock.h>
>  #include <sys/socket.h>
>  
>  #include <net/if.h>
> 
> Modified: head/sys/netpfil/pf/pf_ioctl.c
> ==============================================================================
> --- head/sys/netpfil/pf/pf_ioctl.c	Wed May 30 06:29:22
> 2018	(r334374) +++ head/sys/netpfil/pf/pf_ioctl.c	Wed
> May 30 07:11:33 2018	(r334375) @@ -59,7 +59,6 @@
> __FBSDID("$FreeBSD$"); #include <sys/mbuf.h>
>  #include <sys/module.h>
>  #include <sys/proc.h>
> -#include <sys/rwlock.h>
>  #include <sys/smp.h>
>  #include <sys/socket.h>
>  #include <sys/sysctl.h>
> @@ -202,7 +201,7 @@ VNET_DEFINE(int, pf_vnet_active);
>  int pf_end_threads;
>  struct proc *pf_purge_proc;
>  
> -struct rwlock			pf_rules_lock;
> +struct rmlock			pf_rules_lock;
>  struct sx			pf_ioctl_lock;
>  struct sx			pf_end_lock;
>  
> @@ -995,6 +994,7 @@ static int
>  pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags,
> struct thread *td) {
>  	int			 error = 0;
> +	PF_RULES_RLOCK_TRACKER;
>  
>  	/* XXX keep in sync with switch() below */
>  	if (securelevel_gt(td->td_ucred, 2))
> @@ -3924,7 +3924,7 @@ pf_load(void)
>  {
>  	int error;
>  
> -	rw_init(&pf_rules_lock, "pf rulesets");
> +	rm_init(&pf_rules_lock, "pf rulesets");
>  	sx_init(&pf_ioctl_lock, "pf ioctl");
>  	sx_init(&pf_end_lock, "pf end thread");
>  
> @@ -3997,7 +3997,7 @@ pf_unload(void)
>  
>  	pfi_cleanup();
>  
> -	rw_destroy(&pf_rules_lock);
> +	rm_destroy(&pf_rules_lock);
>  	sx_destroy(&pf_ioctl_lock);
>  	sx_destroy(&pf_end_lock);
>  }
> 
> Modified: head/sys/netpfil/pf/pf_lb.c
> ==============================================================================
> --- head/sys/netpfil/pf/pf_lb.c	Wed May 30 06:29:22
> 2018	(r334374) +++ head/sys/netpfil/pf/pf_lb.c	Wed May
> 30 07:11:33 2018	(r334375) @@ -46,7 +46,6 @@
> __FBSDID("$FreeBSD$"); #include <sys/param.h>
>  #include <sys/lock.h>
>  #include <sys/mbuf.h>
> -#include <sys/rwlock.h>
>  #include <sys/socket.h>
>  #include <sys/sysctl.h>
>  
> 
> Modified: head/sys/netpfil/pf/pf_norm.c
> ==============================================================================
> --- head/sys/netpfil/pf/pf_norm.c	Wed May 30 06:29:22
> 2018	(r334374) +++ head/sys/netpfil/pf/pf_norm.c	Wed
> May 30 07:11:33 2018	(r334375) @@ -41,7 +41,6 @@
> __FBSDID("$FreeBSD$"); #include <sys/mbuf.h>
>  #include <sys/mutex.h>
>  #include <sys/refcount.h>
> -#include <sys/rwlock.h>
>  #include <sys/socket.h>
>  
>  #include <net/if.h>
> 
> Modified: head/sys/netpfil/pf/pf_osfp.c
> ==============================================================================
> --- head/sys/netpfil/pf/pf_osfp.c	Wed May 30 06:29:22
> 2018	(r334374) +++ head/sys/netpfil/pf/pf_osfp.c	Wed
> May 30 07:11:33 2018	(r334375) @@ -27,7 +27,6 @@
> __FBSDID("$FreeBSD$"); #include <sys/kernel.h>
>  #include <sys/lock.h>
>  #include <sys/mbuf.h>
> -#include <sys/rwlock.h>
>  #include <sys/socket.h>
>  
>  #include <netinet/in.h>
> 
> Modified: head/sys/netpfil/pf/pf_table.c
> ==============================================================================
> --- head/sys/netpfil/pf/pf_table.c	Wed May 30 06:29:22
> 2018	(r334374) +++ head/sys/netpfil/pf/pf_table.c	Wed
> May 30 07:11:33 2018	(r334375) @@ -44,7 +44,6 @@
> __FBSDID("$FreeBSD$"); #include <sys/mbuf.h>
>  #include <sys/mutex.h>
>  #include <sys/refcount.h>
> -#include <sys/rwlock.h>
>  #include <sys/socket.h>
>  #include <vm/uma.h>
>  
> _______________________________________________
> svn-src-head@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-head
> To unsubscribe, send any mail to
> "svn-src-head-unsubscribe@freebsd.org"

It seems, this commit issues an error while compiling the kernel:


[...]
--- all_subdir_pf ---
--- pf_ruleset.o ---
In file included from /usr/src/sys/netpfil/pf/pf_ruleset.c:57:
In file included from /usr/src/sys/net/pfvar.h:44:
In file included from /usr/src/sys/sys/rmlock.h:37:
/usr/src/sys/sys/mutex.h:96:52: error: expected ')'
int     _mtx_trylock_flags_int(struct mtx *m, int opts
LOCK_FILE_LINE_ARG_DEF); ^
/usr/src/sys/sys/mutex.h:96:27: note: to match this '('
int     _mtx_trylock_flags_int(struct mtx *m, int opts
LOCK_FILE_LINE_ARG_DEF); ^
/usr/src/sys/sys/mutex.h:100:5: error: 'LOCK_DEBUG' is not defined,
evaluates to 0 [-Werror,-Wundef] #if LOCK_DEBUG > 0
    ^
/usr/src/sys/sys/mutex.h:111:5: error: 'LOCK_DEBUG' is not defined,
evaluates to 0 [-Werror,-Wundef] #if LOCK_DEBUG > 0



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180530141347.1bf868ac>