gvisorgvisor.dev/gvisor/pkg/sentry/hostmm Index | Files

package hostmm

import "gvisor.dev/gvisor/pkg/sentry/hostmm"

Package hostmm provides tools for interacting with the host Linux kernel's virtual memory management subsystem.

Index

Functions

func GetTransparentHugepageEnum

func GetTransparentHugepageEnum(data string) (string, error)

GetTransparentHugepageEnum returns the currently selected option given the contents of any of /sys/kernel/mm/transparent_hugepage/{enabled,shmem_enabled,defrag}.

func GlobalMemoryBarrier

func GlobalMemoryBarrier() error

GlobalMemoryBarrier blocks until "all running threads [in the host OS] have passed through a state where all memory accesses to user-space addresses match program order between entry to and return from GlobalMemoryBarrier", as for membarrier(2).

Preconditions: HaveGlobalMemoryBarrier() == true.

func HaveGlobalMemoryBarrier

func HaveGlobalMemoryBarrier() bool

HaveGlobalMemoryBarrier returns true if GlobalMemoryBarrier is supported.

func HaveProcessMemoryBarrier

func HaveProcessMemoryBarrier() bool

HaveProcessMemoryBarrier returns true if ProcessMemoryBarrier is supported.

func NotifyCurrentMemcgPressureCallback

func NotifyCurrentMemcgPressureCallback(f func(), level string) (func(), error)

NotifyCurrentMemcgPressureCallback requests that f is called whenever the calling process' memory cgroup indicates memory pressure of the given level, as specified by Linux's Documentation/cgroup-v1/memory.txt.

If NotifyCurrentMemcgPressureCallback succeeds, it returns a function that terminates the requested memory pressure notifications. This function may be called at most once.

func ProcessMemoryBarrier

func ProcessMemoryBarrier() error

ProcessMemoryBarrier is equivalent to GlobalMemoryBarrier, but only synchronizes with threads sharing a virtual address space (from the host OS' perspective) with the calling thread.

Preconditions: HaveProcessMemoryBarrier() == true.

func ReadTransparentHugepageEnum

func ReadTransparentHugepageEnum(filename string) (string, error)

ReadTransparentHugepageEnum returns the currently selected option for whichever of /sys/kernel/mm/transparent_hugepage/{enabled,shmem_enabled,defrag} is specified by filename. (Only the basename is required, not the full path.)

Source Files

cgroup.go hostmm.go membarrier.go

Version
v0.0.0-20250605235530-a6711d1e1dc6 (latest)
Published
Jun 5, 2025
Platform
linux/amd64
Imports
10 packages
Last checked
4 hours ago

Tools for package owners.