Skip to content

Commit

Permalink
fix: BPF map size setting
Browse files Browse the repository at this point in the history
  • Loading branch information
rvql committed Nov 6, 2024
1 parent 95d9c49 commit 2bba4d8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
8 changes: 8 additions & 0 deletions agent/src/ebpf/samples/rust/socket-tracer/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions agent/src/ebpf/user/extended/extended.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ void __attribute__ ((weak)) extended_map_preprocess(struct ebpf_map *map)
{
}

uint32_t __attribute__ ((weak)) extended_feature_flags(struct ebpf_map *map)
{
return 0;
}

void __attribute__ ((weak)) extended_print_cp_tracer_status(void)
{
}
Expand Down
6 changes: 6 additions & 0 deletions agent/src/ebpf/user/extended/extended.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ bool extended_require_dwarf(int pid, const char *path);
*/
void extended_map_preprocess(struct ebpf_map *map);

/**
* @brief **extended_feature_flags()** Get enabled features in extened profile
* @param map The pointer to the map to be created
*/
uint32_t extended_feature_flags(struct ebpf_map *map);

/**
* @brief **extended_print_cp_tracer_status()** Extended Profile runtime
* status output.
Expand Down
21 changes: 15 additions & 6 deletions agent/src/ebpf/user/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,12 +935,21 @@ int ebpf_obj_load(struct ebpf_object *obj)
map_flags = BPF_F_NO_PREALLOC;
}

bool map_enabled = map->def.type == BPF_MAP_TYPE_PROG_ARRAY;
map_enabled |= ((map->def.feat_flags & FEATURE_FLAG_UPROBE_GOLANG) != 0 && is_golang_trace_enabled());
map_enabled |= ((map->def.feat_flags & FEATURE_FLAG_UPROBE_OPENSSL) != 0 && is_openssl_trace_enabled());
map_enabled |= ((map->def.feat_flags & FEATURE_FLAG_PROFILE_ONCPU) != 0 && oncpu_profiler_enabled());
map_enabled |= ((map->def.feat_flags & FEATURE_FLAG_DWARF_UNWINDING) != 0 && get_dwarf_enabled());
if (!map_enabled) {
uint32_t enabled_feats = map->def.feat_flags;
if (!is_golang_trace_enabled()) {
enabled_feats &= ~FEATURE_FLAG_UPROBE_GOLANG;
}
if (!is_openssl_trace_enabled()) {
enabled_feats &= ~FEATURE_FLAG_UPROBE_OPENSSL;
}
if (!oncpu_profiler_enabled()) {
enabled_feats &= ~FEATURE_FLAG_PROFILE_ONCPU;
}
if (!get_dwarf_enabled()) {
enabled_feats &= ~FEATURE_FLAG_DWARF_UNWINDING;
}
enabled_feats &= ~extended_feature_flags(map);
if (enabled_feats == 0) {
map->def.max_entries = 1;
}

Expand Down

0 comments on commit 2bba4d8

Please sign in to comment.