diff --git a/bpf/go_redis.h b/bpf/go_redis.h index 9acdedda2..94c4d5998 100644 --- a/bpf/go_redis.h +++ b/bpf/go_redis.h @@ -17,15 +17,15 @@ struct { __uint(type, BPF_MAP_TYPE_LRU_HASH); - __type(key, goroutine_key_t); // key: goroutine id + __type(key, void *); // key: goroutine id __type(value, redis_client_req_t); // the request __uint(max_entries, MAX_CONCURRENT_REQUESTS); } ongoing_redis_requests SEC(".maps"); struct { __uint(type, BPF_MAP_TYPE_LRU_HASH); - __type(key, goroutine_key_t); // key: goroutine id - __type(value, void *); // the *Conn + __type(key, void *); // key: goroutine id + __type(value, void *); // the *Conn __uint(max_entries, MAX_CONCURRENT_REQUESTS); } redis_writes SEC(".maps"); @@ -34,13 +34,11 @@ static __always_inline void setup_request(void *goroutine_addr) { .type = EVENT_GO_REDIS, .start_monotime_ns = bpf_ktime_get_ns(), }; - goroutine_key_t g_key = {}; - goroutine_key_from_id(&g_key, goroutine_addr); // We don't look up in the headers, no http/grpc request, therefore 0 as last argument client_trace_parent(goroutine_addr, &req.tp, 0); - bpf_map_update_elem(&ongoing_redis_requests, &g_key, &req, BPF_ANY); + bpf_map_update_elem(&ongoing_redis_requests, &goroutine_addr, &req, BPF_ANY); } // github.com/redis/go-redis/v9.(*baseClient)._process @@ -61,10 +59,8 @@ int uprobe_redis_process_ret(struct pt_regs *ctx) { bpf_dbg_printk("=== uprobe/redis _process returns === "); void *goroutine_addr = GOROUTINE_PTR(ctx); bpf_dbg_printk("goroutine_addr %lx", goroutine_addr); - goroutine_key_t g_key = {}; - goroutine_key_from_id(&g_key, goroutine_addr); - redis_client_req_t *req = bpf_map_lookup_elem(&ongoing_redis_requests, &g_key); + redis_client_req_t *req = bpf_map_lookup_elem(&ongoing_redis_requests, &goroutine_addr); if (req) { redis_client_req_t *trace = bpf_ringbuf_reserve(&events, sizeof(redis_client_req_t), 0); if (trace) { @@ -76,7 +72,7 @@ int uprobe_redis_process_ret(struct pt_regs *ctx) { } } - bpf_map_delete_elem(&ongoing_redis_requests, &g_key); + bpf_map_delete_elem(&ongoing_redis_requests, &goroutine_addr); return 0; } @@ -94,14 +90,12 @@ int uprobe_redis_with_writer(struct pt_regs *ctx) { off_table_t *ot = get_offsets_table(); bpf_dbg_printk("goroutine_addr %lx", goroutine_addr); - goroutine_key_t g_key = {}; - goroutine_key_from_id(&g_key, goroutine_addr); - redis_client_req_t *req = bpf_map_lookup_elem(&ongoing_redis_requests, &g_key); + redis_client_req_t *req = bpf_map_lookup_elem(&ongoing_redis_requests, &goroutine_addr); if (!req) { setup_request(goroutine_addr); - req = bpf_map_lookup_elem(&ongoing_redis_requests, &g_key); + req = bpf_map_lookup_elem(&ongoing_redis_requests, &goroutine_addr); } if (req) { @@ -112,7 +106,7 @@ int uprobe_redis_with_writer(struct pt_regs *ctx) { cn_ptr + go_offset_of(ot, (go_offset){.v = _redis_conn_bw_pos})); bpf_dbg_printk("bw_ptr %llx", bw_ptr); - bpf_map_update_elem(&redis_writes, &g_key, &bw_ptr, BPF_ANY); + bpf_map_update_elem(&redis_writes, &goroutine_addr, &bw_ptr, BPF_ANY); if (cn_ptr) { void *tcp_conn_ptr = cn_ptr + 8; @@ -141,13 +135,11 @@ int uprobe_redis_with_writer_ret(struct pt_regs *ctx) { void *goroutine_addr = GOROUTINE_PTR(ctx); off_table_t *ot = get_offsets_table(); bpf_dbg_printk("goroutine_addr %lx", goroutine_addr); - goroutine_key_t g_key = {}; - goroutine_key_from_id(&g_key, goroutine_addr); - redis_client_req_t *req = bpf_map_lookup_elem(&ongoing_redis_requests, &g_key); + redis_client_req_t *req = bpf_map_lookup_elem(&ongoing_redis_requests, &goroutine_addr); if (req) { - void **bw_ptr = bpf_map_lookup_elem(&redis_writes, &g_key); + void **bw_ptr = bpf_map_lookup_elem(&redis_writes, &goroutine_addr); if (bw_ptr) { void *bw = *bw_ptr; diff --git a/pkg/internal/ebpf/gotracer/bpf_arm64_bpfel.o b/pkg/internal/ebpf/gotracer/bpf_arm64_bpfel.o index 8fe5c0411..e7c890d33 100644 Binary files a/pkg/internal/ebpf/gotracer/bpf_arm64_bpfel.o and b/pkg/internal/ebpf/gotracer/bpf_arm64_bpfel.o differ diff --git a/pkg/internal/ebpf/gotracer/bpf_debug_arm64_bpfel.o b/pkg/internal/ebpf/gotracer/bpf_debug_arm64_bpfel.o index 52c103674..e29437a4b 100644 Binary files a/pkg/internal/ebpf/gotracer/bpf_debug_arm64_bpfel.o and b/pkg/internal/ebpf/gotracer/bpf_debug_arm64_bpfel.o differ diff --git a/pkg/internal/ebpf/gotracer/bpf_debug_x86_bpfel.o b/pkg/internal/ebpf/gotracer/bpf_debug_x86_bpfel.o index ca52c295b..53f42f0a4 100644 Binary files a/pkg/internal/ebpf/gotracer/bpf_debug_x86_bpfel.o and b/pkg/internal/ebpf/gotracer/bpf_debug_x86_bpfel.o differ diff --git a/pkg/internal/ebpf/gotracer/bpf_tp_arm64_bpfel.o b/pkg/internal/ebpf/gotracer/bpf_tp_arm64_bpfel.o index 8a92d50df..1022f95a8 100644 Binary files a/pkg/internal/ebpf/gotracer/bpf_tp_arm64_bpfel.o and b/pkg/internal/ebpf/gotracer/bpf_tp_arm64_bpfel.o differ diff --git a/pkg/internal/ebpf/gotracer/bpf_tp_debug_arm64_bpfel.o b/pkg/internal/ebpf/gotracer/bpf_tp_debug_arm64_bpfel.o index 0eb13ef3f..14313ea81 100644 Binary files a/pkg/internal/ebpf/gotracer/bpf_tp_debug_arm64_bpfel.o and b/pkg/internal/ebpf/gotracer/bpf_tp_debug_arm64_bpfel.o differ diff --git a/pkg/internal/ebpf/gotracer/bpf_tp_debug_x86_bpfel.o b/pkg/internal/ebpf/gotracer/bpf_tp_debug_x86_bpfel.o index 97fa430ce..ed9311aee 100644 Binary files a/pkg/internal/ebpf/gotracer/bpf_tp_debug_x86_bpfel.o and b/pkg/internal/ebpf/gotracer/bpf_tp_debug_x86_bpfel.o differ diff --git a/pkg/internal/ebpf/gotracer/bpf_tp_x86_bpfel.o b/pkg/internal/ebpf/gotracer/bpf_tp_x86_bpfel.o index 307af2a81..b111e1a15 100644 Binary files a/pkg/internal/ebpf/gotracer/bpf_tp_x86_bpfel.o and b/pkg/internal/ebpf/gotracer/bpf_tp_x86_bpfel.o differ diff --git a/pkg/internal/ebpf/gotracer/bpf_x86_bpfel.o b/pkg/internal/ebpf/gotracer/bpf_x86_bpfel.o index e2d417e2a..f721d98b1 100644 Binary files a/pkg/internal/ebpf/gotracer/bpf_x86_bpfel.o and b/pkg/internal/ebpf/gotracer/bpf_x86_bpfel.o differ