-
Notifications
You must be signed in to change notification settings - Fork 652
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
Allows user space to update/lookup map elements under bpf_spin_lock #473
Conversation
mehrdadrad
commented
Nov 3, 2021
•
edited
edited
- Added FLock constant (BPF_F_LOCK)
- Added three new map methods to support lookup with FLock:
- LookupWithFlags
- LookupBytesWithFlags
- LookupAndDeleteWithFlags
- Added tests with test data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds a lot of API for a pretty niche use case. Could you instead detect whether a map contains a spinlock at creation time and infer the need for BPF_F_LOCK? This will be somewhat complicated by LoadPinnedMap
which should also work with spinlock maps.
Alternatively we should investigate a single new method LookupOpts(key, valueOut, opts)
. Opts could be:
struct Opts {
Delete bool
Lock bool
}
That would avoid so much new API as well.
@lmb re: detect whether a map contains a spinlock
Your alternative option can be like below:
The last thing, we can add at least two of APIs which I already did same as libbpf. Any thoughts? |
You're right, since it's possible to do a lookup without BPF_F_LOCK always adding it doesn't make sense. Let's scrap the BTF idea. The best thing we can do (imo):
There should be a new type cc @ti-mo |
Can you squash your changes please? |
Thanks! |