Re: [RFC PATCH 2/3 v3] perf: Implement Nehalem uncore pmu

From: Peter Zijlstra
Date: Thu Dec 09 2010 - 14:17:30 EST


On Tue, 2010-12-07 at 14:15 +0800, Lin Ming wrote:
> On Thu, 2010-12-02 at 13:20 +0800, Lin Ming wrote:
> > +
> > +static int
> > +uncore_perf_event_set_period(struct perf_event *event)
> > +{
> > + struct hw_perf_event *hwc = &event->hw;
> > + s64 left = local64_read(&hwc->period_left);
> > + s64 period = hwc->sample_period;
> > + u64 max_period = (1ULL << UNCORE_CNTVAL_BITS) - 1;
> > + int ret = 0, idx = hwc->idx;
> > +
> > + /*
> > + * If we are way outside a reasonable range then just skip forward:
> > + */
> > + if (unlikely(left <= -period)) {
> > + left = period;
> > + local64_set(&hwc->period_left, left);
> > + hwc->last_period = period;
> > + ret = 1;
> > + }
> > +
> > + if (unlikely(left <= 0)) {
> > + left += period;
> > + local64_set(&hwc->period_left, left);
> > + hwc->last_period = period;
> > + ret = 1;
> > + }
> > +
> > + if (left > max_period)
> > + left = max_period;
> > +
> > + /*
> > + * The hw event starts counting from this event offset,
> > + * mark it to be able to extra future deltas:
> > + */
> > + local64_set(&hwc->prev_count, (u64)-left);
>
> All uncore pmu interrupts from a socket are routed to one of the four
> cores, so local64_set seems not correct here.
>
> But hwc->prev_count is defined as local64_t, any idea how to set it
> correctly?
>
> Or is it OK if local64_set is always executed in the same cpu?

Yes, the local_t bits work as expected when its always accessed by the
same cpu.
--
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/