CGroups2

cgroup2 support for DIRAC pilot.

class DIRAC.Core.Utilities.CGroups2.CG2Manager(*args, **kwargs)

Bases: object

A class to manage cgroup2 hierachy for a typical pilot job use-case.

This creates a group for all of the pilot processes (anything in the group at the start. This is a requirement for controlling the sub-groups (no processes in non-leaf groups).

A group is then created on request for each “slot” under the pilot, with the requested limits.

CPU_PERIOD = 100000
CPU_WEIGHT = 100000
CTRL_CONTROLLERS = 'cgroup.controllers'
CTRL_CPU_MAX = 'cpu.max'
CTRL_MEM_EVENTS = 'memory.events'
CTRL_MEM_MAX = 'memory.max'
CTRL_MEM_OOM_GROUP = 'memory.oom.group'
CTRL_MEM_PEAK = 'memory.peak'
CTRL_MEM_SWAP_MAX = 'memory.swap.max'
CTRL_PROCS = 'cgroup.procs'
CTRL_SUBTREE = 'cgroup.subtree_control'
FILE_CUR_CGROUP = '/proc/3588/cgroup'
FILE_MOUNTS = '/proc/mounts'
PILOT_GROUP = 'dirac_pilot_3588'
__init__()

Set-up CGroup2 manager.

instance = None
setUp()

Creates the base cgroup tree if possible. Should be called once per process before using systemCall. Returns S_OK/S_ERROR.

systemCall(*args, **kwargs)

A proxy function for Subprocess.systemCall but will create a cgroup2 slot if the functionality is available. An optional ceParameters dictionary may be included, which will be searched for specific cgroup memory options. Returns the usual S_OK/S_ERROR from Subprocess.systemCall.