From f5afa0f9fb1866b874e1822c84ccdfd45a44980a Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Thu, 23 Jan 2020 14:11:02 +0000 Subject: [PATCH] Apply r355819 to sparc64 - fix assertion failure after r355784 From r355819: Repeat the spinlock_enter/exit pattern from amd64 on other architectures to fix an assert violation introduced in r355784. Without this spinlock_exit() may see owepreempt and switch before reducing the spinlock count. amd64 had been optimized to do a single critical enter/exit regardless of the number of spinlocks which avoided the problem and this optimization had not been applied elsewhere. This is completely untested - I have no obsolete Sparc hardware - but someone did try testing recent changes on sparc64 (PR 243534). PR: 243534 --- sys/sparc64/sparc64/machdep.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c index e0f6313c294..28ddd42f72c 100644 --- a/sys/sparc64/sparc64/machdep.c +++ b/sys/sparc64/sparc64/machdep.c @@ -224,9 +224,9 @@ spinlock_enter(void) wrpr(pil, 0, PIL_TICK); td->td_md.md_spinlock_count = 1; td->td_md.md_saved_pil = pil; + critical_enter(); } else td->td_md.md_spinlock_count++; - critical_enter(); } void @@ -236,11 +236,12 @@ spinlock_exit(void) 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) + if (td->td_md.md_spinlock_count == 0) { + critical_exit(); wrpr(pil, pil, 0); + } } static phandle_t