Skip to content

Commit

Permalink
cgroup2: Manager.Delete: handle both "threaded" and "domain threaded"
Browse files Browse the repository at this point in the history
commit 6f5001d added special handling
for threaded cgroup types. A later contribution added detection for
"domain threaded" as known type, but did not update the handling to
detect this type.

From the original PR;

> Reading cgroup.procs seems to return ENOTSUPP when threaded, so check
> the type of the cg when going to delete and read the relevant file.

An alternative could be to check both variants unconditionally, and to
error if either Manager.Threads or Manager.Procs is non-zero.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Dec 10, 2024
1 parent 0896ceb commit 2236eb0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions cgroup2/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,6 @@ func (c *Manager) fallbackKill() error {
}

func (c *Manager) Delete() error {
var (
tasks []uint64
threaded bool
)
// Kernel prevents cgroups with running process from being removed,
// check the tree is empty.
//
Expand All @@ -485,13 +481,13 @@ func (c *Manager) Delete() error {
if !os.IsNotExist(err) {
return err
}
} else {
threaded = cgType == Threaded
}

if threaded {
var tasks []uint64
switch cgType {
case Threaded, DomainThreaded:
tasks, err = c.Threads(true)
} else {
default:
tasks, err = c.Procs(true)
}
if err != nil {
Expand Down

0 comments on commit 2236eb0

Please sign in to comment.