Skip to content

Commit

Permalink
samples/bpf: Define MAX_ENTRIES instead of a magic number in offwaketime
Browse files Browse the repository at this point in the history
Define MAX_ENTRIES instead of using 10000 as a magic number in various
places.

Signed-off-by: Muhammad Falak R Wani <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
mfrw authored and anakryiko committed Aug 15, 2021
1 parent faff1cc commit d1bf7c4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions samples/bpf/offwaketime_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
})

#define MINBLOCK_US 1
#define MAX_ENTRIES 10000

struct key_t {
char waker[TASK_COMM_LEN];
Expand All @@ -32,14 +33,14 @@ struct {
__uint(type, BPF_MAP_TYPE_HASH);
__type(key, struct key_t);
__type(value, u64);
__uint(max_entries, 10000);
__uint(max_entries, MAX_ENTRIES);
} counts SEC(".maps");

struct {
__uint(type, BPF_MAP_TYPE_HASH);
__type(key, u32);
__type(value, u64);
__uint(max_entries, 10000);
__uint(max_entries, MAX_ENTRIES);
} start SEC(".maps");

struct wokeby_t {
Expand All @@ -51,14 +52,14 @@ struct {
__uint(type, BPF_MAP_TYPE_HASH);
__type(key, u32);
__type(value, struct wokeby_t);
__uint(max_entries, 10000);
__uint(max_entries, MAX_ENTRIES);
} wokeby SEC(".maps");

struct {
__uint(type, BPF_MAP_TYPE_STACK_TRACE);
__uint(key_size, sizeof(u32));
__uint(value_size, PERF_MAX_STACK_DEPTH * sizeof(u64));
__uint(max_entries, 10000);
__uint(max_entries, MAX_ENTRIES);
} stackmap SEC(".maps");

#define STACKID_FLAGS (0 | BPF_F_FAST_STACK_CMP)
Expand Down

0 comments on commit d1bf7c4

Please sign in to comment.