Re: [PATCH bpf-next v2 01/11] LoongArch: BPF: Fix tail call count pointer offset for arena programs
From: George Guo
Date: Tue Jul 07 2026 - 05:49:24 EST
Hi Tiezhu,
Thanks for reviewing!
> This introduces a runtime helper to dynamically calculate the stack
> offset. If another optional slot is introduced in the future, this
> helper will need further adjustments.
Fair -- that's exactly the tradeoff. This patch was written to be the
minimal, obviously-correct fix on top of the existing layout (arena slot
above tcc/tcc_ptr) so it could go to the bpf tree as a standalone,
backportable fix. It does mean any future optional slot needs another
"if (...)" in the helper, as you say.
> Please see the following simple and long-term solution, just move
> the arena slot below TCC context slots, this ensures a constant
> offset, reducing complex runtime calculations and eliminating extra
> instructions.
>
> LoongArch: BPF: Optimize redundant TCC loads in epilogue
> https://lore.kernel.org/loongarch/20260630022705.11536-2-yangtiezhu@xxxxxxxxxxx/
>
> LoongArch: BPF: Move arena register slot below TCC context
> https://lore.kernel.org/loongarch/20260630022705.11536-3-yangtiezhu@xxxxxxxxxxx/
I read through both -- the reordering is a nice fix: with the arena slot
moved below tcc_ptr instead of above it, tcc_ptr's offset from $fp stays
a fixed 80 regardless of arena, so the original hardcoded macro is
correct again everywhere and the runtime branch goes away entirely.
Agreed that's the better long-term shape.
One thing to work out: this series (patch 5, exceptions/bpf_throw) also
needs an optional extra slot for exception programs, using the same
mechanism as arena (it currently piggybacks on the same
`ctx->arena_vm_start || is_exception_prog` check your patch 2/4 would
replace). If your reordering lands, I'd extend it the same way --
moving the exception-program slot below tcc_ptr too, rather than adding
a runtime check back in.
Where does your series stand? I'd rather rebase this patch series on
top of your fixed-offset approach once it's in bpf-next than have both
land and immediately conflict. Let me know what's the best way to
sequence these.
Thanks,
George