Skip to content

Commit e93d1fa

Browse files
committed
Let print_bpfmap_id be non-zero
By adding 1 to bpf_get_smp_processor_id(), we can safely rely on "if event.PrintBpfmapId > 0" to decide whether there is bpfmap data to read. Signed-off-by: gray <[email protected]>
1 parent 5077b07 commit e93d1fa

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

bpf/kprobe_pwru.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static __always_inline u64
367367
sync_fetch_and_add(void *id_map) {
368368
u32 *id = bpf_map_lookup_elem(id_map, &ZERO);
369369
if (id)
370-
return ((*id)++) | ((u64)bpf_get_smp_processor_id() << 32);
370+
return ((*id)++) | ((u64)(bpf_get_smp_processor_id() + 1) << 32);
371371
return 0;
372372
}
373373

internal/pwru/output.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func (o *output) Print(event *Event) {
458458
fmt.Fprintf(o.writer, "%s", getShinfoData(event, o))
459459
}
460460

461-
if o.flags.OutputBpfmap {
461+
if o.flags.OutputBpfmap && event.PrintBpfmapId > 0 {
462462
fmt.Fprintf(o.writer, "%s", getBpfMapData(event, o))
463463
}
464464

0 commit comments

Comments
 (0)