Re: [PATCH -tip] x86,perf: P4 PMU -- protect sensible proceduresfrom preemption

From: Cyrill Gorcunov
Date: Wed May 05 2010 - 13:42:53 EST


On Wed, May 05, 2010 at 06:57:34PM +0200, Frederic Weisbecker wrote:
...
> > @@ -741,7 +743,7 @@ static int p4_pmu_schedule_events(struct
> > {
> > unsigned long used_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
> > unsigned long escr_mask[BITS_TO_LONGS(ARCH_P4_TOTAL_ESCR)];
> > - int cpu = raw_smp_processor_id();
> > + int cpu = get_cpu();
> > struct hw_perf_event *hwc;
> > struct p4_event_bind *bind;
> > unsigned int i, thread, num;
> > @@ -777,6 +779,7 @@ reserve:
> > }
> >
> > done:
> > + put_cpu();
> > return num ? -ENOSPC : 0;
> > }
>
> That's no big deal. But I think the schedule_events() is called on
> pmu::enable() time, when preemption is already disabled.
>

We'll be on a safe side using get/put_cpu here (ie in case
if something get changed one day).

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