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

Friendly map create errors, document rlimit and perf ring garbage #94

Merged
merged 3 commits into from
Jun 1, 2020

Conversation

ti-mo
Copy link
Collaborator

@ti-mo ti-mo commented May 11, 2020

Hi all,

While migrating a project off of gobpf, I encountered some issues loading an ELF binary, most of which have been addressed below. There's another part that deals with overwriting the binary's version section with the running kernel's LINUX_VERSION_CODE, but that I'd like to address in another PR.

The removal of BTF requirements in data sections and the rlimit changes might need some extra test coverage, but please let me know what you think before I get started on that.

I've added a bit more detailed info about the perf event buffer underrun in the commit that introduced it:

https://elixir.bootlin.com/linux/v5.5.13/source/kernel/events/core.c#L6611 raw->size is used to size the buffer, but frag->size is used to fill it.

https://elixir.bootlin.com/linux/v5.5.13/source/kernel/events/core.c#L6827
While preparing the sample output, raw->size is set to the sum of all
fragments' sizes minus 4 bytes. However, header->size doesn't include this
4-byte deduction.

I think I might've stumbled across a kernel bug, but looking at bcc and gobpf, it seems like many userspace libraries already depend on that behaviour by now and discard those bytes by default. Raw perf events are 64-bit aligned, but the test case wasn't.

elf_reader.go Outdated Show resolved Hide resolved
elf_reader.go Show resolved Hide resolved
perf/reader.go Outdated Show resolved Hide resolved
perf/reader_test.go Outdated Show resolved Hide resolved
syscalls.go Outdated Show resolved Hide resolved
elf_reader.go Outdated Show resolved Hide resolved
run-tests.sh Outdated Show resolved Hide resolved
@ti-mo ti-mo force-pushed the btf-perf-rlimit-rodata branch 2 times, most recently from ceccbac to 7dd9d2a Compare May 19, 2020 17:41
@ti-mo ti-mo changed the title Remove BTF requirement in ELF data, implicit rlimit, perf event buffer underrun Friendly map create errors, document rlimit and perf ring garbage May 19, 2020
@ti-mo
Copy link
Collaborator Author

ti-mo commented May 26, 2020

Hi @lmb, is this good to go? Any other feedback?

Copy link
Collaborator

@lmb lmb left a comment

Choose a reason for hiding this comment

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

I took a long week-end, hence the delay :) The error messages are much more understandable now, thanks!

syscalls.go Outdated Show resolved Hide resolved
perf/reader_test.go Outdated Show resolved Hide resolved
…reproducer

A patch for this was submitted upstream:
https://lore.kernel.org/patchwork/patch/1244339.

Promises about the buffer's alignment were also removed because they were
inacurrate. The `perf_event_open` man page is incorrect, and there's
another bug in the kernel that causes these buffers to be unaligned.
Copy link
Collaborator

@lmb lmb left a comment

Choose a reason for hiding this comment

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

Thank you for contributing, and your patience!

@lmb lmb merged commit 9f1617e into cilium:master Jun 1, 2020
@ti-mo ti-mo deleted the btf-perf-rlimit-rodata branch December 1, 2020 16:51
@ti-mo ti-mo mentioned this pull request Mar 22, 2023
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.

4 participants