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) > + ); > +