Use memutil.MapFile for the memory accounting page.
PiperOrigin-RevId: 381145216
This commit is contained in:
parent
dfa4b3b908
commit
7e0c1d9f1e
|
@ -107,7 +107,7 @@ analyzers:
|
|||
- pkg/sentry/socket/unix/transport/connectioned.go # unsupported usage.
|
||||
- pkg/sentry/vfs/dentry.go # unsupported usage.
|
||||
- pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go # unsupported usage.
|
||||
- pkg/tcpip/stack/conntrack.go # unsupported usage.
|
||||
- pkg/tcpip/stack/conntrack.go # unsupported usage.
|
||||
- pkg/tcpip/transport/packet/endpoint_state.go # unsupported usage.
|
||||
- pkg/tcpip/transport/raw/endpoint_state.go # unsupported usage.
|
||||
- pkg/tcpip/transport/icmp/endpoint.go # unsupported usage.
|
||||
|
@ -177,6 +177,7 @@ analyzers:
|
|||
- pkg/sentry/platform/kvm/bluepill_unsafe.go # Special case.
|
||||
- pkg/sentry/platform/kvm/machine_unsafe.go # Special case.
|
||||
- pkg/sentry/platform/safecopy/safecopy_unsafe.go # Special case.
|
||||
- pkg/sentry/usage/memory_unsafe.go # Special case.
|
||||
- pkg/sentry/vfs/mount_unsafe.go # Special case.
|
||||
- pkg/state/decode_unsafe.go # Special case.
|
||||
unusedresult:
|
||||
|
|
|
@ -132,7 +132,7 @@ func Init() error {
|
|||
// always be the case for a newly mapped page from /dev/shm. If we obtain
|
||||
// the shared memory through some other means in the future, we may have to
|
||||
// explicitly zero the page.
|
||||
mmap, err := unix.Mmap(int(file.Fd()), 0, int(RTMemoryStatsSize), unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED)
|
||||
mmap, err := memutil.MapFile(0, RTMemoryStatsSize, unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED, file.Fd(), 0)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error mapping usage file: %v", err)
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
// RTMemoryStatsSize is the size of the RTMemoryStats struct.
|
||||
var RTMemoryStatsSize = unsafe.Sizeof(RTMemoryStats{})
|
||||
|
||||
// RTMemoryStatsPointer casts the address of the byte slice into a RTMemoryStats pointer.
|
||||
func RTMemoryStatsPointer(b []byte) *RTMemoryStats {
|
||||
return (*RTMemoryStats)(unsafe.Pointer(&b[0]))
|
||||
// RTMemoryStatsPointer casts addr to a RTMemoryStats pointer.
|
||||
func RTMemoryStatsPointer(addr uintptr) *RTMemoryStats {
|
||||
return (*RTMemoryStats)(unsafe.Pointer(addr))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue