summaryrefslogtreecommitdiffstats
path: root/utils/oci-runtime-tools/patches/010-cgroups-rename-GetSubsystemPath-to-GetV1SubsystemPath.patch
blob: deb08bd66a1f842e920bfdf6c26e79612d788e55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
From ca16950875eb0a63febdfa2189c3585c92301983 Mon Sep 17 00:00:00 2001
From: Daniel Golle <daniel@makrotopia.org>
Date: Tue, 20 Oct 2026 16:48:51 +0100
Subject: [PATCH] cgroups: rename GetSubsystemPath to GetV1SubsystemPath

The function looks a controller up by name in /proc/<pid>/cgroup, which
only means something for the cgroup v1 hierarchies; the unified
hierarchy has a single entry with an empty controller list. Name it
for what it does so that a cgroup v2 lookup can sit next to it.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 cgroups/cgroups.go    |  4 ++--
 cgroups/cgroups_v1.go | 18 +++++++++---------
 2 files changed, 11 insertions(+), 11 deletions(-)

--- a/cgroups/cgroups.go
+++ b/cgroups/cgroups.go
@@ -76,8 +76,8 @@ func FindCgroup() (Cgroup, error) {
 	return nil, fmt.Errorf("cgroup is not found")
 }
 
-// GetSubsystemPath gets path of subsystem
-func GetSubsystemPath(pid int, subsystem string) (string, error) {
+// GetV1SubsystemPath gets the path of a cgroup v1 subsystem
+func GetV1SubsystemPath(pid int, subsystem string) (string, error) {
 	contents, err := os.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
 	if err != nil {
 		return "", err
--- a/cgroups/cgroups_v1.go
+++ b/cgroups/cgroups_v1.go
@@ -52,7 +52,7 @@ func (cg *CgroupV1) GetBlockIOData(pid i
 		fileName := strings.Join([]string{"blkio", name}, ".")
 		filePath := filepath.Join(cg.MountPath, "blkio", cgPath, fileName)
 		if !filepath.IsAbs(cgPath) {
-			subPath, err := GetSubsystemPath(pid, "blkio")
+			subPath, err := GetV1SubsystemPath(pid, "blkio")
 			if err != nil {
 				return nil, err
 			}
@@ -227,7 +227,7 @@ func (cg *CgroupV1) GetCPUData(pid int,
 		fileName := strings.Join([]string{"cpu", name}, ".")
 		filePath := filepath.Join(cg.MountPath, "cpu", cgPath, fileName)
 		if !filepath.IsAbs(cgPath) {
-			subPath, err := GetSubsystemPath(pid, "cpu")
+			subPath, err := GetV1SubsystemPath(pid, "cpu")
 			if err != nil {
 				return nil, err
 			}
@@ -294,7 +294,7 @@ func (cg *CgroupV1) GetCPUData(pid int,
 		fileName := strings.Join([]string{"cpuset", name}, ".")
 		filePath := filepath.Join(cg.MountPath, "cpuset", cgPath, fileName)
 		if !filepath.IsAbs(cgPath) {
-			subPath, err := GetSubsystemPath(pid, "cpuset")
+			subPath, err := GetV1SubsystemPath(pid, "cpuset")
 			if err != nil {
 				return nil, err
 			}
@@ -324,7 +324,7 @@ func (cg *CgroupV1) GetDevicesData(pid i
 	fileName := strings.Join([]string{"devices", "list"}, ".")
 	filePath := filepath.Join(cg.MountPath, "devices", cgPath, fileName)
 	if !filepath.IsAbs(cgPath) {
-		subPath, err := GetSubsystemPath(pid, "devices")
+		subPath, err := GetV1SubsystemPath(pid, "devices")
 		if err != nil {
 			return nil, err
 		}
@@ -447,7 +447,7 @@ func (cg *CgroupV1) GetHugepageLimitData
 		maxUsage := strings.Join([]string{"hugetlb", pageSize, "limit_in_bytes"}, ".")
 		filePath := filepath.Join(cg.MountPath, "hugetlb", cgPath, maxUsage)
 		if !filepath.IsAbs(cgPath) {
-			subPath, err := GetSubsystemPath(pid, "hugetlb")
+			subPath, err := GetV1SubsystemPath(pid, "hugetlb")
 			if err != nil {
 				return lh, err
 			}
@@ -494,7 +494,7 @@ func (cg *CgroupV1) GetMemoryData(pid in
 		fileName := strings.Join([]string{"memory", name}, ".")
 		filePath := filepath.Join(cg.MountPath, "memory", cgPath, fileName)
 		if !filepath.IsAbs(cgPath) {
-			subPath, err := GetSubsystemPath(pid, "memory")
+			subPath, err := GetV1SubsystemPath(pid, "memory")
 			if err != nil {
 				return nil, err
 			}
@@ -587,7 +587,7 @@ func (cg *CgroupV1) GetNetworkData(pid i
 	fileName := strings.Join([]string{"net_cls", "classid"}, ".")
 	filePath := filepath.Join(cg.MountPath, "net_cls", cgPath, fileName)
 	if !filepath.IsAbs(cgPath) {
-		subPath, err := GetSubsystemPath(pid, "net_cls")
+		subPath, err := GetV1SubsystemPath(pid, "net_cls")
 		if err != nil {
 			return nil, err
 		}
@@ -614,7 +614,7 @@ func (cg *CgroupV1) GetNetworkData(pid i
 	fileName = strings.Join([]string{"net_prio", "ifpriomap"}, ".")
 	filePath = filepath.Join(cg.MountPath, "net_prio", cgPath, fileName)
 	if !filepath.IsAbs(cgPath) {
-		subPath, err := GetSubsystemPath(pid, "net_prio")
+		subPath, err := GetV1SubsystemPath(pid, "net_prio")
 		if err != nil {
 			return nil, err
 		}
@@ -658,7 +658,7 @@ func (cg *CgroupV1) GetPidsData(pid int,
 	fileName := strings.Join([]string{"pids", "max"}, ".")
 	filePath := filepath.Join(cg.MountPath, "pids", cgPath, fileName)
 	if !filepath.IsAbs(cgPath) {
-		subPath, err := GetSubsystemPath(pid, "pids")
+		subPath, err := GetV1SubsystemPath(pid, "pids")
 		if err != nil {
 			return nil, err
 		}