Skip to content

Commit

Permalink
libbpf-tools: initialize global variables in cachestat and funclatency
Browse files Browse the repository at this point in the history
Signed-off-by: Hengqi Chen <[email protected]>
  • Loading branch information
chenhengqi authored and yonghong-song committed Mar 17, 2021
1 parent 9b6b05a commit 6cf1b6f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions libbpf-tools/cachestat.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

__s64 total; /* total cache accesses without counting dirties */
__s64 misses; /* total of add to lru because of read misses */
__u64 mbd; /* total of mark_buffer_dirty events */
__s64 total = 0; /* total cache accesses without counting dirties */
__s64 misses = 0; /* total of add to lru because of read misses */
__u64 mbd = 0; /* total of mark_buffer_dirty events */

SEC("fentry/add_to_page_cache_lru")
int BPF_PROG(add_to_page_cache_lru)
Expand Down
6 changes: 3 additions & 3 deletions libbpf-tools/funclatency.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "funclatency.h"
#include "bits.bpf.h"

const volatile pid_t targ_tgid;
const volatile int units;
const volatile pid_t targ_tgid = 0;
const volatile int units = 0;

/* key: pid. value: start time */
struct {
Expand All @@ -18,7 +18,7 @@ struct {
__type(value, u64);
} starts SEC(".maps");

__u32 hist[MAX_SLOTS];
__u32 hist[MAX_SLOTS] = {};

SEC("kprobe/dummy_kprobe")
int BPF_KPROBE(dummy_kprobe)
Expand Down

0 comments on commit 6cf1b6f

Please sign in to comment.