From owner-freebsd-current@FreeBSD.ORG Sat Dec 25 07:59:42 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B84C816A4CE; Sat, 25 Dec 2004 07:59:42 +0000 (GMT) Received: from aiolos.otenet.gr (aiolos.otenet.gr [195.170.0.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id EB2E943D41; Sat, 25 Dec 2004 07:59:41 +0000 (GMT) (envelope-from keramida@freebsd.org) Received: from gothmog.gr (patr530-b133.otenet.gr [212.205.244.141]) iBP7xdsC027587; Sat, 25 Dec 2004 09:59:39 +0200 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.1/8.13.1) with ESMTP id iBP7xcQe000694; Sat, 25 Dec 2004 09:59:38 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from giorgos@localhost) by gothmog.gr (8.13.1/8.13.1/Submit) id iBP7xcEP000693; Sat, 25 Dec 2004 09:59:38 +0200 (EET) (envelope-from keramida@freebsd.org) Date: Sat, 25 Dec 2004 09:59:38 +0200 From: Giorgos Keramidas To: freebsd-current@freebsd.org Message-ID: <20041225075938.GA669@gothmog.gr> References: <20041225075709.GA558@gothmog.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041225075709.GA558@gothmog.gr> cc: Scott Long Subject: Re: LORs in ipfilter X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Dec 2004 07:59:42 -0000 On 2004-12-25 09:57, Giorgos Keramidas wrote: > The locking changes of ipfilter have introduced a few LORs, [...] It may help to send over the changes I locally made to use mutexes instead of sx locks: %%% Index: sys/contrib/ipfilter/netinet/ip_compat.h =================================================================== RCS file: /home/ncvs/src/sys/contrib/ipfilter/netinet/ip_compat.h,v retrieving revision 1.24 diff -u -r1.24 ip_compat.h --- sys/contrib/ipfilter/netinet/ip_compat.h 24 Dec 2004 09:14:26 -0000 1.24 +++ sys/contrib/ipfilter/netinet/ip_compat.h 25 Dec 2004 07:49:31 -0000 @@ -424,15 +424,6 @@ # undef MUTEX_INIT # undef MUTEX_DESTROY #endif -#if defined(__FreeBSD_version) && (__FreeBSD_version >= 500043) -# include -# include -# include -# define USE_MUTEX 1 -# define kmutex_t struct mtx -# define KRWLOCK_T struct sx -# define NETBSD_PF -#endif #ifdef KERNEL # if SOLARIS # if SOLARIS2 >= 6 @@ -525,30 +516,26 @@ # else /* __sgi */ # if defined(__FreeBSD_version) && (__FreeBSD_version >= 500043) # include -# include # include # define USE_MUTEX 1 +# define NETBSD_PF # define kmutex_t struct mtx -# define KRWLOCK_T struct sx +# define KRWLOCK_T kmutex_t # define ATOMIC_INC(x) { MUTEX_ENTER(&ipf_rw); \ (x)++; MUTEX_EXIT(&ipf_rw); } # define ATOMIC_DEC(x) { MUTEX_ENTER(&ipf_rw); \ (x)--; MUTEX_EXIT(&ipf_rw); } # define MUTEX_ENTER(x) mtx_lock(x) -# define READ_ENTER(x) sx_slock(x) -# define WRITE_ENTER(x) sx_xlock(x) +# define READ_ENTER(x) MUTEX_ENTER(x) +# define WRITE_ENTER(x) MUTEX_ENTER(x) # define RW_UPGRADE(x) ; -# define MUTEX_DOWNGRADE(x) sx_downgrade(x) -# define RWLOCK_INIT(x, y, z) sx_init((x), (y)) -# define RWLOCK_EXIT(x) do { \ - if ((x)->sx_cnt < 0) \ - sx_xunlock(x); \ - else \ - sx_sunlock(x); \ - } while (0) +# define MUTEX_DOWNGRADE(x) ; # define MUTEX_EXIT(x) mtx_unlock(x) +# define RWLOCK_EXIT(x) mtx_unlock(x) # define MUTEX_INIT(x,y,z) mtx_init((x), (y), NULL, MTX_DEF) # define MUTEX_DESTROY(x) mtx_destroy(x) +# define RWLOCK_INIT(x,y,z) mtx_init((x), (y), NULL, MTX_DEF) +# define RW_DESTROY(x) MUTEX_DESTROY(x) # else # define ATOMIC_INC(x) (x)++ # define ATOMIC_DEC(x) (x)-- %%%