From 9b2ceb0ad86c83a35a46a13363ce85ee430a3092 Mon Sep 17 00:00:00 2001 From: ad Date: Sat, 7 Dec 2019 21:14:36 +0000 Subject: [PATCH] mi_switch: move an over eager KASSERT defeated by kernel preemption. Discovered during automated test. --- sys/kern/kern_synch.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 1a95aa7b4489..229a9c145daf 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_synch.c,v 1.330 2019/12/07 17:36:33 ad Exp $ */ +/* $NetBSD: kern_synch.c,v 1.331 2019/12/07 21:14:36 ad Exp $ */ /*- * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009, 2019 @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.330 2019/12/07 17:36:33 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.331 2019/12/07 21:14:36 ad Exp $"); #include "opt_kstack.h" #include "opt_dtrace.h" @@ -753,6 +753,7 @@ mi_switch(lwp_t *l) * Note that, unless the caller disabled preemption, we can * be preempted at any time after this splx(). */ + KASSERT(l->l_cpu == ci); splx(oldspl); } else { /* Nothing to do - just unlock and return. */ @@ -763,9 +764,7 @@ mi_switch(lwp_t *l) lwp_unlock(l); } - /* Only now is it safe to consider l_cpu again. */ KASSERT(l == curlwp); - KASSERT(l->l_cpu == ci); KASSERT(l->l_stat == LSONPROC); SYSCALL_TIME_WAKEUP(l);