Skip to content

Commit 59310e8

Browse files
committed
pping: Preallocate memory for aggregation maps
When maps are not preallocated, the creation of map entries may sometimes unpredictably fail with ENOMEM, despite plenty of free memory being available. Solving this memory allocation issue may take some time, so in the mean time let's just preallocate the memory for the aggregation maps as well. Preallocating the maps means the memory usage will be the same regardless of the amount of traffic actually observed (i.e. regardless of the number of aggregation entries that need to be created). To compensate for this higher out-of-the-box memory usage, decrease the histogram resolution from 1000 1ms bins to 250 4ms bins. The memory usage (for the aggregation maps) should be approximately: (56 + NR_BINS * 4) * CPUS * MAP_AGGREGATION_SIZE * 4 With the current values, that translates to roughly 66 MiB per CPU core (down from ~254 MiB/core with 1000 bins). Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
1 parent aadc753 commit 59310e8

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

pping/pping.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ typedef __u64 fixpoint64;
2727
#define EVENT_TYPE_MAP_FULL 3
2828
#define EVENT_TYPE_MAP_CLEAN 4
2929

30-
#define RTT_AGG_NR_BINS 1000UL
31-
#define RTT_AGG_BIN_WIDTH (1 * NS_PER_MS) // 1 ms
30+
#define RTT_AGG_NR_BINS 250UL
31+
#define RTT_AGG_BIN_WIDTH (4 * NS_PER_MS)
3232

3333
/* Special IPv4/IPv6 prefixes used for backup entries
3434
* To avoid them colliding with and actual traffic (causing the traffic to end

pping/pping_kern.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,31 +159,27 @@ struct {
159159
__type(key, __u32);
160160
__type(value, struct aggregated_rtt_stats);
161161
__uint(max_entries, MAP_AGGREGATION_SIZE);
162-
__uint(map_flags, BPF_F_NO_PREALLOC);
163162
} map_v4_agg1 SEC(".maps");
164163

165164
struct {
166165
__uint(type, BPF_MAP_TYPE_PERCPU_HASH);
167166
__type(key, __u32);
168167
__type(value, struct aggregated_rtt_stats);
169168
__uint(max_entries, MAP_AGGREGATION_SIZE);
170-
__uint(map_flags, BPF_F_NO_PREALLOC);
171169
} map_v4_agg2 SEC(".maps");
172170

173171
struct {
174172
__uint(type, BPF_MAP_TYPE_PERCPU_HASH);
175173
__type(key, __u64);
176174
__type(value, struct aggregated_rtt_stats);
177175
__uint(max_entries, MAP_AGGREGATION_SIZE);
178-
__uint(map_flags, BPF_F_NO_PREALLOC);
179176
} map_v6_agg1 SEC(".maps");
180177

181178
struct {
182179
__uint(type, BPF_MAP_TYPE_PERCPU_HASH);
183180
__type(key, __u64);
184181
__type(value, struct aggregated_rtt_stats);
185182
__uint(max_entries, MAP_AGGREGATION_SIZE);
186-
__uint(map_flags, BPF_F_NO_PREALLOC);
187183
} map_v6_agg2 SEC(".maps");
188184

189185
struct {

0 commit comments

Comments
 (0)