[DTrace-devel] [PATCH 3/8] bpf: introduce dt_bpf_prog_attach()

Eugene Loh eugene.loh at oracle.com
Thu Apr 4 19:53:29 UTC 2024


Here is what I see on a couple of VMs I run on:

     grep attach_btf_id /usr/include/linux/bpf.h

     x86 OL7 UEK6 5.4.17-2136.328.3.el7uek.x86_64    (nil)
     arm OL7 UEK6 5.4.17-2136.328.3.el7uek.aarch64   (nil)
     x86 OL8 UEK6 5.4.17-2136.328.3.el8uek.x86_64    __u32 attach_btf_id;
     arm OL8 UEK6 5.4.17-2136.328.3.el8uek.aarch64   __u32 attach_btf_id;
     x86 OL8 UEK7 5.15.0-102.110.4.el8uek.x86_64     __u32 attach_btf_id;
     arm OL8 UEK7 5.15.0-102.110.4.el8uek.aarch64    __u32 attach_btf_id;
     x86 OL9 UEK7 5.15.0-203.146.5.1.el9uek.x86_64   __u32 attach_btf_id;
     arm OL9 UEK7 5.15.0-203.146.5.1.el9uek.aarch64  __u32 attach_btf_id;

That is, the OL7 VMs do not seem to know about attach_bpf_id.

Also...

On 4/3/24 11:26, Kris Van Hees via DTrace-devel wrote:
> diff --git a/libdtrace/dt_bpf.c b/libdtrace/dt_bpf.c
> index 56b342e8..14ef12fc 100644
> --- a/libdtrace/dt_bpf.c
> +++ b/libdtrace/dt_bpf.c
> @@ -73,18 +73,22 @@ dt_bpf_lockmem_error(dtrace_hdl_t *dtp, const char *msg)
>   }
>   
>   /*
> - * Load a BPF program into the kernel.
> + * Load a BPF program into the kernel (and attach it to an object by BTF id if
> + * specified).
>    */

Omit the parentheses and the "if specified."  For this function, the 
btf_id is specified.  How about,
"Load a BPF program into the kernel, attaching it to an object by BTF id."

>   int
> -dt_bpf_prog_load(enum bpf_prog_type prog_type, const dtrace_difo_t *dp,
> -		     uint32_t log_level, char *log_buf, size_t log_buf_sz)
> +dt_bpf_prog_attach(enum bpf_prog_type ptype, enum bpf_attach_type atype,
> +		   uint32_t btf_id, const dtrace_difo_t *dp, uint32_t log_level,
> +		   char *log_buf, size_t log_buf_sz)
>   {
>   	union bpf_attr	attr;
>   	int		fd;
>   	int		i = 0;
>   
>   	memset(&attr, 0, sizeof(attr));
> -	attr.prog_type = prog_type;
> +	attr.prog_type = ptype;
> +	attr.expected_attach_type = atype;
> +	attr.attach_btf_id = btf_id;
>   	attr.insn_cnt = dp->dtdo_len;
>   	attr.insns = (uint64_t)dp->dtdo_buf;
>   	attr.license = (uint64_t)BPF_CG_LICENSE;
> @@ -103,6 +107,17 @@ dt_bpf_prog_load(enum bpf_prog_type prog_type, const dtrace_difo_t *dp,
>   	return fd;
>   }
>   
> +/*
> + * Load a BPF program into the kernel (and attach it to an object by BTF id if
> + * specified).
> + */

Omit the parenthetical remark.  This function does not allow btf id.

> +int
> +dt_bpf_prog_load(enum bpf_prog_type ptype, const dtrace_difo_t *dp,
> +		 uint32_t log_lvl, char *log_buf, size_t log_bufsz)
> +{
> +	return dt_bpf_prog_attach(ptype, 0, 0, dp, log_lvl, log_buf, log_bufsz);
> +}



More information about the DTrace-devel mailing list