Skip to content

Commit

Permalink
fix helper call removal
Browse files Browse the repository at this point in the history
  • Loading branch information
brycekahle committed Dec 2, 2024
1 parent 88565bb commit 6d8e725
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/ebpf/perf/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func (e *EventHandler) BeforeInit(mgr *manager.Manager, moduleName names.ModuleN
e.initRingBuffer(mgr)
return nil
}
defer e.removeRingBufferHelperCalls(mgr, moduleName, mgrOpts)

if e.opts.mode == perfBufferOnly {
if ms.Type != ebpf.PerfEventArray {
Expand All @@ -212,13 +213,20 @@ func (e *EventHandler) BeforeInit(mgr *manager.Manager, moduleName names.ModuleN
}

e.initPerfBuffer(mgr)
// add helper call remover because ring buffers are not available
return ddebpf.NewHelperCallRemover(asm.FnRingbufOutput).BeforeInit(mgr, moduleName, mgrOpts)
return nil
}

return fmt.Errorf("unsupported EventHandlerMode %d", e.opts.mode)
}

func (e *EventHandler) removeRingBufferHelperCalls(mgr *manager.Manager, moduleName names.ModuleName, mgrOpts *manager.Options) {
if features.HaveMapType(ebpf.RingBuf) == nil {
return
}
// add helper call remover because ring buffers are not available
_ = ddebpf.NewHelperCallRemover(asm.FnRingbufOutput).BeforeInit(mgr, moduleName, mgrOpts)
}

func (e *EventHandler) setupConstant(mgrOpts *manager.Options) {
if e.opts.ringBufferConstantName == "" || e.f == nil {
return
Expand Down

0 comments on commit 6d8e725

Please sign in to comment.