diff --git a/src/cc/export/helpers.h b/src/cc/export/helpers.h index 6a7a7bd942db..2b64ee8d1a9c 100644 --- a/src/cc/export/helpers.h +++ b/src/cc/export/helpers.h @@ -566,6 +566,7 @@ int bpf_usdt_readarg_p(int argc, struct pt_regs *ctx, void *buf, u64 len) asm("l #define PT_REGS_PARM4(ctx) ((ctx)->cx) #define PT_REGS_PARM5(ctx) ((ctx)->r8) #define PT_REGS_PARM6(ctx) ((ctx)->r9) +#define PT_REGS_FP(ctx) ((ctx)->bp) /* Works only with CONFIG_FRAME_POINTER */ #define PT_REGS_RC(ctx) ((ctx)->ax) #define PT_REGS_IP(ctx) ((ctx)->ip) #define PT_REGS_SP(ctx) ((ctx)->sp) diff --git a/tools/lib/ucalls.py b/tools/lib/ucalls.py index 2798793759b4..04214e8733dd 100755 --- a/tools/lib/ucalls.py +++ b/tools/lib/ucalls.py @@ -185,7 +185,7 @@ #ifdef SYSCALLS int syscall_entry(struct pt_regs *ctx) { u64 pid = bpf_get_current_pid_tgid(); - u64 *valp, ip = ctx->ip, val = 0; + u64 *valp, ip = PT_REGS_IP(ctx), val = 0; PID_FILTER #ifdef LATENCY struct syscall_entry_t data = {}; diff --git a/tools/memleak.py b/tools/memleak.py index 484c386488d6..a9030f7f36a0 100755 --- a/tools/memleak.py +++ b/tools/memleak.py @@ -14,6 +14,7 @@ from bcc import BPF from time import sleep from datetime import datetime +import resource import argparse import subprocess import os @@ -366,6 +367,7 @@ def run_command_get_pid(command): bpf_source = bpf_source.replace("SHOULD_PRINT", "1" if trace_all else "0") bpf_source = bpf_source.replace("SAMPLE_EVERY_N", str(sample_every_n)) +bpf_source = bpf_source.replace("PAGE_SIZE", str(resource.getpagesize())) size_filter = "" if min_size is not None and max_size is not None: diff --git a/tools/wakeuptime.py b/tools/wakeuptime.py index 949e02b1435d..e09840aa411d 100755 --- a/tools/wakeuptime.py +++ b/tools/wakeuptime.py @@ -76,13 +76,19 @@ def signal_ignore(signal, frame): static u64 get_frame(u64 *bp) { if (*bp) { - // The following stack walker is x86_64 specific + // The following stack walker is x86_64/arm64 specific u64 ret = 0; if (bpf_probe_read(&ret, sizeof(ret), (void *)(*bp+8))) return 0; if (bpf_probe_read(bp, sizeof(*bp), (void *)*bp)) return 0; +#ifdef __x86_64__ if (ret < __START_KERNEL_map) +#elif __aarch64__ + if (ret < VA_START) +#else +#error "Unsupported architecture for stack walker" +#endif return 0; return ret; } @@ -121,7 +127,7 @@ def signal_ignore(signal, frame): bpf_probe_read(&key.target, sizeof(key.target), p->comm); bpf_get_current_comm(&key.waker, sizeof(key.waker)); - bp = ctx->bp; + bp = PT_REGS_FP(ctx); // unrolled loop (MAXDEPTH): if (!(key.ret[depth++] = get_frame(&bp))) goto out;