diff options
author | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2022-06-10 21:34:16 +0000 |
---|---|---|
committer | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2022-06-10 21:34:16 +0000 |
commit | fdd6249c94a9ecbccbbdbf3c3e154ddfb72c82e4 (patch) | |
tree | 4056a6f43ff81c4e74281a12db58bc897d9456d4 /sys/arch | |
parent | 19d9c0ee5ab673d73f3c05cc5981da2ec3e24bb4 (diff) |
Implement CPU_BUSY_CYCLE() with the ZiHintPause extension
This may help save power but also improves performance in contended
workloads.
kettenis@ helped a lot:
- pointing out the error in my newest diff
- pointing out that the ZiHintPause had been ratified in early 2021
- testing this on his visionfive board
ok kettenis@
libc make -j4 time before
17m39.06s real 22m13.85s user 34m27.88s system
17m35.60s real 22m15.01s user 34m28.51s system
17m40.78s real 22m14.89s user 34m42.91s system
17m40.61s real 22m06.99s user 34m29.58s system
17m42.79s real 22m08.04s user 34m33.19s system
17m39.21s real 22m11.27s user 34m23.18s system
17m32.81s real 22m13.84s user 34m09.67s system
libc make -j4 time after
16m35.48s real 21m57.94s user 32m05.50s system
16m49.10s real 21m58.47s user 32m42.37s system
16m42.16s real 22m00.51s user 32m22.18s system
16m41.54s real 21m53.32s user 32m19.53s system
16m45.42s real 21m52.14s user 32m37.78s system
16m46.55s real 21m58.98s user 32m36.70s system
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/riscv64/include/cpu.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/arch/riscv64/include/cpu.h b/sys/arch/riscv64/include/cpu.h index 20da2ccf689..4c32f35fdff 100644 --- a/sys/arch/riscv64/include/cpu.h +++ b/sys/arch/riscv64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.11 2022/01/01 14:18:39 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.12 2022/06/10 21:34:15 jca Exp $ */ /* * Copyright (c) 2019 Mike Larkin <mlarkin@openbsd.org> @@ -175,7 +175,8 @@ void cpu_startclock(void); #endif /* !MULTIPROCESSOR */ -#define CPU_BUSY_CYCLE() do {} while (0) +/* Zihintpause ratified extension */ +#define CPU_BUSY_CYCLE() __asm volatile(".long 0x0100000f" ::: "memory") #define curpcb curcpu()->ci_curpcb |