Movatterモバイル変換


[0]ホーム

URL:


cgroup

packagestandard library
go1.25.2Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License:BSD-3-ClauseImports:4Imported by:0

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Index

Constants

View Source
const (// Required amount of scratch space for CPULimit.//// TODO(prattmic): This is shockingly large (~70KiB) due to the (very// unlikely) combination of extremely long paths consisting mostly// escaped characters. The scratch buffer ends up in .bss in package// runtime, so it doesn't contribute to binary size and generally won't// be faulted in, but it would still be nice to shrink this. A more// complex parser that did not need to keep entire lines in memory// could get away with much less. Alternatively, we could do a one-off// mmap allocation for this buffer, which is only mapped larger if we// actually need the extra space.ScratchSize =PathSize +ParseSize// Required space to store a path of the cgroup in the filesystem.PathSize = _PATH_MAX// Required space to parse /proc/self/mountinfo and /proc/self/cgroup.// See findCPUMount and findCPURelativePath.ParseSize = 4 * escapedPathMax)

Variables

View Source
var (ErrNoCgrouperror = stringError("not in a cgroup"))

Functions

funcFindCPUMountPoint

func FindCPUMountPoint(out []byte, scratch []byte) (int,error)

FindCPUMountPoint finds the root of the CPU cgroup mount places it in out.scratch is a scratch buffer for internal use.

out must have length PathSize. scratch must have length ParseSize.

Returns the number of bytes written to out.

Returns ErrNoCgroup if the process is not in a CPU cgroup.

funcReadCPULimit

func ReadCPULimit(cCPU) (float64,bool,error)

Returns average CPU throughput limit from the cgroup, or ok false if thereis no limit.

Types

typeCPU

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

CPU owns the FDs required to read the CPU limit from a cgroup.

funcOpenCPU

func OpenCPU(scratch []byte) (CPU,error)

OpenCPU returns a CPU for the CPU cgroup containing the current process, orErrNoCgroup if the process is not in a CPU cgroup.

scratch must have length ScratchSize.

func (CPU)Close

func (cCPU) Close()

typeVersion

type Versionint

Version indicates the cgroup version.

const (VersionUnknownVersion =iotaV1V2)

funcFindCPU

func FindCPU(out []byte, scratch []byte) (int,Version,error)

FindCPU finds the path to the CPU cgroup that this process is a member ofand places it in out. scratch is a scratch buffer for internal use.

out must have length PathSize. scratch must have length ParseSize.

Returns the number of bytes written to out and the cgroup version (1 or 2).

Returns ErrNoCgroup if the process is not in a CPU cgroup.

funcFindCPURelativePath

func FindCPURelativePath(out []byte, scratch []byte) (int,Version,error)

FindCPURelativePath finds the path to the CPU cgroup that this process is a member ofrelative to the root of the cgroup mount and places it in out. scratch is ascratch buffer for internal use.

out must have length PathSize minus the size of the cgroup mount root (ifknown). scratch must have length ParseSize.

Returns the number of bytes written to out and the cgroup version (1 or 2).

Returns ErrNoCgroup if the process is not in a CPU cgroup.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp