Skip to content

Commit

Permalink
bperf: Fix veristat error (#290)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #290

BPF map per_thread_data has variable value size. The default value size
is 1.  This is ok for the actually code, as the userspace will adjust the
value size before loading the skeleton. However, this breaks veristat,
because veristat will load the skeleton without adjustment in user space.

Fix this by increasing the default size to the maximal possible value.

Reviewed By: anakryiko

Differential Revision: D61823794

fbshipit-source-id: 04de6d31f4ef268336164cf886d6d6a441406e6f
  • Loading branch information
liu-song-6 authored and facebook-github-bot committed Aug 27, 2024
1 parent 45e3fc9 commit eb0c488
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hbt/src/perf_event/bpf/bperf_leader_cgroup.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,15 @@ struct {
__uint(max_entries, BPERF_MAX_THREAD_READER);
} per_thread_idx SEC(".maps");

#define BPERF_MAX_THREAD_DATA_SIZE (sizeof(struct bperf_thread_data) + \
sizeof(struct bperf_perf_event_data) * BPERF_MAX_GROUP_SIZE)
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(key_size, sizeof(int));
/* for variable size bperf_thread_data, update value_size before load */
__uint(value_size, 1);
/* for variable size bperf_thread_data, update value_size before load.
* Set the default size to the maximum to make veristat happy.
*/
__uint(value_size, BPERF_MAX_THREAD_DATA_SIZE);
__uint(max_entries, BPERF_MAX_THREAD_READER);
__uint(map_flags, BPF_F_MMAPABLE);
} per_thread_data SEC(".maps");
Expand Down

0 comments on commit eb0c488

Please sign in to comment.