From: kettenis Date: Thu, 16 May 2024 09:30:03 +0000 (+0000) Subject: Stop treating IPL_NONE mutexes special in MULTIPROCESSOR kernels. While X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=52ac02e4d7f3dc6035fb429a557276c9f267439a;p=openbsd Stop treating IPL_NONE mutexes special in MULTIPROCESSOR kernels. While in theory these are safe to use in code that runs under the kernel lock they are nasty trips when converting code to run without the kernel lock. ok mpi@, claudio@ --- diff --git a/sys/arch/hppa/include/mutex.h b/sys/arch/hppa/include/mutex.h index 0aa8d1b3230..a7277931964 100644 --- a/sys/arch/hppa/include/mutex.h +++ b/sys/arch/hppa/include/mutex.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.h,v 1.9 2018/01/13 15:18:11 mpi Exp $ */ +/* $OpenBSD: mutex.h,v 1.10 2024/05/16 09:30:03 kettenis Exp $ */ /* * Copyright (c) 2004 Artur Grabowski @@ -45,16 +45,7 @@ struct mutex { #endif }; -/* - * To prevent lock ordering problems with the kernel lock, we need to - * make sure we block all interrupts that can grab the kernel lock. - * The simplest way to achieve this is to make sure mutexes always - * raise the interrupt priority level to the highest level that has - * interrupts that grab the kernel lock. - */ #ifdef MULTIPROCESSOR -#define __MUTEX_IPL(ipl) \ - (((ipl) > IPL_NONE && (ipl) < IPL_MPFLOOR) ? IPL_MPFLOOR : (ipl)) #ifdef WITNESS #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ { MUTEX_UNLOCKED, __MUTEX_IPL((ipl)), 0, NULL, \ @@ -64,7 +55,6 @@ struct mutex { { MUTEX_UNLOCKED, __MUTEX_IPL((ipl)), 0, NULL } #endif /* WITNESS */ #else /* MULTIPROCESSOR */ -#define __MUTEX_IPL(ipl) (ipl) #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ { __MUTEX_IPL((ipl)), 0, NULL } #endif /* MULTIPROCESSOR */ diff --git a/sys/arch/m88k/include/mutex.h b/sys/arch/m88k/include/mutex.h index 5752a427f42..61b1f0dd826 100644 --- a/sys/arch/m88k/include/mutex.h +++ b/sys/arch/m88k/include/mutex.h @@ -1,6 +1,4 @@ -#ifndef _M88K_MUTEX_H_ -#define _M88K_MUTEX_H_ -/* $OpenBSD: mutex.h,v 1.8 2020/05/26 11:55:10 aoyama Exp $ */ +/* $OpenBSD: mutex.h,v 1.9 2024/05/16 09:30:03 kettenis Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat. @@ -27,6 +25,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifndef _M88K_MUTEX_H_ +#define _M88K_MUTEX_H_ + #include struct mutex { @@ -39,20 +40,6 @@ struct mutex { #endif }; -/* - * To prevent lock ordering problems with the kernel lock, we need to - * make sure we block all interrupts that can grab the kernel lock. - * The simplest way to achieve this is to make sure mutexes always - * raise the interrupt priority level to the highest level that has - * interrupts that grab the kernel lock. - */ -#ifdef MULTIPROCESSOR -#define __MUTEX_IPL(ipl) \ - (((ipl) > IPL_NONE && (ipl) < IPL_MPFLOOR) ? IPL_MPFLOOR : (ipl)) -#else -#define __MUTEX_IPL(ipl) (ipl) -#endif - #ifdef WITNESS #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ { 0, __MUTEX_IPL((ipl)), IPL_NONE, NULL, \ diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index cff33404c3c..960299fa941 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.h,v 1.21 2024/03/26 18:18:30 bluhm Exp $ */ +/* $OpenBSD: mutex.h,v 1.22 2024/05/16 09:30:03 kettenis Exp $ */ /* * Copyright (c) 2004 Artur Grabowski @@ -33,6 +33,20 @@ * "mtx_enter(foo); mtx_enter(bar); mtx_leave(foo); mtx_leave(bar);" */ +/* + * To prevent lock ordering problems with the kernel lock, we need to + * make sure we block all interrupts that can grab the kernel lock. + * The simplest way to achieve this is to make sure mutexes always + * raise the interrupt priority level to the highest level that has + * interrupts that grab the kernel lock. + */ +#ifdef MULTIPROCESSOR +#define __MUTEX_IPL(ipl) \ + (((ipl) < IPL_MPFLOOR) ? IPL_MPFLOOR : (ipl)) +#else +#define __MUTEX_IPL(ipl) (ipl) +#endif + #include #ifdef __USE_MI_MUTEX @@ -48,20 +62,6 @@ struct mutex { #endif }; -/* - * To prevent lock ordering problems with the kernel lock, we need to - * make sure we block all interrupts that can grab the kernel lock. - * The simplest way to achieve this is to make sure mutexes always - * raise the interrupt priority level to the highest level that has - * interrupts that grab the kernel lock. - */ -#ifdef MULTIPROCESSOR -#define __MUTEX_IPL(ipl) \ - (((ipl) > IPL_NONE && (ipl) < IPL_MPFLOOR) ? IPL_MPFLOOR : (ipl)) -#else -#define __MUTEX_IPL(ipl) (ipl) -#endif - #ifdef WITNESS #define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ { NULL, __MUTEX_IPL((ipl)), IPL_NONE, MTX_LO_INITIALIZER(name, flags) }