Skip to content

How do I re-use a pinned map when loading an ELF? #603

Answered by ti-mo
d0u9 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @d0u9, thanks for the question.

In order for the ELF loader to automatically pin or re-use a pinned map, the map definition needs to have its pinned flag set.

See the example below:

__uint(pinning, LIBBPF_PIN_BY_NAME);

If you attempt to load this ELF (containing a map definition with the 'pinned' flag) without CollectionOptions.Maps.PinPath set, map creation will fail with an error.

Specifying /sys/fs/bpf will cause a map called global to be created and pinned to /sys/fs/bpf/global. If an map at that path already exists, it will automatically open it and use that existing map in any programs loaded from the ELF. …

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@chenhengqi
Comment options

Comment options

You must be logged in to vote
2 replies
@mrpre
Comment options

@ti-mo
Comment options

Answer selected by ti-mo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants