From 650719a058a4f5feb1c9c4281e45101ee43a8f3d Mon Sep 17 00:00:00 2001 From: ningmingxiao Date: Tue, 16 Dec 2025 23:47:19 +0800 Subject: [PATCH] increase chan size to fix oom event lost Signed-off-by: ningmingxiao --- cgroup2/manager.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cgroup2/manager.go b/cgroup2/manager.go index 3536fc97..f7d8a58c 100644 --- a/cgroup2/manager.go +++ b/cgroup2/manager.go @@ -796,7 +796,7 @@ func (c *Manager) memoryEventNonBlockFD() (_ *os.File, retErr error) { } func (c *Manager) EventChan() (<-chan Event, <-chan error) { - ec := make(chan Event, 1) + ec := make(chan Event, 16) errCh := make(chan error, 1) fd, err := c.memoryEventNonBlockFD() @@ -821,12 +821,6 @@ func (c *Manager) EventChan() (<-chan Event, <-chan error) { continue } - // Check cgroup.events first - shouldExit := false - if c.isCgroupEmpty() { - shouldExit = true - } - out := make(map[string]uint64) if err := readKVStatsFile(c.path, "memory.events", out); err != nil { // When cgroup is deleted read may return -ENODEV instead of -ENOENT from open. @@ -844,7 +838,7 @@ func (c *Manager) EventChan() (<-chan Event, <-chan error) { OOMKill: out["oom_kill"], } - if shouldExit { + if c.isCgroupEmpty() { return } }