-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support clear() and delete() on a count()-based map without key #1639
Conversation
0acedd8
to
051b6ee
Compare
So the difference between before and after 439a6bc is a count()-based map is an array, so it'll be printed out even if we clear() or delete() it. For example:
but
But I guess most people want to know the final value of the count. |
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.
LGTM, small nit
src/imap.h
Outdated
@@ -27,6 +27,11 @@ class IMap | |||
return map_type_ == BPF_MAP_TYPE_PERCPU_HASH || | |||
map_type_ == BPF_MAP_TYPE_PERCPU_ARRAY; | |||
} | |||
bool is_not_clearable() const |
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.
Can we name this is_clearable()
? Would be confusing to read !is_not_clearable()
later on (the double negation).
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.
That makes sense. will fix.
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.
done.
bbe53ce
to
6efc09f
Compare
6efc09f
to
e29a397
Compare
Needs a rebase |
439a6bc changes so that count()-based map with no arguments uses BPF_MAP_TYPE_PERCPU_ARRAY for the performance. The problem is crear() uses bpf_map_delete_elem(), but ARRAY-typed maps cannot be deleted. To solve this, suggested by fbs in bpftrace#1350 (comment), use zero() internally in clear() if a map type is array. Suggested-by: bas smit <[email protected]> Signed-off-by: Masanori Misono <[email protected]>
Like clear(), delete() also does not work for count()-based map (please see the previous commit message for the details.) To fix this, instead calling bpf_map_delete_elem() when delete(), call bpf_mpa_updat_elem() and update the map value with zero.
e29a397
to
91a71e6
Compare
439a6bc changes so that count()-based map with no arguments uses
BPF_MAP_TYPE_PERCPU_ARRAY for the performance. The problem is crear()
uses bpf_map_delete_elem(), but ARRAY-typed maps cannot be deleted.
To solve this, suggested by fbs in #1350 (comment),
use zero() internally in clear() if a map type is array.
Like clear(), delete() also does not work for count()-based map (please
see the previous commit message for the details.) To fix this, instead
calling bpf_map_delete_elem() when delete(), call bpf_mpa_updat_elem()
and update the map value with zero.
Closes #1350
Checklist
docs/reference_guide.md
CHANGELOG.md