Re: [RFC/PATCH 17/38] perf tools: Maintain map groups list in a leader thread

From: Jiri Olsa
Date: Mon Oct 12 2015 - 08:43:44 EST


On Fri, Oct 09, 2015 at 03:58:49PM +0900, Namhyung Kim wrote:

SNIP

>
>
> >
> > some comment on how we treat map groups in general (for fork/clone/exit)
> > would be awesome ;-)
>
> I admit that this code is subtle and confusing.. How about this?
>
>
> Managing map groups is subtle in that we basically want to share a map
> groups between threads in a process. When a new process is created
> (forked), the child clones (current) map groups from the parent. But
> if a new thread is called it only gets a reference of the leader's mg.
>
> Complication comes from the exec as we also want to keep the history
> of a thread's execution, so the map groups are now managed by mg_list.
> This mg_list is maintained by leader threads only, and non-leader
> threads have a reference a mg at the time in the mg_list. It uses a
> timestamp at the event to find out the correct mg in the mg_list.
>
> One corner case is when exec is called from a non-leader thread. We
> want to add a new mg to the mg_list in the thread. But it doesn't
> have a mg_list since it was not a leader. So it sets up a mg_list and
> insert a cloned mg from the old leader. Now it can handle exec as
> usual - create a new mg and insert it to the mg_list.

seems ok, thanks

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/