summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorMasao Uebayashi <uebayasi@cvs.openbsd.org>2014-07-11 10:53:08 +0000
committerMasao Uebayashi <uebayasi@cvs.openbsd.org>2014-07-11 10:53:08 +0000
commit123f4b6634c6f64980c8a879dc8140fcc706d6d2 (patch)
tree8f16526685cec43a88ad22499b7316fe46507593 /sys/arch/i386
parent7153f32429c8f459cac9dbed87a626718d2b84b9 (diff)
CPU_BUSY_CYCLE(): A new MI statement for busy loop power reduction
The new CPU_BUSY_CYCLE() may be put in a busy loop body so that CPU can reduce power consumption, as Linux's cpu_relax() and FreeBSD's cpu_spinwait(). To start minimally, use PAUSE on i386/amd64 and empty on others. The name is chosen following the existing cpu_idle_*() functions. Naming and API may be polished later. OK kettenis@
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/include/cpu.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h
index fec9ff29642..91b558a2934 100644
--- a/sys/arch/i386/include/cpu.h
+++ b/sys/arch/i386/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.133 2014/03/29 18:09:29 guenther Exp $ */
+/* $OpenBSD: cpu.h,v 1.134 2014/07/11 10:53:07 uebayasi Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
@@ -225,6 +225,8 @@ extern void cpu_init_idle_pcbs(void);
void cpu_kick(struct cpu_info *);
void cpu_unidle(struct cpu_info *);
+#define CPU_BUSY_CYCLE() __asm volatile("pause": : : "memory")
+
#else /* MULTIPROCESSOR */
#define MAXCPUS 1
@@ -237,6 +239,8 @@ void cpu_unidle(struct cpu_info *);
#define cpu_kick(ci)
#define cpu_unidle(ci)
+#define CPU_BUSY_CYCLE() do {} while (0)
+
#endif
#define aston(p) ((p)->p_md.md_astpending = 1)