Re: [RFC PATCH 1/4] perf: Starter and stopper events

From: Lin Ming
Date: Tue Mar 15 2011 - 10:36:23 EST


On Tue, Mar 15, 2011 at 3:18 AM, Frederic Weisbecker <fweisbec@xxxxxxxxx> wrote:

>
> +static void perf_event_pause_resume(struct perf_event *event, int nmi,
> +                                   struct perf_sample_data *data,
> +                                   struct pt_regs *regs)
> +{
> +       struct perf_event *iter;
> +       unsigned long flags;
> +
> +       /*
> +        * Ensure the targets can't be sched in/out concurrently.
> +        * Disabling irqs is sufficient for that because starters/stoppers
> +        * are on the same cpu/task.
> +        */
> +       local_irq_save(flags);

Could you explain this more detail?

> +
> +
> +       /* Prevent the targets from being removed under us. */
> +       rcu_read_lock();
> +
> +       list_for_each_entry_rcu(iter, &event->starter_list, starter_entry) {
> +               /*
> +                * There is a small race window here, between the state
> +                * gets set to active and the event is actually ->add().
> +                * We need to find a way to ensure the starter/stopper
> +                * can't trigger in between.

Can we set the state to active after the event is actually ->add()?

> +                */
> +               if (iter->state == PERF_EVENT_STATE_ACTIVE) {
> +                       if (iter->paused) {
> +                               iter->pmu->start(iter, PERF_EF_RELOAD);
> +                               iter->paused = 0;
> +                       }
> +               }
> +       }
> +

Thanks,
Lin Ming
--
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/