Skip to content
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

add WakeupEvents and Flush #188

Merged
merged 1 commit into from
Jul 3, 2024
Merged

add WakeupEvents and Flush #188

merged 1 commit into from
Jul 3, 2024

Conversation

brycekahle
Copy link
Member

What does this PR do?

Adds WakeupEvents to perf buffers and Flush to both perf buffers and ring buffers.

Motivation

WakeupEvents is used to queue data in perf buffers without waking up userspace. Ring buffers have this builtin control from the eBPF side with flags to helper calls.

Flush is used to manually wakeup userspace to read any data already queued in the buffer. This is useful to have a synchronization point where you have read all available data.

Additional Notes

A sentinel error perf.ErrFlushed is reported by the upstream library when a Flush has completed reading all available data. This is turned into a Record with an empty RawSample field. This is so there is an in-band way of detecting the end. Using the error channel or something else would require potentially complex synchronization.

Describe how to test your changes

@brycekahle brycekahle requested a review from a team as a code owner July 2, 2024 20:26
@@ -127,7 +132,8 @@ func (m *PerfMap) Start() error {
// Create and start the perf map
var err error
opt := perf.ReaderOptions{
Watermark: m.Watermark,
Watermark: m.Watermark,
WakeupEvents: m.WakeupEvents,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just set one of these, to avoid confusions around which one gets applied by the kernel?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upstream handles if they are both set to non-zero values with an error https://github.com/cilium/ebpf/blob/f2b2f6d61aaf1fa8c0eb14c2a58f7e199fbd6086/perf/reader.go#L198-L200

@brycekahle brycekahle merged commit e30f696 into main Jul 3, 2024
3 checks passed
@brycekahle brycekahle deleted the bryce.kahle/flush-wakeup branch July 3, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants