From b43d7c278ce9b35401a121323bd85088ec5b9443 Mon Sep 17 00:00:00 2001 From: jca Date: Sun, 9 Jun 2024 21:15:29 +0000 Subject: [PATCH] Add a compiler barrier where missing in CPU_BUSY_CYCLE() implems Having differences between architectures is asking for problems. And adding a barrier here just makes sense in most cases. This is also what cpu_relax() provides in Linux land. ok kettenis@ claudio@ --- sys/arch/alpha/include/cpu.h | 6 ++++-- sys/arch/amd64/include/cpu.h | 4 ++-- sys/arch/arm/include/cpu.h | 4 ++-- sys/arch/hppa/include/cpu.h | 4 ++-- sys/arch/i386/include/cpu.h | 4 ++-- sys/arch/m88k/include/cpu.h | 4 ++-- sys/arch/mips64/include/cpu.h | 4 ++-- sys/arch/powerpc64/include/cpu.h | 4 ++-- sys/arch/sh/include/cpu.h | 4 ++-- 9 files changed, 20 insertions(+), 18 deletions(-) diff --git a/sys/arch/alpha/include/cpu.h b/sys/arch/alpha/include/cpu.h index f91536fe066..04997fd8272 100644 --- a/sys/arch/alpha/include/cpu.h +++ b/sys/arch/alpha/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.74 2024/05/21 23:16:06 jsg Exp $ */ +/* $OpenBSD: cpu.h,v 1.75 2024/06/09 21:15:29 jca Exp $ */ /* $NetBSD: cpu.h,v 1.45 2000/08/21 02:03:12 thorpej Exp $ */ /*- @@ -264,6 +264,8 @@ do { \ struct cpu_info *__ci = curcpu(); \ int __s; \ \ + __asm volatile ("" ::: "memory"); \ + \ if (__ci->ci_ipis != 0) { \ __s = splipi(); \ alpha_ipi_process_with_frame(__ci); \ @@ -277,7 +279,7 @@ do { \ #define CPU_IS_PRIMARY(ci) 1 #define CPU_IS_RUNNING(ci) 1 #define cpu_unidle(ci) do { /* nothing */ } while (0) -#define CPU_BUSY_CYCLE() do {} while (0) +#define CPU_BUSY_CYCLE() __asm volatile ("" ::: "memory") #endif /* MULTIPROCESSOR */ diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h index 90f5dd9e905..82d3552c43e 100644 --- a/sys/arch/amd64/include/cpu.h +++ b/sys/arch/amd64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.172 2024/06/07 16:53:35 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.173 2024/06/09 21:15:29 jca Exp $ */ /* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */ /*- @@ -319,7 +319,7 @@ void cpu_unidle(struct cpu_info *); #define cpu_kick(ci) #define cpu_unidle(ci) -#define CPU_BUSY_CYCLE() do {} while (0) +#define CPU_BUSY_CYCLE() __asm volatile ("" ::: "memory") #endif diff --git a/sys/arch/arm/include/cpu.h b/sys/arch/arm/include/cpu.h index 1b973d3f569..a598a46bca1 100644 --- a/sys/arch/arm/include/cpu.h +++ b/sys/arch/arm/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.66 2024/02/25 19:15:50 cheloha Exp $ */ +/* $OpenBSD: cpu.h,v 1.67 2024/06/09 21:15:29 jca Exp $ */ /* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */ /* @@ -251,7 +251,7 @@ extern struct cpu_info *cpu_info[MAXCPUS]; void cpu_boot_secondary_processors(void); #endif /* !MULTIPROCESSOR */ -#define CPU_BUSY_CYCLE() do {} while (0) +#define CPU_BUSY_CYCLE() __asm volatile ("" ::: "memory") #define curpcb curcpu()->ci_curpcb diff --git a/sys/arch/hppa/include/cpu.h b/sys/arch/hppa/include/cpu.h index 47abd9cfd4f..e2ff730c9d4 100644 --- a/sys/arch/hppa/include/cpu.h +++ b/sys/arch/hppa/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.104 2024/02/25 19:15:50 cheloha Exp $ */ +/* $OpenBSD: cpu.h,v 1.105 2024/06/09 21:15:29 jca Exp $ */ /* * Copyright (c) 2000-2004 Michael Shalayeff @@ -165,7 +165,7 @@ curcpu(void) #define CPU_INFO_FOREACH(cii, ci) \ for (cii = 0, ci = &cpu_info[0]; cii < ncpus; cii++, ci++) -#define CPU_BUSY_CYCLE() do {} while (0) +#define CPU_BUSY_CYCLE() __asm volatile ("" ::: "memory") /* types */ enum hppa_cpu_type { diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 565f6159c74..d9b5cb50bc9 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.190 2024/06/07 16:53:35 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.191 2024/06/09 21:15:29 jca Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -262,7 +262,7 @@ void cpu_unidle(struct cpu_info *); #define cpu_kick(ci) #define cpu_unidle(ci) -#define CPU_BUSY_CYCLE() do {} while (0) +#define CPU_BUSY_CYCLE() __asm volatile ("" ::: "memory") #endif diff --git a/sys/arch/m88k/include/cpu.h b/sys/arch/m88k/include/cpu.h index d5ce5dff711..4dbb4d9786d 100644 --- a/sys/arch/m88k/include/cpu.h +++ b/sys/arch/m88k/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.78 2024/05/28 09:27:54 claudio Exp $ */ +/* $OpenBSD: cpu.h,v 1.79 2024/06/09 21:15:29 jca Exp $ */ /* * Copyright (c) 1996 Nivas Madhur * Copyright (c) 1992, 1993 @@ -221,7 +221,7 @@ void m88k_broadcast_ipi(int); #endif /* MULTIPROCESSOR */ -#define CPU_BUSY_CYCLE() do {} while (0) +#define CPU_BUSY_CYCLE() __asm volatile ("" ::: "memory") struct cpu_info *set_cpu_number(cpuid_t); diff --git a/sys/arch/mips64/include/cpu.h b/sys/arch/mips64/include/cpu.h index dccd1157ab4..6578a1bad4d 100644 --- a/sys/arch/mips64/include/cpu.h +++ b/sys/arch/mips64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.146 2024/02/25 19:15:50 cheloha Exp $ */ +/* $OpenBSD: cpu.h,v 1.147 2024/06/09 21:15:29 jca Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -258,7 +258,7 @@ void smp_rendezvous_cpus(unsigned long, void (*)(void *), void *arg); #define get_cpu_info(i) (&cpu_info_primary) #endif -#define CPU_BUSY_CYCLE() do {} while (0) +#define CPU_BUSY_CYCLE() __asm volatile ("" ::: "memory") extern void (*md_initclock)(void); extern void (*md_startclock)(struct cpu_info *); diff --git a/sys/arch/powerpc64/include/cpu.h b/sys/arch/powerpc64/include/cpu.h index 13c67b80628..fe0394f457b 100644 --- a/sys/arch/powerpc64/include/cpu.h +++ b/sys/arch/powerpc64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.36 2024/02/25 19:15:50 cheloha Exp $ */ +/* $OpenBSD: cpu.h,v 1.37 2024/06/09 21:15:29 jca Exp $ */ /* * Copyright (c) 2020 Mark Kettenis @@ -170,7 +170,7 @@ void mp_setperf(int); void signotify(struct proc *); -#define CPU_BUSY_CYCLE() do {} while (0) +#define CPU_BUSY_CYCLE() __asm volatile ("" ::: "memory") #define curpcb curcpu()->ci_curpcb diff --git a/sys/arch/sh/include/cpu.h b/sys/arch/sh/include/cpu.h index eeae150d812..e1bb2283c64 100644 --- a/sys/arch/sh/include/cpu.h +++ b/sys/arch/sh/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.38 2024/03/31 07:23:29 miod Exp $ */ +/* $OpenBSD: cpu.h,v 1.39 2024/06/09 21:15:29 jca Exp $ */ /* $NetBSD: cpu.h,v 1.41 2006/01/21 04:24:12 uwe Exp $ */ /*- @@ -90,7 +90,7 @@ extern struct cpu_info cpu_info_store; #define MAXCPUS 1 #define cpu_unidle(ci) -#define CPU_BUSY_CYCLE() do {} while (0) +#define CPU_BUSY_CYCLE() __asm volatile ("" ::: "memory") /* -- 2.20.1