Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions ebpf/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"syscall"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/link"
"github.com/cilium/ebpf/perf"
"github.com/go-kit/log"
Expand Down Expand Up @@ -173,12 +172,11 @@ func (s *session) Start() error {
if err != nil {
return fmt.Errorf("unable to get pid namespace %w", err)
}
err = spec.RewriteConstants(map[string]interface{}{
"global_config": pyrobpf.ProfileGlobalConfigT{
NsPidIno: nsIno,
},
})
if err != nil {
v, ok := spec.Variables["global_config"]
if !ok {
return fmt.Errorf("pyrobpf rewrite constants: variable global_config not found")
}
if err := v.Set(pyrobpf.ProfileGlobalConfigT{NsPidIno: nsIno}); err != nil {
return fmt.Errorf("pyrobpf rewrite constants %w", err)
}
}
Expand All @@ -189,8 +187,6 @@ func (s *session) Start() error {
return fmt.Errorf("load bpf objects: %w", err)
}

btf.FlushKernelSpec() // save some memory

eventsReader, err := perf.NewReader(s.bpf.ProfileMaps.Events, 4*os.Getpagesize())
if err != nil {
s.stopLocked()
Expand Down
20 changes: 9 additions & 11 deletions ebpf/session_python.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/btf"
"github.com/go-kit/log/level"
"github.com/grafana/pyroscope/ebpf/pyrobpf"
"github.com/grafana/pyroscope/ebpf/python"
Expand Down Expand Up @@ -107,8 +106,6 @@ func (s *session) getPyPerf(cause *sd.Target) *python.Perf {
}

func (s *session) loadPyPerf(cause *sd.Target) (*python.Perf, error) {
defer btf.FlushKernelSpec() // save some memory

opts := &ebpf.CollectionOptions{
Programs: s.progOptions(),
MapReplacements: map[string]*ebpf.Map{
Expand All @@ -124,14 +121,15 @@ func (s *session) loadPyPerf(cause *sd.Target) (*python.Perf, error) {
if err != nil {
return nil, fmt.Errorf("unable to get pid namespace %w", err)
}
err = spec.RewriteConstants(map[string]interface{}{
"global_config": python.PerfGlobalConfigT{
BpfLogErr: boolToU8(s.pythonBPFErrorLogEnabled(cause)),
BpfLogDebug: boolToU8(s.pythonBPFDebugLogEnabled(cause)),
NsPidIno: nsIno,
},
})
if err != nil {
v, ok := spec.Variables["global_config"]
if !ok {
return nil, fmt.Errorf("pyperf rewrite constants: variable global_config not found")
}
if err := v.Set(python.PerfGlobalConfigT{
BpfLogErr: boolToU8(s.pythonBPFErrorLogEnabled(cause)),
BpfLogDebug: boolToU8(s.pythonBPFDebugLogEnabled(cause)),
NsPidIno: nsIno,
}); err != nil {
return nil, fmt.Errorf("pyperf rewrite constants %w", err)
}
if s.options.BPFMapsOptions.SymbolsMapSize != 0 {
Expand Down