Re: LORs in ipfilter

From: Giorgos Keramidas <keramida_at_freebsd.org>
Date: Sat, 25 Dec 2004 09:59:38 +0200
On 2004-12-25 09:57, Giorgos Keramidas <keramida_at_freebsd.org> 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
_at__at_ -424,15 +424,6 _at__at_
 # undef	MUTEX_INIT
 # undef	MUTEX_DESTROY
 #endif
-#if defined(__FreeBSD_version) && (__FreeBSD_version >= 500043)
-#  include <sys/mutex.h>
-#  include <sys/sx.h>
-#  include <machine/atomic.h>
-#  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
_at__at_ -525,30 +516,26 _at__at_
 #  else /* __sgi */
 #   if defined(__FreeBSD_version) && (__FreeBSD_version >= 500043)
 #    include <sys/mutex.h>
-#    include <sys/sx.h>
 #    include <machine/atomic.h>
 #    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)--
%%%
Received on Sat Dec 25 2004 - 06:59:42 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:25 UTC