mirror of https://github.com/golang/go.git
runtime: add a alignment check
The Linux implementation requires that the address addr be
page-aligned, and allows length to be zero.
See Linux notes:
https://man7.org/linux/man-pages/man2/madvise.2.html
Change-Id: Ic49960c32991ef12f23de2de76e9689567c82d03
GitHub-Last-Rev: 35e7f8e5cc
GitHub-Pull-Request: golang/go#59793
Reviewed-on: https://go-review.googlesource.com/c/go/+/488015
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
3c59639b90
commit
ada0eec827
|
|
@ -92,6 +92,11 @@ func sysHugePageOS(v unsafe.Pointer, n uintptr) {
|
|||
}
|
||||
|
||||
func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
|
||||
if uintptr(v)&(physPageSize-1) != 0 {
|
||||
// The Linux implementation requires that the address
|
||||
// addr be page-aligned, and allows length to be zero.
|
||||
throw("unaligned sysNoHugePageOS")
|
||||
}
|
||||
madvise(v, n, _MADV_NOHUGEPAGE)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue