这里需要提的一点是两种类型在同时使用时到底是如何省内存的,举个例子,subfunc1 执行 Tail Call 调用 func2,此时subfunc的栈帧已经被func2复用了,然后func2 执行 BPF to BPF Calls 调用 subfunc2,此时第三个栈帧被创建,然后执行 Tail Call 调用 func3,五个逻辑过程使用了三个栈,这就节省了内存。 然后因为...
ARG_PTR_TO_MAP_KEY就是这样的参数约束之一。这意味着传递给这个函数的寄存器类型必须是PTR_TO_STACK,它将作为‘map element key的指针’在函数内部使用。例如bpf_map_lookup_elem()的参数约束:`.ret_type = RET_PTR_TO_MAP_VALUE_OR_NULL,.arg1_type = ARG_CONST_MAP_PTR,.arg2_type = ARG_PTR_TO_M...
* * registers used to pass values to function calls are checked against * function argument constraints. * * ARG_PTR_TO_MAP_KEY is one of such argument constraints. * It means that the register type passed to this function must be * PTR_TO_STACK and it will be used inside the function...
BPF_REG_2, -4), // after this insn R2 type is PTR_TO_STACKBPF_LD_MAP_FD(BPF_REG_1, map_fd), // after this insn R1 type is CONST_PTR_TO_MAPBPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem),` ...
“Super powers have finally come to Linux” — Brendan Gregg 接下来我们来简单描述下BPF超能力的核心技能点。 BPF超能的核心技能点——BPF Hooks 第一个核心技能点是「BPF Hooks」,即BPF钩子,也就是在内核中,哪些地方可以加载BPF程序,在目前的Linux内核中已经有了近10种的钩子,如下所示: ...
subprog 里使用 tailcall 的前提:bpf: allow for tailcalls in BPF subprograms for x64 JIT[2] since v5.10 kernel。 然而,在引入 tailcall in bpf2bpf 特性时,因为代码问题从而引入了这个问题。 在v5.19 内核里,commit ff672c67ee76 ("bpf, x86: Fix tail call count offset calculation on bpf2bpf ...
system calls fentry/fexit Tracepoints network devices(tc/xdp) network routes TCP congestion algorithms sockets(data level) 从文件打开、创建TCP链接、Socket链接到发送系统消息等几乎所有的系统调用,加上用户空间的各种动态信息,都能加载BPF程序,可以说是无所不能。它们在内核中形成不同的BPF程序类型,在加载时...
“Super powers have finally come to Linux” — Brendan Gregg 接下来我们来简单描述下BPF超能力的核心技能点。 BPF超能的核心技能点——BPF Hooks 第一个核心技能点是「BPF Hooks」,即BPF钩子,也就是在内核中,哪些地方可以加载BPF程序,在目前的Linux内核中已经有了近10种的钩子,如下所示: ...
calls for PID 181 only ./funccount t:sched:sched_fork # count calls to the sched_fork tracepoint ./funccount -p 185 u:node:gc* # count all GC USDT probes in node, PID 185 ./funccount c:malloc # count all malloc() calls in libc ./funccount go:os.* # count all "os.*" ...