On Mon, Jul 7, 2025 at 12:16 PM Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> wrote: > > The other option of course is to do run time checks of > prog->aux->terminate bit and start failing things that way. > Most of the time, the branch will be untaken. It can be set to 1 when > a prog detects a fatal condition or from a watchdog (later). > cond_break, rqspinlock, iterators, bpf_loop can all be adjusted to check it. > > When I was playing with all this, this is basically what I did > (amortized or not) and I think the overhead was negligible/in range of > noise. > If a prog is hot, the line with terminate bit is almost always in > cache, and it's not a load dependency for other accesses. > If it's not hot, the cost of every other state access dominates anyway. bpf_check_timed_may_goto() can certainly check prog->aux->must_terminate. bpf_loop() can gain aux__prog and check the flag as well. if we add it in more places then we won't need fast-execute. Everything that can take a long time will be required to check that flag. I was hoping fast-execute can avoid this run-time penalty, but if it comes with extra clone (even if optional for some progs) then the amortized flag check looks much simpler.