Skip to content

Commit ad2b4f3

Browse files
committed
Add percpu buffer flag
Signed-off-by: Adv <[email protected]>
1 parent a7f9086 commit ad2b4f3

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

bpf/kprobe_pwru.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "bpf/bpf_endian.h"
1010
#include "bpf/bpf_ipv6.h"
1111

12+
1213
#define PERCPU_BIG_BUFF_SIZE 4096
1314
#define PRINT_SKB_STR_SIZE (PERCPU_BIG_BUFF_SIZE - sizeof(u32))
1415
#define PRINT_SHINFO_STR_SIZE (PERCPU_BIG_BUFF_SIZE - sizeof(u32))
@@ -209,7 +210,7 @@ struct {
209210
struct {
210211
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
211212
__type(key, u32);
212-
__type(value, u8[PERCPU_BIG_BUFF_SIZE]);
213+
__uint(value_size, PERCPU_BIG_BUFF_SIZE);
213214
__uint(max_entries, 1);
214215
} percpu_big_buff SEC(".maps");
215216

internal/pwru/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ type Flags struct {
6565
ReadyFile string
6666

6767
Backend string
68+
69+
SetPerCPUBuf uint32
6870
}
6971

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

115+
flag.Uint32Var(&f.SetPerCPUBuf, "set-percpu-buf", 4096, "set the size of the percpu buffer")
113116
flag.Usage = func() {
114117
fmt.Fprintf(os.Stderr, "Usage: %s [options] [pcap-filter]\n", os.Args[0])
115118
fmt.Fprintf(os.Stderr, " Available pcap-filter: see \"man 7 pcap-filter\"\n")

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ func main() {
195195
log.Fatalf("Failed to rewrite config: %v", err)
196196
}
197197

198+
bpfSpec.Maps["percpu_big_buff"].ValueSize = flags.SetPerCPUBuf
199+
198200
haveFexit := pwru.HaveBPFLinkTracing()
199201
if (flags.FilterTraceTc || flags.FilterTraceXdp) && !haveFexit {
200202
log.Fatalf("Current kernel does not support fentry/fexit to run with --filter-trace-tc/--filter-trace-xdp")

0 commit comments

Comments
 (0)