diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-22 23:00:03 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-22 23:00:03 +0200 |
| commit | 1666ba49ef9e5b61e14d1a32d2f6e2380064105e (patch) | |
| tree | 182b5e7b8e3464fefac256c22118312388c41bc9 | |
| parent | 86a96020fb63cf15ee6d20ec3058a462b5cacd7e (diff) | |
Fix event comm attribution and reduce integration log noise
| -rw-r--r-- | Magefile.go | 29 | ||||
| -rw-r--r-- | integrationtests/close_test.go | 1 | ||||
| -rw-r--r-- | integrationtests/cmd/ioworkload/scenario_copy_file_range.go | 3 | ||||
| -rw-r--r-- | internal/eventloop.go | 39 |
4 files changed, 71 insertions, 1 deletions
diff --git a/Magefile.go b/Magefile.go index 7e88141..86e5958 100644 --- a/Magefile.go +++ b/Magefile.go @@ -672,14 +672,43 @@ func envToList(env map[string]string) []string { } func shouldPrintTestLog(msg string) bool { + // Always keep error/failure lines. + if strings.Contains(msg, "--- FAIL:") || + strings.Contains(msg, " FAIL ") || + strings.Contains(msg, "panic:") || + strings.Contains(strings.ToLower(msg), "error") || + strings.Contains(strings.ToLower(msg), "expected event not found") { + return true + } + // Drop high-volume attach/debug noise from ior startup in integration tests. noisePrefixes := []string{ + "=== RUN", + "___", + "|_ _|", + "| |", + "|___", + "v0.0.0", + "libbpf:", "ShouldIAttachTracepoint called with ", "Attaching tracepoint ", "Attached prog handle_ ", "Attached tracepoint", "Attaching sys_", "Not attaching sys_", + "Collecting flame graph stats", + "Starting flamegraph worker", + "Waiting for stats to be ready", + "Stopping event loop", + "Waiting for flamegraph", + "Worker ", + "Writing ", + "Good bye...", + "Statistics:", + "duration:", + "tracepoints:", + "syscalls:", + "syscalls after filter:", } for _, p := range noisePrefixes { if strings.HasPrefix(msg, p) { diff --git a/integrationtests/close_test.go b/integrationtests/close_test.go index f2ecd34..3689fb8 100644 --- a/integrationtests/close_test.go +++ b/integrationtests/close_test.go @@ -28,6 +28,7 @@ func TestCloseInvalidFd(t *testing.T) { runScenario(t, "close-invalid-fd", []ExpectedEvent{ { Tracepoint: "enter_close", + Comm: "ioworkload", MinCount: 1, }, }) diff --git a/integrationtests/cmd/ioworkload/scenario_copy_file_range.go b/integrationtests/cmd/ioworkload/scenario_copy_file_range.go index 87531b0..ce0524e 100644 --- a/integrationtests/cmd/ioworkload/scenario_copy_file_range.go +++ b/integrationtests/cmd/ioworkload/scenario_copy_file_range.go @@ -37,6 +37,9 @@ func copyFileRangeBasic() error { if _, err := syscall.Write(srcFd, data); err != nil { return fmt.Errorf("write source: %w", err) } + if _, err := syscall.Seek(srcFd, 0, 0); err != nil { + return fmt.Errorf("seek source: %w", err) + } n, _, errno := syscall.Syscall6(uintptr(sysCopyFileRange), uintptr(srcFd), 0, uintptr(dstFd), 0, uintptr(len(data)), 0) if errno != 0 { diff --git a/internal/eventloop.go b/internal/eventloop.go index 7bfd576..654d0fc 100644 --- a/internal/eventloop.go +++ b/internal/eventloop.go @@ -40,7 +40,7 @@ type eventLoop struct { } func newEventLoop() *eventLoop { - return &eventLoop{ + el := &eventLoop{ filter: newEventFilter(), enterEvs: make(map[uint32]*event.Pair), pendingHandles: make(map[uint32]string), @@ -51,6 +51,28 @@ func newEventLoop() *eventLoop { flamegraph: flamegraph.New(), done: make(chan struct{}), } + el.seedTrackedPidComm() + return el +} + +func (e *eventLoop) seedTrackedPidComm() { + pid := flags.Get().PidFilter + if pid <= 0 { + return + } + commPath := fmt.Sprintf("/proc/%d/comm", pid) + data, err := os.ReadFile(commPath) + if err != nil { + return + } + comm := string(data) + if len(comm) > 0 && comm[len(comm)-1] == '\n' { + comm = comm[:len(comm)-1] + } + if comm == "" { + return + } + e.comms[uint32(pid)] = comm } func (e *eventLoop) stats() string { @@ -174,6 +196,10 @@ func (e *eventLoop) processRawEvent(raw []byte, ch chan<- *event.Pair) { func (e *eventLoop) tracepointEntered(enterEv event.Event) { tid := enterEv.GetTid() + // Cache comm as early as possible to reduce races for short-lived processes. + if _, ok := e.comms[tid]; !ok { + _ = e.comm(tid) + } if !e.filter.commFilterEnable { e.enterEvs[tid] = event.NewPair(enterEv) return @@ -427,6 +453,17 @@ func (e *eventLoop) comm(tid uint32) string { if comm, ok := e.comms[tid]; ok { return comm } + commPath := fmt.Sprintf("/proc/%d/comm", tid) + if data, err := os.ReadFile(commPath); err == nil { + comm := string(data) + if len(comm) > 0 && comm[len(comm)-1] == '\n' { + comm = comm[:len(comm)-1] + } + if comm != "" { + e.comms[tid] = comm + return comm + } + } if linkName, err := os.Readlink(fmt.Sprintf("/proc/%d/exe", tid)); err == nil { linkName = filepath.Base(linkName) e.comms[tid] = linkName |
