On Sun, 2024-09-29 at 21:27 +0800, Leon Hwang wrote: > Previously, I fixed a tailcall infinite loop issue caused by trampoline[0]. > > At this time, I fix a tailcall infinite loop issue caused by tailcall and > freplace combination by preventing updating extended prog to prog_array map > and preventing extending tail callee prog with freplace: > > 1. If a prog or its subprog has been extended by freplace prog, the prog > can not be updated to prog_array map. > 2. If a prog has been updated to prog_array map, it or its subprog can not > be extended by freplace prog. So, once this series is applied we essentially have: - three variables: - tgt_prog->aux->is_extended - tgt_prog->aux->prog_array_member_cnt - trampoline->extension_prog - four operations: - link/attach extension program 'prog' using trampoline 'tr' - unlink/detach extension program 'prog' using trampoline 'tr' - put program 'tgt_prog' into prog array - remove program 'tgt_prog' from prog array And above four operations have the following pseudo-code with regards to update of the variables: - link/attach extension program 'prog' using trampoline 'tr': with lock(tgt_prog->ext_mutex): if tgt_prog->aux->prog_array_member_cnt: return error if tr->extension_prog: return error tr->extension_prog = prog tgt_prog->is_extended = true - unlink/detach extension program 'prog' using trampoline 'tr': with lock(tgt_prog->ext_mutex): tr->extension_prog = NULL tgt_prog->is_extended = false - put program 'tgt_prog' into prog array: with lock(tgt_prog->ext_mutex): if tgt_prog->aux->is_extended: return error tgt_prog->aux->prog_array_member_cnt++ - remove program 'tgt_prog' from prog array: with lock(tgt_prog->ext_mutex): tgt_prog->aux->prog_array_member_cnt-- I think this is correct, would be great if someone with more concurrency related experience would take a look. [...]