From 102957a00e48a2f74c82f3c4941d79cd7b7272a0 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Fri, 28 Jul 2023 14:03:50 +0000 Subject: [PATCH] tetragon: Speed up tetragon pre validation 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 --- pkg/sensors/tracing/generickprobe.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/sensors/tracing/generickprobe.go b/pkg/sensors/tracing/generickprobe.go index 321799368f8..afebd7ddc57 100644 --- a/pkg/sensors/tracing/generickprobe.go +++ b/pkg/sensors/tracing/generickprobe.go @@ -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] @@ -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{