Date: Sat, 25 Dec 2004 09:59:38 +0200 From: Giorgos Keramidas <keramida@freebsd.org> To: freebsd-current@freebsd.org Cc: Scott Long <scottl@freebsd.org> Subject: Re: LORs in ipfilter Message-ID: <20041225075938.GA669@gothmog.gr> In-Reply-To: <20041225075709.GA558@gothmog.gr> References: <20041225075709.GA558@gothmog.gr>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2004-12-25 09:57, Giorgos Keramidas <keramida@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
@@ -424,15 +424,6 @@
# 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
@@ -525,30 +516,26 @@
# 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)--
%%%
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041225075938.GA669>
