RE: [PATCH] oprofile: add SMP barriers for hrtimer hotplug code

Will Deacon
2011-01-31T17:24:43Z

Hi Santosh,

On Mon, 2011-01-31 at 15:41 +0000, Santosh Shilimkar wrote:
> > diff --git a/drivers/oprofile/timer_int.c
> > b/drivers/oprofile/timer_int.c
> > index 0107251..38c1e1b 100644
> > --- a/drivers/oprofile/timer_int.c
> > +++ b/drivers/oprofile/timer_int.c
> > @@ -48,6 +48,7 @@ static int oprofile_hrtimer_start(void)
> > {
> > get_online_cpus();
> > ctr_running = 1;
> > + smp_mb();
> Is smp_wmb() more appropriate ?
>
We could use smp_wmb, but then we have to add smp_rmb before
reading ctr_running too.

> > on_each_cpu(__oprofile_hrtimer_start, NULL, 1);
> > put_online_cpus();
> > return 0;
> > @@ -70,6 +71,7 @@ static void oprofile_hrtimer_stop(void)
> > get_online_cpus();
> > for_each_online_cpu(cpu)
> > __oprofile_hrtimer_stop(cpu);
> > + smp_mb();
> > ctr_running = 0;
> > put_online_cpus();
> > }

I misread this code: it actually all executes on the current CPU so we
don't need the barrier. The control hazard is enough.

> > --
> Otherwise patch is fine.
> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

Ok, thanks. I will post a v2 anyway with the second barrier removed.
Feel free to re-ack!

Will