lkml.org 
[lkml]   [2009]   [Apr]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/9] perf_counter: fix update_userpage()
From
Date
On Thu, 2009-04-02 at 20:58 +1100, Paul Mackerras wrote:
> Peter Zijlstra writes:
>
> > > Good point. This should work, though:
> > >
> > > do {
> > > seq = pc->lock;
> > > barrier();
> > > value = read_pmc(pc->index) + pc->offset;
> > > barrier();
> > > } while (pc->lock != seq);
> > > return value;
> >
> > I don't think you need the first barrier(), all you need to avoid is it
> > reusing the first pc->lock read, so one should suffice.
>
> I need it to make sure that the compiler doesn't put the load of
> pc->index or pc->offset before the first load of pc->lock. The second
> barrier is needed to make sure the compiler puts the second load of
> pc->lock after the loads of pc->index and pc->offset. So I think I do
> need to barrier()s (but only compiler barriers, not cpu memory
> barriers).

Ah, you're right indeed.

> > Also, you need to handle the !pc->index case.
>
> Hmmm, yeah. I claim that read_pmc(0) always returns 0. :)

Hehe :-)

Ok, updated that patch.



\
 
 \ /
  Last update: 2009-04-02 12:39    [W:0.066 / U:0.796 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site