Skip to content

Commit 20c2bfd

Browse files
PureWhiteWurandall77
authored andcommitted
cpu: fix cpu cacheLineSize for arm64 darwin(a.k.a. M1)
The existing value for M1 is 64, which is the same as other arm64 cpus. But the correct cacheLineSize for M1 should be 128, which can be verified using the following command: $ sysctl -a hw | grep cachelinesize hw.cachelinesize: 128 Fixes golang/go#53075 Change-Id: I555716ed412cdc02941c8b1d9767952f7ad6678c Reviewed-on: https://go-review.googlesource.com/c/sys/+/408614 Run-TryBot: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Joedian Reid <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 2296e01 commit 20c2bfd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cpu/cpu_arm64.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ package cpu
66

77
import "runtime"
88

9-
const cacheLineSize = 64
9+
// cacheLineSize is used to prevent false sharing of cache lines.
10+
// We choose 128 because Apple Silicon, a.k.a. M1, has 128-byte cache line size.
11+
// It doesn't cost much and is much more future-proof.
12+
const cacheLineSize = 128
1013

1114
func initOptions() {
1215
options = []option{

0 commit comments

Comments
 (0)