Re: [RFC][PATCH 8/8] perf: Rework the PMU methods

From: Peter Zijlstra
Date: Fri Jun 18 2010 - 03:15:52 EST


On Fri, 2010-06-18 at 06:21 +0200, Frederic Weisbecker wrote:
> On Wed, Jun 16, 2010 at 06:00:35PM +0200, Peter Zijlstra wrote:
> > -static void x86_pmu_stop(struct perf_event *event)
> > +static void x86_pmu_stop(struct perf_event *event, int flags)
> > {
> > - struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
> > - struct hw_perf_event *hwc = &event->hw;
> > - int idx = hwc->idx;
> > -
> > if (!__test_and_clear_bit(idx, cpuc->active_mask))
> > - return;
>
>
>
> Do you still need active_mask now that you have HES_STOPPED?

there still were some users, but yeah, we cuold probably clean that up,
bit since the patch is large enough as is, I didn't attempt that.

> > +static void perf_swevent_start(struct perf_event *event, int flags)
> > +{
> > + event->hw.state = 0;
> > +}
> > +
> > +static void perf_swevent_stop(struct perf_event *event, int flags)
> > {
> > + event->hw.state = 1;
> > }
>
>
> So, instead of doing this and add yet another check in the fast path,
> what about just playing with the hlist insertion and deletion?

I wanted to avoid too much trickery, first make a simple one work, then
try something fancy.

> It would be nice to have a PERF_EF_STOP as well in ->del, so that
> each pmu don't need to maintain an internal state.

You have to track it since we can stop the thing outselves without the
caller knowing.

> > }
> > #endif
> > @@ -4591,12 +4582,12 @@ static void perf_swevent_start_hrtimer(s
> > if (hwc->sample_period) {
> > u64 period;
> >
> > - if (hwc->remaining) {
> > - if (hwc->remaining < 0)
> > + if (hwc->period_left) {
> > + if (hwc->period_left < 0)
> > period = 10000;
> > else
> > - period = hwc->remaining;
> > - hwc->remaining = 0;
> > + period = hwc->period_left;
> > + hwc->period_left = 0;
>
>
>
> If remaining can be replaced by period_left, it should probably be done
> in another patch.

true.
--
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/