Skip to content

Set up mapid -> mapfd relocation - #1861

Merged
danobi merged 5 commits into
bpftrace:masterfrom
danobi:relocator
Jun 3, 2021
Merged

Set up mapid -> mapfd relocation#1861
danobi merged 5 commits into
bpftrace:masterfrom
danobi:relocator

Conversation

@danobi

@danobi danobi commented May 27, 2021

Copy link
Copy Markdown
Member

This PR begins the work on ahead-of-time (AOT) compiled bpftrace
scripts. More details on AOT are available here.

Details on relocation are in individual commit messages.

Checklist
  • Language changes are updated in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

@danobi
danobi marked this pull request as ready for review May 27, 2021 20:16
@fbs

fbs commented Jun 1, 2021

Copy link
Copy Markdown
Member

looks good :)

danobi added 5 commits June 2, 2021 22:54
Setup code for relocation helper. The relocator will fixup each probe's
bytecode with information better available at runtime (as opposed to
during codegen).
We will need every map to have an ID in order to relocate
map ID -> map FD in BPF_PSUEDO_MAP_FD loads.
Before it could return Some(nullptr) if the map wasn't actually present
This commit relocates map id -> map fd. This is desirable for multiple
reasons:

1) Codegen should be independent as possible from runtime state such as
   which FD a map gets. The more independent it is, the easier it is to
   test codegen b/c we won't have to mock as much stuff out or configure
   the testing environment as much.

2) This is necessary to enable ahead of time compile bpftrace scripts as
   a map FD is not guaranteed to be the same value on another host.
   Thus, the runtime must relocate map ID -> map FD at load time.
This is no longer necessary as the mapid is placed into bytecode now.
This is nicer b/c now tests can't forget to set next_mapfd_ = 1 before
running the test.
@danobi
danobi merged commit 6683ad5 into bpftrace:master Jun 3, 2021
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