mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
cgroupfs: don't add a task in the root cgroup if it is already there.
PiperOrigin-RevId: 377975013
This commit is contained in:
@@ -1861,7 +1861,9 @@ func (k *Kernel) PopulateNewCgroupHierarchy(root Cgroup) {
|
||||
return
|
||||
}
|
||||
t.mu.Lock()
|
||||
t.enterCgroupLocked(root)
|
||||
// A task can be in the cgroup if it has been created after the
|
||||
// cgroup hierarchy was registered.
|
||||
t.enterCgroupIfNotYetLocked(root)
|
||||
t.mu.Unlock()
|
||||
})
|
||||
k.tasks.mu.RUnlock()
|
||||
|
||||
@@ -85,6 +85,14 @@ func (t *Task) enterCgroupLocked(c Cgroup) {
|
||||
c.Enter(t)
|
||||
}
|
||||
|
||||
// +checklocks:t.mu
|
||||
func (t *Task) enterCgroupIfNotYetLocked(c Cgroup) {
|
||||
if _, ok := t.cgroups[c]; ok {
|
||||
return
|
||||
}
|
||||
t.enterCgroupLocked(c)
|
||||
}
|
||||
|
||||
// LeaveCgroups removes t out from all its cgroups.
|
||||
func (t *Task) LeaveCgroups() {
|
||||
t.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user