[DTrace-devel] [PATCH 2/3] Add 'lock xadd' BPF instruction macro

Eugene Loh eugene.loh at oracle.com
Fri Sep 4 12:31:38 PDT 2020


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>

On 08/27/2020 11:54 AM, Kris Van Hees wrote:
> BPF implements an exclusive-add instruction to provide an atomic form
> for:
>
> 	*(dst + offset) += (src)
>
> This instruction was missing from the bpf_asm.h include file.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
>   include/bpf_asm.h | 9 +++++++++
>   1 file changed, 9 insertions(+)
>
> diff --git a/include/bpf_asm.h b/include/bpf_asm.h
> index 59484697..cac60c24 100644
> --- a/include/bpf_asm.h
> +++ b/include/bpf_asm.h
> @@ -91,6 +91,15 @@
>   		.imm = 0						\
>   	})
>   
> +#define BPF_XADD_REG(sz, dst, ofs, src)					\
> +	((struct bpf_insn) {						\
> +		.code = BPF_STX | BPF_XADD | (sz),			\
> +		.dst_reg = (dst),					\
> +		.src_reg = (src),					\
> +		.off = (ofs),						\
> +		.imm = 0						\
> +	})
> +
>   #define BPF_STORE_IMM(sz, dst, ofs, val)				\
>   	((struct bpf_insn) {						\
>   		.code = BPF_ST | BPF_MEM | (sz),			\




More information about the DTrace-devel mailing list