From 9bd3c365ccd2c7c312d72114cd564e600255097b Mon Sep 17 00:00:00 2001 From: Herman Zhu Date: Tue, 9 Jul 2024 17:12:51 +0800 Subject: [PATCH] perf: fix panic when CPU is offline Commit 75bce381 ("perf: opportunistically check all rings for data") introduced a panic on systems where not all CPUs are online. Fix this by skipping nil rings. Signed-off-by: zhuhuijun --- perf/reader.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/perf/reader.go b/perf/reader.go index ee557e449..79c4f502d 100644 --- a/perf/reader.go +++ b/perf/reader.go @@ -386,6 +386,11 @@ func (pr *Reader) ReadInto(rec *Record) error { // Waking up userspace is expensive, make the most of it by checking // all rings. for _, ring := range pr.rings { + // Skip rings that are not currently enabled. + if ring == nil { + continue + } + ring.loadHead() pr.epollRings = append(pr.epollRings, ring) }