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

No way to specify PERF_FLAG_FD_OUTPUT (?) #28

Closed
pwaller opened this issue May 10, 2020 · 6 comments
Closed

No way to specify PERF_FLAG_FD_OUTPUT (?) #28

pwaller opened this issue May 10, 2020 · 6 comments

Comments

@pwaller
Copy link
Contributor

pwaller commented May 10, 2020

As far as I can tell, there is no way to pass flags into perf.Open.

Here it's passed as 0:

perf/perf.go

Line 121 in 6861f4b

return open(a, pid, cpu, group, 0)

I want to pass PERF_FLAG_FD_OUTPUT so that I can coalesce tracepoint events into a single ring buffer, where it is useful to preserve their ordering.

@pwaller
Copy link
Contributor Author

pwaller commented May 10, 2020

If it might require a change to the signature of Open, it seems worth fixing before trying to publish this in golang.org/x/...

@acln0
Copy link
Owner

acln0 commented May 10, 2020

The man page for PERF_FLAG_FD_OUTPUT says "broken since Linux 2.6.35". My memory is a little hazy, but I believe you're meant to use PERF_EVENT_IOC_SET_OUTPUT, which is (*Event).SetOutput in this API.

@acln0
Copy link
Owner

acln0 commented May 10, 2020

Please let me know if that works as expected. I see now there is a big comment on SetOutput, and I don't remember all the details.

@pwaller
Copy link
Contributor Author

pwaller commented May 16, 2020

I'm yet to succeed at getting this to work but I've only had limited time to try so far. It seems to make sense to me.

However, what if the kernel introduces a new useful flag in the future?

How could they be specified then? Given current use cases it seems all good, though, so I'm happy to close this.

@simplejackcoder
Copy link

@pwaller were you able to successfully achieve your goal? I also would like to reduce the number of ring buffers I need to consume. Your reason is better than mine (ordering guaranteed by the kernel).

But then you also mention you were unable to make it work. It is my understanding that this functionality (setting the output) is used by BPF so it is not considered broken.

@pwaller
Copy link
Contributor Author

pwaller commented Aug 31, 2020

I don't think I got to the end of my journey of trying to get BPF working as I wanted to. Please file another issue if you have another legitimate use case for it. I'm going to close this one for now.

@pwaller pwaller closed this as completed Aug 31, 2020
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

No branches or pull requests

3 participants