From 3e00ee8e994147c2dce70bc785fb6fb70f3ecd41 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 21 May 2026 17:58:01 +0300 Subject: j7 add futex kind and aggregate-only defaults --- internal/generate/classify.go | 13 +++++++++++++ internal/generate/classify_test.go | 25 +++++++++++++++++++++++++ internal/generate/codegen_test.go | 4 +++- internal/generate/kindregistry.go | 1 + 4 files changed, 42 insertions(+), 1 deletion(-) (limited to 'internal/generate') diff --git a/internal/generate/classify.go b/internal/generate/classify.go index 3fa8d23..ffac1b3 100644 --- a/internal/generate/classify.go +++ b/internal/generate/classify.go @@ -37,6 +37,7 @@ const ( KindSysVOp KindProc KindBpf + KindFutex ) func (k TracepointKind) MetadataName() string { @@ -103,6 +104,8 @@ func (k TracepointKind) MetadataName() string { return "proc" case KindBpf: return "bpf" + case KindFutex: + return "futex" default: return "none" } @@ -410,6 +413,16 @@ func classifyNameOnly(name string) (ClassificationResult, bool) { return ClassificationResult{Kind: KindProc}, true case "sys_enter_bpf": return ClassificationResult{Kind: KindBpf}, true + case "sys_enter_futex": + return ClassificationResult{Kind: KindFutex}, true + case "sys_enter_futex_wait": + return ClassificationResult{Kind: KindFutex}, true + case "sys_enter_futex_wake": + return ClassificationResult{Kind: KindFutex}, true + case "sys_enter_futex_requeue": + return ClassificationResult{Kind: KindFutex}, true + case "sys_enter_futex_waitv": + return ClassificationResult{Kind: KindFutex}, true case "sys_enter_pidfd_send_signal": return ClassificationResult{Kind: KindFd}, true case "sys_enter_kexec_file_load": diff --git a/internal/generate/classify_test.go b/internal/generate/classify_test.go index 07445ec..c3c7676 100644 --- a/internal/generate/classify_test.go +++ b/internal/generate/classify_test.go @@ -780,6 +780,31 @@ func TestClassifyL7NameOnlyKinds(t *testing.T) { } } +func TestClassifyJ7NameOnlyKinds(t *testing.T) { + tests := []string{ + "sys_enter_futex", + "sys_enter_futex_wait", + "sys_enter_futex_wake", + "sys_enter_futex_requeue", + "sys_enter_futex_waitv", + } + + for _, name := range tests { + t.Run(name, func(t *testing.T) { + r := ClassifyFormat(&Format{ + Name: name, + ExternalFields: []Field{ + {Type: "long", Name: "__syscall_nr"}, + {Type: "long", Name: "arg0"}, + }, + }) + if r.Kind != KindFutex { + t.Fatalf("%s: got kind %d, want KindFutex", name, r.Kind) + } + }) + } +} + func TestClassify67NameOnlyKinds(t *testing.T) { tests := []struct { name string diff --git a/internal/generate/codegen_test.go b/internal/generate/codegen_test.go index 220d77e..cf75324 100644 --- a/internal/generate/codegen_test.go +++ b/internal/generate/codegen_test.go @@ -634,6 +634,7 @@ func TestGenerateAllEventTypes(t *testing.T) { {KindSysVOp, "ENTER_NULL_EVENT", "EXIT_NULL_EVENT"}, {KindProc, "ENTER_NULL_EVENT", "EXIT_NULL_EVENT"}, {KindBpf, "ENTER_NULL_EVENT", "EXIT_NULL_EVENT"}, + {KindFutex, "ENTER_NULL_EVENT", "EXIT_NULL_EVENT"}, } for _, tt := range tests { @@ -682,6 +683,7 @@ func TestEventStructNames(t *testing.T) { {KindSysVOp, "null_event"}, {KindProc, "null_event"}, {KindBpf, "null_event"}, + {KindFutex, "null_event"}, } for _, tt := range tests { @@ -700,7 +702,7 @@ func TestEnterReject(t *testing.T) { t.Error("KindNone should be enter-rejected") } - accepted := []TracepointKind{KindFd, KindOpen, KindMqOpen, KindExec, KindPathname, KindName, KindFcntl, KindNull, KindDup3, KindOpenByHandleAt, KindSocket, KindSocketpair, KindAccept, KindPipe, KindEventfd, KindPidfd, KindEpollCtl, KindTwoFd, KindPoll, KindMem, KindSleep, KindKeyctl, KindPtrace, KindPerfOpen, KindSeccomp, KindModule, KindSysVId, KindSysVOp, KindProc, KindBpf} + accepted := []TracepointKind{KindFd, KindOpen, KindMqOpen, KindExec, KindPathname, KindName, KindFcntl, KindNull, KindDup3, KindOpenByHandleAt, KindSocket, KindSocketpair, KindAccept, KindPipe, KindEventfd, KindPidfd, KindEpollCtl, KindTwoFd, KindPoll, KindMem, KindSleep, KindKeyctl, KindPtrace, KindPerfOpen, KindSeccomp, KindModule, KindSysVId, KindSysVOp, KindProc, KindBpf, KindFutex} for _, k := range accepted { if isEnterRejected(k) { t.Errorf("kind %d should NOT be enter-rejected", k) diff --git a/internal/generate/kindregistry.go b/internal/generate/kindregistry.go index f78bf6f..03977a4 100644 --- a/internal/generate/kindregistry.go +++ b/internal/generate/kindregistry.go @@ -47,6 +47,7 @@ var kindRegistry = map[TracepointKind]kindMeta{ KindSysVOp: {structName: "null_event", enterAccepted: true}, KindProc: {structName: "null_event", enterAccepted: true}, KindBpf: {structName: "null_event", enterAccepted: true}, + KindFutex: {structName: "null_event", enterAccepted: true}, // KindNone is intentionally absent: it represents "unclassified" and is // never enter-accepted. lookupKind returns the zero kindMeta (enterAccepted=false) // for any unregistered kind, so KindNone is implicitly rejected. -- cgit v1.2.3