cgroupfs

package
v0.0.0-...-989fa2c Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0, MIT Imports: 25 Imported by: 0

Documentation

Overview

Package cgroupfs implements cgroupfs.

A cgroup is a collection of tasks on the system, organized into a tree-like structure similar to a filesystem directory tree. In fact, each cgroup is represented by a directory on cgroupfs, and is manipulated through control files in the directory.

All cgroups on a system are organized into hierarchies. Hierarchies are a distinct tree of cgroups, with a common set of controllers. One or more cgroupfs mounts may point to each hierarchy. These mounts provide a common view into the same tree of cgroups.

A controller (also known as a "resource controller", or a cgroup "subsystem") determines the behaviour of each cgroup.

In addition to cgroupfs, the kernel has a cgroup registry that tracks system-wide state related to cgroups such as active hierarchies and the controllers associated with them.

Since cgroupfs doesn't allow hardlinks, there is a unique mapping between cgroupfs dentries and inodes. Thus, cgroupfs inodes don't need to be ref counted and exist until they're unlinked once or the FS is destroyed.

Synchronization

Cgroup hierarchy creation and destruction is protected by the kernel.CgroupRegistry.mu. Once created, a hierarchy's set of controllers, the filesystem associated with it, and the root cgroup for the hierarchy are immutable.

Membership of tasks within cgroups is protected by cgroupfs.filesystem.tasksMu. Tasks also maintain a set of all cgroups they're in, and this list is protected by Task.mu.

Lock order:

kernel.CgroupRegistry.mu
	kernfs.filesystem.mu
	kernel.TaskSet.mu
  	kernel.Task.mu
    	cgroupfs.filesystem.tasksMu.
      	cgroupfs.dir.OrderedChildren.mu

Index

Constants

View Source
const (
	// Name is the default filesystem name.
	Name = "cgroup"
)

Variables

View Source
var SupportedMountOptions = []string{"all", "cpu", "cpuacct", "cpuset", "job", "memory", "pids"}

SupportedMountOptions is the set of supported mount options for cgroupfs.

Functions

This section is empty.

Types

type FilesystemType

type FilesystemType struct{}

FilesystemType implements vfs.FilesystemType.

+stateify savable

func (FilesystemType) GetFilesystem

func (fsType FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.VirtualFilesystem, creds *auth.Credentials, source string, opts vfs.GetFilesystemOptions) (*vfs.Filesystem, *vfs.Dentry, error)

GetFilesystem implements vfs.FilesystemType.GetFilesystem.

func (FilesystemType) Name

func (FilesystemType) Name() string

Name implements vfs.FilesystemType.Name.

func (FilesystemType) Release

func (FilesystemType) Release(ctx context.Context)

Release implements vfs.FilesystemType.Release.

func (*FilesystemType) StateFields

func (fsType *FilesystemType) StateFields() []string

func (*FilesystemType) StateLoad

func (fsType *FilesystemType) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*FilesystemType) StateSave

func (fsType *FilesystemType) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*FilesystemType) StateTypeName

func (fsType *FilesystemType) StateTypeName() string

type InitialCgroup

type InitialCgroup struct {
	// Path is an absolute path relative to the root of a cgroupfs filesystem
	// that indicates where to place the init task. An empty string indicates
	// the root of the filesystem.
	Path string

	// SetOwner indicates the UID and GID fields contain valid values. If true,
	// Both UID and GID must be provided.
	SetOwner bool
	// UID of the initial cgroup path components, excluding the root cgroup.
	UID auth.KUID
	// GID of the initial cgroup path components, excluding the root cgroup.
	GID auth.KGID

	// SetMode indicates the Mode field contains a valid value.
	SetMode bool
	// Mode of the initial cgroup path components, excluding the root cgroup.
	Mode linux.FileMode
}

InitialCgroup specifies properties of the cgroup for the init task.

+stateify savable

func (*InitialCgroup) StateFields

func (i *InitialCgroup) StateFields() []string

func (*InitialCgroup) StateLoad

func (i *InitialCgroup) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*InitialCgroup) StateSave

func (i *InitialCgroup) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*InitialCgroup) StateTypeName

func (i *InitialCgroup) StateTypeName() string

type InternalData

type InternalData struct {
	DefaultControlValues map[string]int64
	InitialCgroup        InitialCgroup
}

InternalData contains internal data passed in to the cgroupfs mount via vfs.GetFilesystemOptions.InternalData.

+stateify savable

func (*InternalData) StateFields

func (i *InternalData) StateFields() []string

func (*InternalData) StateLoad

func (i *InternalData) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*InternalData) StateSave

func (i *InternalData) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*InternalData) StateTypeName

func (i *InternalData) StateTypeName() string

Jump to

Keyboard shortcuts

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