Skip to content

Add percpu buffer flag #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged
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
2 changes: 1 addition & 1 deletion bpf/kprobe_pwru.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ struct {
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__type(key, u32);
__type(value, u8[PERCPU_BIG_BUFF_SIZE]);
__uint(value_size, PERCPU_BIG_BUFF_SIZE);
__uint(max_entries, 1);
} percpu_big_buff SEC(".maps");

Expand Down
3 changes: 3 additions & 0 deletions internal/pwru/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ type Flags struct {
ReadyFile string

Backend string

SetPerCPUBuf uint32
}

func (f *Flags) SetFlags() {
Expand Down Expand Up @@ -110,6 +112,7 @@ func (f *Flags) SetFlags() {
flag.StringVar(&f.Backend, "backend", "",
fmt.Sprintf("Tracing backend('%s', '%s'). Will auto-detect if not specified.", BackendKprobe, BackendKprobeMulti))

flag.Uint32Var(&f.SetPerCPUBuf, "set-percpu-buf", 4096, "set the size of buffers to print skb data (used by --output-skb and --output-skb-shared-info)")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [options] [pcap-filter]\n", os.Args[0])
fmt.Fprintf(os.Stderr, " Available pcap-filter: see \"man 7 pcap-filter\"\n")
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ func main() {
log.Fatalf("Failed to rewrite config: %v", err)
}

bpfSpec.Maps["percpu_big_buff"].ValueSize = flags.SetPerCPUBuf

haveFexit := pwru.HaveBPFLinkTracing()
if (flags.FilterTraceTc || flags.FilterTraceXdp) && !haveFexit {
log.Fatalf("Current kernel does not support fentry/fexit to run with --filter-trace-tc/--filter-trace-xdp")
Expand Down