Skip to content

Commit

Permalink
[ksyms] Do not cache ksyms to reduce memory consumption
Browse files Browse the repository at this point in the history
We use ksyms for checking the proper exit hooks when loading the base
sensor. Furthermore, we use it when we add a kprobe policy for a
function that is part of a kernel module.

Having that always in memory, uses a lot of memory. This patch makes the
read of ksyms when we need that.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
  • Loading branch information
tpapagian committed Sep 20, 2024
1 parent 3cefc44 commit 8ccba6c
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions pkg/ksyms/ksyms.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,15 @@ import (
"sort"
"strconv"
"strings"
"sync"

"github.com/cilium/tetragon/pkg/logger"
"github.com/cilium/tetragon/pkg/option"

lru "github.com/hashicorp/golang-lru/v2"
)

var (
kernelSymbols *Ksyms
setKernelSymbols sync.Once
)

func KernelSymbols() (*Ksyms, error) {
var err error
setKernelSymbols.Do(func() {
kernelSymbols, err = NewKsyms(option.Config.ProcFS)
})
return kernelSymbols, err
return NewKsyms(option.Config.ProcFS)
}

type ksym struct {
Expand Down

0 comments on commit 8ccba6c

Please sign in to comment.