hostmm

package
v0.0.0-...-607ea00 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: Apache-2.0, BSD-3-Clause, MIT Imports: 10 Imported by: 6

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

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 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 Probe

func Probe(probePrivateExpedited bool) <-chan HostMemBarrier

Probe asynchronously determines host `membarrier(2)` support and, if `probePrivateExpedited` is true and the host supports it, registers for MEMBARRIER_CMD_PRIVATE_EXPEDITED. Returns a channel on which the resulting HostMemBarrier is sent back. This is meant to be used in Platform implementation constructors, which mus run before seccomp filters installation. Runs in the background to allow further platform initialization to proceed while we determine this, which can take tens of milliseconds.

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.)

Types

type HostMemBarrier

type HostMemBarrier struct {
	// contains filtered or unexported fields
}

HostMemBarrier provides access to the host membarrier(2) operations that the calling process has been verified to support. It is obtained from Probe.

func (HostMemBarrier) GlobalMemoryBarrier

func (h HostMemBarrier) 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 (HostMemBarrier) HaveGlobalMemoryBarrier

func (h HostMemBarrier) HaveGlobalMemoryBarrier() bool

HaveGlobalMemoryBarrier returns true if GlobalMemoryBarrier is supported.

func (HostMemBarrier) HaveProcessMemoryBarrier

func (h HostMemBarrier) HaveProcessMemoryBarrier() bool

HaveProcessMemoryBarrier returns true if ProcessMemoryBarrier is supported and registration succeeded.

func (HostMemBarrier) ProcessMemoryBarrier

func (h HostMemBarrier) 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL