From eb0c4885811edadcd81b7a5231248776ac2176c8 Mon Sep 17 00:00:00 2001 From: Song Liu Date: Mon, 26 Aug 2024 17:43:10 -0700 Subject: [PATCH] bperf: Fix veristat error (#290) Summary: Pull Request resolved: https://github.com/facebookincubator/dynolog/pull/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 --- hbt/src/perf_event/bpf/bperf_leader_cgroup.bpf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hbt/src/perf_event/bpf/bperf_leader_cgroup.bpf.c b/hbt/src/perf_event/bpf/bperf_leader_cgroup.bpf.c index 0805aa38..274dd19d 100644 --- a/hbt/src/perf_event/bpf/bperf_leader_cgroup.bpf.c +++ b/hbt/src/perf_event/bpf/bperf_leader_cgroup.bpf.c @@ -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");