Skip to content

cgroups: Create generic handler for v1 and v2

Will Chandler requested to merge wc/cgroup-generic into master

We have separate cgroup handler implementations for cgroups-v1 and cgroups-v2, but much of this is duplicated other than the cgroup type.

Create a new genericHandler to unify most of the logic for cgroups-v1 and v2. This is made generic over two parameters:

  • T: The cgroup type, cgroup1.Cgroup or *cgroup2.Manager.
  • H: The hierarchy or mountpoint passed when creating a cgroup. For cgroup1.New this is a cgroup1.Hierarchy, for cgroup2.New this is a string with the path to the cgroup's mountpoint.

Four generic functions are added for the operations that are easily abstracted over. Metrics and stats collection are not included as they involve significant version-specific logic.

Edited by Will Chandler

Merge request reports