On Fri, 2024-10-04 at 12:33 -0700, Alexei Starovoitov wrote: [...] > btw the whole thing can be done with a single atomic64_t: > - set it to 1 at the start then > > - prog_fd_array_get_ptr() will do > atomic64_inc_not_zero > > - prog_fd_array_put_ptr() will do > atomic64_add_unless(,-1, 1) > > - freplace attach will do > cmpxchg(,1,0) > > so 1 - initial state > 2,3,.. - prog in prog_array > 0 - prog was extended. > > If == 0 -> cannot add to prog_array > if > 1 -> cannot freplace. I think this should work, because we no longer need to jungle two values. I kinda like it. [...]