Date: Tue, 12 Sep 2000 10:13:48 +0100 (BST) From: Doug Rabson <dfr@nlsystems.com> To: John Baldwin <jhb@pike.osd.bsdi.com> Cc: dfr@FreeBSD.org, alpha@FreeBSD.org Subject: Re: Bug in spinlocks? Message-ID: <Pine.BSF.4.21.0009121010170.86297-100000@salmon.nlsystems.com> In-Reply-To: <200009112037.NAA61735@pike.osd.bsdi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 11 Sep 2000, John Baldwin wrote: > Hmm, is there any reason why we aren't disabling interrupts on the alpha > when we obtain spinlocks? In the i386 code we use the following macro: > > /* Get a spin lock, handle recursion inline (as the less common case) */ > #define _getlock_spin_block(mp, tid, type) do { \ > u_int _mtx_fl = read_eflags(); \ > disable_intr(); \ > if (atomic_cmpset_int(&(mp)->mtx_lock, MTX_UNOWNED, (tid)) == 0) \ > mtx_enter_hard(mp, (type) & MTX_HARDOPTS, _mtx_fl); \ > else \ > (mp)->mtx_savefl = _mtx_fl; \ > } while (0) > > on the alpha it is almost the same: > > /* > * Get a spin lock, handle recusion inline (as the less common case) > */ > > #define _getlock_spin_block(mp, tid, type) do { \ > u_int _ipl = alpha_pal_rdps() & ALPHA_PSL_IPL_MASK; \ > if (atomic_cmpset_64(&(mp)->mtx_lock, MTX_UNOWNED, (tid)) == 0) \ > mtx_enter_hard(mp, (type) & MTX_HARDOPTS, _ipl); \ > else { \ > alpha_mb(); \ > (mp)->mtx_saveipl = _ipl; \ > } \ > } while (0) > > Note that in the alpha we are just saving and restoring the ipl, but we > aren't actually changing it to disable interrupts. Looks like a major brain failure on my part. Try these (untested) changes: Index: mutex.h =================================================================== RCS file: /home/ncvs/src/sys/alpha/include/mutex.h,v retrieving revision 1.5 diff -u -r1.5 mutex.h --- mutex.h 2000/09/09 23:18:47 1.5 +++ mutex.h 2000/09/12 09:13:25 @@ -223,9 +223,9 @@ extern char STR_IEN[]; extern char STR_IDIS[]; #endif /* MTX_STRS */ -#define ASS_IEN MPASS2((alpha_pal_rdps & ALPHA_PSL_IPL_MASK) \ +#define ASS_IEN MPASS2((alpha_pal_rdps() & ALPHA_PSL_IPL_MASK) \ == ALPHA_PSL_IPL_HIGH, STR_IEN) -#define ASS_IDIS MPASS2((alpha_pal_rdps & ALPHA_PSL_IPL_MASK) \ +#define ASS_IDIS MPASS2((alpha_pal_rdps() & ALPHA_PSL_IPL_MASK) \ != ALPHA_PSL_IPL_HIGH, STR_IDIS) #endif /* INVARIANTS */ @@ -326,7 +326,7 @@ */ #define _getlock_spin_block(mp, tid, type) do { \ - u_int _ipl = alpha_pal_rdps() & ALPHA_PSL_IPL_MASK; \ + u_int _ipl = alpha_pal_swpipl(ALPHA_PSL_IPL_HIGH); \ if (atomic_cmpset_64(&(mp)->mtx_lock, MTX_UNOWNED, (tid)) == 0) \ mtx_enter_hard(mp, (type) & MTX_HARDOPTS, _ipl); \ else { \ @@ -544,8 +544,8 @@ * Simple assembly macros to get and release non-recursive spin locks */ #define MTX_ENTER(lck) \ - call_pal PAL_OSF1_rdps; \ - and v0, ALPHA_PSL_IPL_MASK, v0; \ + ldiq a0, ALPHA_PSL_IPL_HIGH; \ + call_pal PAL_OSF1_swpipl; \ 1: ldq_l a0, lck+MTX_LOCK; \ cmpeq a0, MTX_UNOWNED, a1; \ beq a1, 1b; \ @@ -553,9 +553,7 @@ stq_c a0, lck+MTX_LOCK; \ beq a0, 1b; \ mb; \ - stl v0, lck+MTX_SAVEIPL; \ - ldq a0, ALPHA_PSL_IPL_HIGH; \ - call_pal PSL_OSF1_swpipl + stl v0, lck+MTX_SAVEIPL #define MTX_EXIT(lck) \ mb; \ -- Doug Rabson Mail: dfr@nlsystems.com Nonlinear Systems Ltd. Phone: +44 20 8348 3944 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0009121010170.86297-100000>