Skip to content

Commit

Permalink
cpu: fix cpu cacheLineSize for arm64 darwin(a.k.a. M1)
Browse files Browse the repository at this point in the history
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 <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
  • Loading branch information
PureWhiteWu authored and randall77 committed Aug 23, 2022
1 parent 2296e01 commit 20c2bfd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cpu/cpu_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ package cpu

import "runtime"

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

func initOptions() {
options = []option{
Expand Down

0 comments on commit 20c2bfd

Please sign in to comment.