Skip to contentSkip to conversation

libbpf: remove sample_period init in perf_buffer

RFC PATCH In review Tao Chen 3 participants 5 messages Apr 22, 2025 – Apr 23, 2025

Subsystems (2)
lore
Share & tools
lore

Tao Chen

author
#0 lore raw

RFC PATCH 1/1 libbpf: remove sample_period init in perf_buffer

It seems that sample_period no used in perf buffer, actually only wakeup_events valid about events aggregation for wakeup. So remove it to avoid causing confusion.

Fixes fb84b8224655 ("libbpf: add perf buffer API")
---
 tools/lib/bpf/libbpf.c | 1 -
 1 file changed, 1 deletion(-)
tools/lib/bpf/libbpf.c +0 -1
index 194809da5172..1830e3c011a5 100644
@@ -13306,7 +13306,6 @@ struct perf_buffer *perf_buffer__new(int map_fd, size_t page_cnt,
 	attr.config = PERF_COUNT_SW_BPF_OUTPUT;
 	attr.type = PERF_TYPE_SOFTWARE;
 	attr.sample_type = PERF_SAMPLE_RAW;
-	attr.sample_period = sample_period;
 	attr.wakeup_events = sample_period;
 
 	p.attr = &attr;
Signature · 1 line
2.43.0
#1 lore raw
Quoted 3 lines · Tao Chen

It seems that sample_period no used in perf buffer, actually only wakeup_events valid about events aggregation for wakeup. So remove it to avoid causing confusion.

I don't see too much confusion in keeping it, but I think it should be safe to remove it

PERF_COUNT_SW_BPF_OUTPUT is "trigered" by bpf_perf_event_output, AFAICS there's no path checking on sample_period for this event used in context of perf_buffer__new, Namhyung, thoughts?

thanks,
jirka

Quoted 22 lines
Fixes fb84b8224655 ("libbpf: add perf buffer API")
---
 tools/lib/bpf/libbpf.c | 1 -
 1 file changed, 1 deletion(-)
tools/lib/bpf/libbpf.c +0 -1
index 194809da5172..1830e3c011a5 100644
@@ -13306,7 +13306,6 @@ struct perf_buffer *perf_buffer__new(int map_fd, size_t page_cnt,
 	attr.config = PERF_COUNT_SW_BPF_OUTPUT;
 	attr.type = PERF_TYPE_SOFTWARE;
 	attr.sample_type = PERF_SAMPLE_RAW;
-	attr.sample_period = sample_period;
 	attr.wakeup_events = sample_period;
 
 	p.attr = &attr;
Signature · 1 line
2.43.0
Acked-by
#2 lore raw

Hello,

Quoted 11 lines · Jiri Olsa
Quoted 3 lines · Tao Chen

It seems that sample_period no used in perf buffer, actually only wakeup_events valid about events aggregation for wakeup. So remove it to avoid causing confusion.

I don't see too much confusion in keeping it, but I think it should be safe to remove it

PERF_COUNT_SW_BPF_OUTPUT is "trigered" by bpf_perf_event_output, AFAICS there's no path checking on sample_period for this event used in context of perf_buffer__new, Namhyung, thoughts?

It seems to be ok to call mmap(2) for non-sampling events.

Thanks,
Namhyung

Quoted 23 lines
Quoted 23 lines
Fixes fb84b8224655 ("libbpf: add perf buffer API")
---
 tools/lib/bpf/libbpf.c | 1 -
 1 file changed, 1 deletion(-)
tools/lib/bpf/libbpf.c +0 -1
index 194809da5172..1830e3c011a5 100644
@@ -13306,7 +13306,6 @@ struct perf_buffer *perf_buffer__new(int map_fd, size_t page_cnt,
 	attr.config = PERF_COUNT_SW_BPF_OUTPUT;
 	attr.type = PERF_TYPE_SOFTWARE;
 	attr.sample_type = PERF_SAMPLE_RAW;
-	attr.sample_period = sample_period;
 	attr.wakeup_events = sample_period;
 
 	p.attr = &attr;
Signature · 1 line
2.43.0
Acked-by
#3 lore raw
Quoted 11 lines · Namhyung Kim

Hello,

Quoted 8 lines · Jiri Olsa
Quoted 3 lines · Tao Chen

It seems that sample_period no used in perf buffer, actually only wakeup_events valid about events aggregation for wakeup. So remove it to avoid causing confusion.

I don't see too much confusion in keeping it, but I think it should be safe to remove it

Quoted 7 lines
Quoted 3 lines

PERF_COUNT_SW_BPF_OUTPUT is "trigered" by bpf_perf_event_output, AFAICS there's no path checking on sample_period for this event used in context of perf_buffer__new, Namhyung, thoughts?

It seems to be ok to call mmap(2) for non-sampling events.

Tao Chen,
could you please resend without rfc tag? plz keeps acks

thanks,
jirka

Quoted 27 lines

Thanks,
Namhyung

Quoted 23 lines
Quoted 23 lines
Fixes fb84b8224655 ("libbpf: add perf buffer API")
---
 tools/lib/bpf/libbpf.c | 1 -
 1 file changed, 1 deletion(-)
tools/lib/bpf/libbpf.c +0 -1
index 194809da5172..1830e3c011a5 100644
@@ -13306,7 +13306,6 @@ struct perf_buffer *perf_buffer__new(int map_fd, size_t page_cnt,
 	attr.config = PERF_COUNT_SW_BPF_OUTPUT;
 	attr.type = PERF_TYPE_SOFTWARE;
 	attr.sample_type = PERF_SAMPLE_RAW;
-	attr.sample_period = sample_period;
 	attr.wakeup_events = sample_period;
 
 	p.attr = &attr;
Signature · 1 line
2.43.0
author
#4 lore raw
Quoted 16 lines · Jiri Olsa
Quoted 15 lines · Namhyung Kim

Hello,

Quoted 11 lines · Jiri Olsa
Quoted 3 lines · Tao Chen

It seems that sample_period no used in perf buffer, actually only wakeup_events valid about events aggregation for wakeup. So remove it to avoid causing confusion.

I don't see too much confusion in keeping it, but I think it should be safe to remove it

PERF_COUNT_SW_BPF_OUTPUT is "trigered" by bpf_perf_event_output, AFAICS there's no path checking on sample_period for this event used in context of perf_buffer__new, Namhyung, thoughts?

Quoted 7 lines
Quoted 3 lines

It seems to be ok to call mmap(2) for non-sampling events.

Tao Chen,
could you please resend without rfc tag? plz keeps acks

sure, will resend it, thanks.

Quoted 33 lines

thanks,
jirka

Quoted 27 lines

Thanks,
Namhyung

Quoted 23 lines
Quoted 23 lines
Fixes fb84b8224655 ("libbpf: add perf buffer API")
---
  tools/lib/bpf/libbpf.c | 1 -
  1 file changed, 1 deletion(-)
tools/lib/bpf/libbpf.c +0 -1
index 194809da5172..1830e3c011a5 100644
@@ -13306,7 +13306,6 @@ struct perf_buffer *perf_buffer__new(int map_fd, size_t page_cnt,
  	attr.config = PERF_COUNT_SW_BPF_OUTPUT;
  	attr.type = PERF_TYPE_SOFTWARE;
  	attr.sample_type = PERF_SAMPLE_RAW;
-	attr.sample_period = sample_period;
  	attr.wakeup_events = sample_period;
 
  	p.attr = &attr;
Signature · 1 line
2.43.0
Signature · 2 lines
Best Regards
Tao Chen