Date: Tue, 25 Jan 2011 22:08:43 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r217856 - in stable/7/sys: amd64/amd64 arm/arm i386/i386 ia64/ia64 pc98/pc98 powerpc/powerpc sparc64/sparc64 sun4v/sun4v Message-ID: <201101252208.p0PM8hN7052738@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Tue Jan 25 22:08:43 2011 New Revision: 217856 URL: http://svn.freebsd.org/changeset/base/217856 Log: MFC 214835: Adjust the order of operations in spinlock_enter() and spinlock_exit() to work properly with single-stepping in a kernel debugger. Modified: stable/7/sys/amd64/amd64/machdep.c stable/7/sys/arm/arm/machdep.c stable/7/sys/i386/i386/machdep.c stable/7/sys/ia64/ia64/machdep.c stable/7/sys/pc98/pc98/machdep.c stable/7/sys/powerpc/powerpc/machdep.c stable/7/sys/sparc64/sparc64/machdep.c stable/7/sys/sun4v/sun4v/machdep.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/amd64/amd64/machdep.c ============================================================================== --- stable/7/sys/amd64/amd64/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/amd64/amd64/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -1405,11 +1405,15 @@ void spinlock_enter(void) { struct thread *td; + register_t flags; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_flags = intr_disable(); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + flags = intr_disable(); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_flags = flags; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -1417,12 +1421,14 @@ void spinlock_exit(void) { struct thread *td; + register_t flags; td = curthread; critical_exit(); + flags = td->td_md.md_saved_flags; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - intr_restore(td->td_md.md_saved_flags); + intr_restore(flags); } /* Modified: stable/7/sys/arm/arm/machdep.c ============================================================================== --- stable/7/sys/arm/arm/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/arm/arm/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -475,11 +475,15 @@ void spinlock_enter(void) { struct thread *td; + register_t cspr; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_cspr = disable_interrupts(I32_bit | F32_bit); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + cspr = disable_interrupts(I32_bit | F32_bit); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_cspr = cspr; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -487,12 +491,14 @@ void spinlock_exit(void) { struct thread *td; + register_t cspr; td = curthread; critical_exit(); + cspr = td->td_md.md_saved_cspr; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - restore_interrupts(td->td_md.md_saved_cspr); + restore_interrupts(cspr); } /* Modified: stable/7/sys/i386/i386/machdep.c ============================================================================== --- stable/7/sys/i386/i386/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/i386/i386/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -2440,11 +2440,15 @@ void spinlock_enter(void) { struct thread *td; + register_t flags; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_flags = intr_disable(); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + flags = intr_disable(); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_flags = flags; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -2452,12 +2456,14 @@ void spinlock_exit(void) { struct thread *td; + register_t flags; td = curthread; critical_exit(); + flags = td->td_md.md_saved_flags; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - intr_restore(td->td_md.md_saved_flags); + intr_restore(flags); } #if defined(I586_CPU) && !defined(NO_F00F_HACK) Modified: stable/7/sys/ia64/ia64/machdep.c ============================================================================== --- stable/7/sys/ia64/ia64/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/ia64/ia64/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -410,11 +410,15 @@ void spinlock_enter(void) { struct thread *td; + int intr; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_intr = intr_disable(); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + intr = intr_disable(); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_intr = intr; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -422,12 +426,14 @@ void spinlock_exit(void) { struct thread *td; + int intr; td = curthread; critical_exit(); + intr = td->td_md.md_saved_intr; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - intr_restore(td->td_md.md_saved_intr); + intr_restore(intr); } void Modified: stable/7/sys/pc98/pc98/machdep.c ============================================================================== --- stable/7/sys/pc98/pc98/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/pc98/pc98/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -2179,11 +2179,15 @@ void spinlock_enter(void) { struct thread *td; + register_t flags; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_flags = intr_disable(); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + flags = intr_disable(); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_flags = flags; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -2191,12 +2195,14 @@ void spinlock_exit(void) { struct thread *td; + register_t flags; td = curthread; critical_exit(); + flags = td->td_md.md_saved_flags; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - intr_restore(td->td_md.md_saved_flags); + intr_restore(flags); } #if defined(I586_CPU) && !defined(NO_F00F_HACK) Modified: stable/7/sys/powerpc/powerpc/machdep.c ============================================================================== --- stable/7/sys/powerpc/powerpc/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/powerpc/powerpc/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -942,11 +942,15 @@ void spinlock_enter(void) { struct thread *td; + register_t msr; td = curthread; - if (td->td_md.md_spinlock_count == 0) - td->td_md.md_saved_msr = intr_disable(); - td->td_md.md_spinlock_count++; + if (td->td_md.md_spinlock_count == 0) { + msr = intr_disable(); + td->td_md.md_spinlock_count = 1; + td->td_md.md_saved_msr = msr; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -954,12 +958,14 @@ void spinlock_exit(void) { struct thread *td; + register_t msr; td = curthread; critical_exit(); + msr = td->td_md.md_saved_msr; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - intr_restore(td->td_md.md_saved_msr); + intr_restore(msr); } /* Modified: stable/7/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/sparc64/sparc64/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -222,9 +222,10 @@ spinlock_enter(void) if (td->td_md.md_spinlock_count == 0) { pil = rdpr(pil); wrpr(pil, 0, PIL_TICK); + td->td_md.md_spinlock_count = 1; td->td_md.md_saved_pil = pil; - } - td->td_md.md_spinlock_count++; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -232,12 +233,14 @@ void spinlock_exit(void) { struct thread *td; + register_t pil; td = curthread; critical_exit(); + pil = td->td_md.md_saved_pil; td->td_md.md_spinlock_count--; if (td->td_md.md_spinlock_count == 0) - wrpr(pil, td->td_md.md_saved_pil, 0); + wrpr(pil, pil, 0); } static phandle_t Modified: stable/7/sys/sun4v/sun4v/machdep.c ============================================================================== --- stable/7/sys/sun4v/sun4v/machdep.c Tue Jan 25 22:08:22 2011 (r217855) +++ stable/7/sys/sun4v/sun4v/machdep.c Tue Jan 25 22:08:43 2011 (r217856) @@ -267,9 +267,10 @@ spinlock_enter(void) td = curthread; if (td->td_md.md_spinlock_count == 0) { pil = intr_disable(); + td->td_md.md_spinlock_count = 1; td->td_md.md_saved_pil = pil; - } - td->td_md.md_spinlock_count++; + } else + td->td_md.md_spinlock_count++; critical_enter(); } @@ -277,14 +278,14 @@ void spinlock_exit(void) { struct thread *td; + register_t pil; td = curthread; critical_exit(); + pil = td->td_md.md_saved_pil; td->td_md.md_spinlock_count--; - if (td->td_md.md_spinlock_count == 0) { - intr_restore(td->td_md.md_saved_pil); - } - + if (td->td_md.md_spinlock_count == 0) + intr_restore(pil); } unsigned
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101252208.p0PM8hN7052738>