Skip to content

Commit

Permalink
Eliminate unwind stat error_catchall (#69)
Browse files Browse the repository at this point in the history
* Eliminate unwind stat error_catchall - added 3 actual stats that composed it

* Add tmate session for debugging

* Remove --ignore-environment from Github workflow clippy step for now

* Remove tmate shell session step

* back to original CI workflow
  • Loading branch information
gmarler authored Sep 17, 2024
1 parent e651efc commit f8fde6d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/bpf/profiler.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ int dwarf_unwind(struct bpf_perf_event_data *ctx) {
// add it, it would be best to add it only during development.
if (previous_rsp == 0) {
LOG("[error] previous_rsp should not be zero.");
bump_unwind_error_catchall();
bump_unwind_error_previous_rsp_zero();
return 1;
}

Expand All @@ -491,7 +491,7 @@ int dwarf_unwind(struct bpf_perf_event_data *ctx) {
LOG("[error] previous_rip should not be zero. This can mean that the "
"read failed, ret=%d while reading @ %llx.",
err, previous_rip_addr);
bump_unwind_error_catchall();
bump_unwind_error_previous_rip_zero();
}
return 1;
}
Expand All @@ -510,7 +510,7 @@ int dwarf_unwind(struct bpf_perf_event_data *ctx) {
LOG("[error] previous_rbp should not be zero. This can mean "
"that the read has failed %d.",
ret);
bump_unwind_error_catchall();
bump_unwind_error_previous_rbp_zero();
return 1;
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/bpf/profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ struct unwinder_stats_t {
u64 error_unsupported_expression;
u64 error_unsupported_frame_pointer_action;
u64 error_unsupported_cfa_register;
u64 error_catchall;
u64 error_previous_rsp_zero;
u64 error_previous_rip_zero;
u64 error_previous_rbp_zero;
u64 error_should_never_happen;
u64 error_bp_should_be_zero_for_bottom_frame;
u64 error_mapping_not_found;
Expand All @@ -89,8 +91,8 @@ struct unwinder_stats_t {
u64 jit_encountered;
};

const volatile struct lightswitch_config_t lightswitch_config = {.verbose_logging =
true};
const volatile struct lightswitch_config_t lightswitch_config = {
.verbose_logging = true};

// A different stack produced the same hash.
#define STACK_COLLISION(err) (err == -EEXIST)
Expand All @@ -99,7 +101,7 @@ const volatile struct lightswitch_config_t lightswitch_config = {.verbose_loggin

#define LOG(fmt, ...) \
({ \
if (lightswitch_config.verbose_logging) { \
if (lightswitch_config.verbose_logging) { \
bpf_printk(fmt, ##__VA_ARGS__); \
} \
})
Expand Down Expand Up @@ -226,4 +228,4 @@ unsigned long long hash_stack(native_stack_t *stack) {
}

return hash;
}
}
4 changes: 3 additions & 1 deletion src/bpf/profiler_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ impl Add for unwinder_stats_t {
+ other.error_unsupported_frame_pointer_action,
error_unsupported_cfa_register: self.error_unsupported_cfa_register
+ other.error_unsupported_cfa_register,
error_catchall: self.error_catchall + other.error_catchall,
error_previous_rsp_zero: self.error_previous_rsp_zero + other.error_previous_rsp_zero,
error_previous_rip_zero: self.error_previous_rip_zero + other.error_previous_rip_zero,
error_previous_rbp_zero: self.error_previous_rbp_zero + other.error_previous_rbp_zero,
error_should_never_happen: self.error_should_never_happen
+ other.error_should_never_happen,
error_bp_should_be_zero_for_bottom_frame: self.error_bp_should_be_zero_for_bottom_frame
Expand Down
7 changes: 4 additions & 3 deletions src/bpf/shared_maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ struct {
__type(value, struct unwinder_stats_t);
} percpu_stats SEC(".maps");


#define DEFINE_COUNTER(__func__name) \
static void bump_unwind_##__func__name() { \
u32 zero = 0; \
Expand All @@ -35,7 +34,9 @@ DEFINE_COUNTER(error_truncated);
DEFINE_COUNTER(error_unsupported_expression);
DEFINE_COUNTER(error_unsupported_frame_pointer_action);
DEFINE_COUNTER(error_unsupported_cfa_register);
DEFINE_COUNTER(error_catchall);
DEFINE_COUNTER(error_previous_rsp_zero);
DEFINE_COUNTER(error_previous_rip_zero);
DEFINE_COUNTER(error_previous_rbp_zero);
DEFINE_COUNTER(error_should_never_happen);
DEFINE_COUNTER(error_bp_should_be_zero_for_bottom_frame);
DEFINE_COUNTER(error_mapping_not_found);
Expand All @@ -47,4 +48,4 @@ DEFINE_COUNTER(error_cfa_offset_did_not_fit);
DEFINE_COUNTER(vdso_encountered);
DEFINE_COUNTER(jit_encountered);

#endif
#endif

0 comments on commit f8fde6d

Please sign in to comment.