mirror of
https://github.com/golang/go
synced 2024-11-16 23:04:44 -07:00
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
This commit is contained in:
parent
6bbbc5dc70
commit
35e7f8e5cc
@ -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
Block a user