samples/bpf: tracex4: Fix failed to create kretprobe 'kmem_cache_alloc_node+0x0'

JIRA: https://issues.redhat.com/browse/RHEL-63880

commit d205d4af3a5ee840edecfa5f6b389d7d03b0786d
Author: Rong Tao <rongtao@cestc.cn>
Date:   Tue Aug 27 12:30:30 2024 +0800

    samples/bpf: tracex4: Fix failed to create kretprobe 'kmem_cache_alloc_node+0x0'

    commit 7bd230a26648 ("mm/slab: enable slab allocation tagging for kmalloc
    and friends") [1] swap kmem_cache_alloc_node() to
    kmem_cache_alloc_node_noprof().

        linux/samples/bpf$ sudo ./tracex4
        libbpf: prog 'bpf_prog2': failed to create kretprobe
        'kmem_cache_alloc_node+0x0' perf event: No such file or directory
        ERROR: bpf_program__attach failed

    Signed-off-by: Rong Tao <rongtao@cestc.cn>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: 7bd230a266
    Link: https://lore.kernel.org/bpf/tencent_34E5BCCAC5ABF3E81222AD81B1D05F16DE06@qq.com

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
This commit is contained in:
Jerome Marchand 2024-12-18 15:33:15 +01:00
parent 3cd975dd6f
commit b47de658d9
1 changed files with 2 additions and 2 deletions

View File

@ -33,13 +33,13 @@ int bpf_prog1(struct pt_regs *ctx)
return 0;
}
SEC("kretprobe/kmem_cache_alloc_node")
SEC("kretprobe/kmem_cache_alloc_node_noprof")
int bpf_prog2(struct pt_regs *ctx)
{
long ptr = PT_REGS_RC(ctx);
long ip = 0;
/* get ip address of kmem_cache_alloc_node() caller */
/* get ip address of kmem_cache_alloc_node_noprof() caller */
BPF_KRETPROBE_READ_RET_IP(ip, ctx);
struct pair v = {