Re: [PATCH bpf-next v2 1/2] bpf, x64: Fix tailcall hierarchy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 22, 2024 at 12:53 AM Leon Hwang <hffilwlqm@xxxxxxxxx> wrote:
>
> +DEFINE_PER_CPU(u32, bpf_tail_call_cnt);
> +
> +static __used void bpf_tail_call_cnt_prepare(void)
> +{
> +       /* The following asm equals to
> +        *
> +        * u32 *tcc_ptr = this_cpu_ptr(&bpf_tail_call_cnt);
> +        *
> +        * *tcc_ptr = 0;
> +        *
> +        * This asm must uses %rax only.
> +        */
> +
> +       asm volatile (
> +            "addq " __percpu_arg(0) ", %1\n\t"
> +            "movl $0, (%%rax)\n\t"

This looks wrong.
Should probably be "movl $0, (%1)" ?

> +            :
> +            : "m" (this_cpu_off), "r" (&bpf_tail_call_cnt)
> +       );
> +}
> +
> +static __used u32 bpf_tail_call_cnt_fetch_and_inc(void)
> +{
> +       u32 tail_call_cnt;
> +
> +       /* The following asm equals to
> +        *
> +        * u32 *tcc_ptr = this_cpu_ptr(&bpf_tail_call_cnt);
> +        *
> +        * (*tcc_ptr)++;
> +        * tail_call_cnt = *tcc_ptr;
> +        * tail_call_cnt--;
> +        *
> +        * This asm must uses %rax only.
> +        */
> +
> +       asm volatile (
> +            "addq " __percpu_arg(1) ", %2\n\t"
> +            "incl (%%rax)\n\t"
> +            "movl (%%rax), %0\n\t"

and %2 here instead of rax ?

> +            "decl %0\n\t"
> +            : "=r" (tail_call_cnt)
> +            : "m" (this_cpu_off), "r" (&bpf_tail_call_cnt)
> +       );
> +





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux