Re: [RFC PATCH] perf_counter: dynamically allocate tasks'perf_counter_context struct

From: Ingo Molnar
Date: Fri May 22 2009 - 15:18:44 EST



* Paul Mackerras <paulus@xxxxxxxxx> wrote:

> Ingo Molnar writes:
>
> > * Paul Mackerras <paulus@xxxxxxxxx> wrote:
> >
> > > This replaces the struct perf_counter_context in the task_struct
> > > with a pointer to a dynamically allocated perf_counter_context
> > > struct. The main reason for doing is this is to allow us to
> > > transfer a perf_counter_context from one task to another when we
> > > do lazy PMU switching in a later patch.
> >
> > Hm, i'm not sure how far this gets us towards lazy PMU switching.
> >
> > In fact i'd say that the term "lazy PMU switching" is probably
> > misleading, we should use: "equivalent PMU context switching" or
> > instead.
>
> Yes, that's what I mean.
>
> As you say, we need to be able to detect when two tasks have
> equivalent contexts - that is, when their counters are all
> inherited from a common ancestor. My idea is that in that
> situation we simply swap the contexts: move the context of the
> outgoing task onto the incoming task, and give the incoming task's
> context to the outgoing task. With my patch, that involves simply
> swapping the pointers over and adjusting the task pointers in the
> two contexts.
>
> That means that all the counters get transferred over to the
> incoming task, so there is nothing in the PMU or the arch code
> that needs to changed or adjusted. The outgoing task still has a
> perfectly valid context, so it doesn't matter if it migrates to
> another CPU. The nice thing is that there is nothing special or
> unusual about the state after we have swapped the contexts -
> nothing that needs to be remembered or undone later.

Yeah, agreed - your scheme is simpler than the scheme i thought of!

Ingo
--
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/