Skip to content

Commit 17367da

Browse files
committed
Support cgroup.AddThread in cgroupv2 manager
In threaded mode, we need to add thread id to cgroup.threads. This work is to make the cgroupv2 manager support AddThread(). Fixes: #242 Signed-off-by: yaoyinnan <yaoyinnan@foxmail.com>
1 parent 04ebfd6 commit 17367da

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

v2/manager.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,14 @@ func (c *Manager) AddProc(pid uint64) error {
336336
return writeValues(c.path, []Value{v})
337337
}
338338

339+
func (c *Manager) AddThread(tid uint64) error {
340+
v := Value{
341+
filename: cgroupThreads,
342+
value: tid,
343+
}
344+
return writeValues(c.path, []Value{v})
345+
}
346+
339347
func (c *Manager) Delete() error {
340348
return remove(c.path)
341349
}

v2/utils.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ import (
3030

3131
"github.com/containerd/cgroups/v2/stats"
3232

33-
"github.com/godbus/dbus/v5"
34-
"github.com/opencontainers/runtime-spec/specs-go"
3533
"github.com/sirupsen/logrus"
3634
)
3735

3836
const (
3937
cgroupProcs = "cgroup.procs"
38+
cgroupThreads = "cgroup.threads"
4039
defaultDirPerm = 0755
4140
)
4241

0 commit comments

Comments
 (0)