Skip to content

Commit

Permalink
link/kprobe: Allow fallback to tracefs on old kernels
Browse files Browse the repository at this point in the history
Centos 8 (with kernel 4.18) has kprobe PMU support, but
don't allow `.` in symbol name. Add a new option to
workaround this problem.

Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
  • Loading branch information
chenhengqi committed Mar 24, 2022
1 parent 30211c6 commit 74037f8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion link/kprobe.go
Expand Up @@ -49,6 +49,13 @@ type KprobeOptions struct {
//
// Needs kernel 5.15+.
Cookie uint64

// Fallback to legacy tracefs kprobe interface
// event if kernel has kprobe PMU
//
// This allows old kernels which has kprobe PMU
// but don't support `.` in symbol names to work properly
Legacy bool
}

const (
Expand Down Expand Up @@ -173,7 +180,7 @@ func kprobe(symbol string, prog *ebpf.Program, opts *KprobeOptions, ret bool) (*
if err == nil {
return tp, nil
}
if err != nil && !errors.Is(err, ErrNotSupported) {
if err != nil && !errors.Is(err, ErrNotSupported) && !opts.Legacy {
return nil, fmt.Errorf("creating perf_kprobe PMU: %w", err)
}

Expand Down

0 comments on commit 74037f8

Please sign in to comment.