Skip to content

Commit 8f322d2

Browse files
AdvH039brb
authored andcommitted
Add percpu buffer flag
Signed-off-by: Adv <[email protected]>
1 parent aed8306 commit 8f322d2

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

bpf/kprobe_pwru.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ struct {
209209
struct {
210210
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
211211
__type(key, u32);
212-
__type(value, u8[PERCPU_BIG_BUFF_SIZE]);
212+
__uint(value_size, PERCPU_BIG_BUFF_SIZE);
213213
__uint(max_entries, 1);
214214
} percpu_big_buff SEC(".maps");
215215

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 buffers to print skb data (used by --output-skb and --output-skb-shared-info)")
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)