Skip to content

Commit

Permalink
tetragon: Speed up tetragon pre validation
Browse files Browse the repository at this point in the history
There's no need to create new btf object for each kprobe,
we can create it just once. It speeds up loading policies
with many functions.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Jul 28, 2023
1 parent b123cd0 commit 102957a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/sensors/tracing/generickprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ func preValidateList(name string, lists []v1alpha1.ListSpec) error {
// Pre validate the kprobe semantics and BTF information in order to separate
// the kprobe errors from BPF related ones.
func preValidateKprobes(name string, kprobes []v1alpha1.KProbeSpec, lists []v1alpha1.ListSpec) error {
btfobj, err := btf.NewBTF()
if err != nil {
return err
}

for i := range kprobes {
f := &kprobes[i]

Expand Down Expand Up @@ -342,11 +347,6 @@ func preValidateKprobes(name string, kprobes []v1alpha1.KProbeSpec, lists []v1al
}

// Now go over BTF validation
btfobj, err := btf.NewBTF()
if err != nil {
return err
}

if err := btf.ValidateKprobeSpec(btfobj, f); err != nil {
if warn, ok := err.(*btf.ValidationWarn); ok {
logger.GetLogger().WithFields(logrus.Fields{
Expand Down

0 comments on commit 102957a

Please sign in to comment.