> On Thu, Dec 07, 2023 at 11:07:38AM +0100, Jiri Olsa wrote: > > + if (tgt_prog) { > > + /* Bookkeeping for managing the prog attachment chain. If it's a > > + * tracing program, bump the level, otherwise carry it on. > > + */ > > + if (prog->type == BPF_PROG_TYPE_TRACING) > > + prog->aux->attach_depth = tgt_prog->aux->attach_depth + 1; > > + else > > + prog->aux->attach_depth = tgt_prog->aux->attach_depth; > > + } > > I'm not sure why we need to keep the attach_depth for all program types, > I might be missing something but could we perhaps just use flag related > just to tracing programs like in patch below Originally I was trying to make the change somewhat generic, so that the same approach could be used e.g. for extensions if needed (say, instead of preventing extending fentry/fexit). But since we reduce the scope anyway, I agree we can simply use a boolean flag. It still has to be set for the target prog if it's fentry/fexit and already attached somewhere, but otherwise would be similar to your proposal. Let me prepare the new version.