lkml.org 
[lkml]   [2020]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v12] perf: Sharing PMU counters across compatible events
Date


> On Apr 20, 2020, at 4:04 PM, Peter Zijlstra <peterz@infradead.org> wrote:
>>
>> static inline u64 perf_event_count(struct perf_event *event)
>> {
>> - return local64_read(&event->count) + atomic64_read(&event->child_count);
>> + u64 count;
>> +
>> + if (likely(event->dup_master != event))
>> + count = local64_read(&event->count);
>> + else
>> + count = local64_read(&event->master_count);
>> +
>> + return count + atomic64_read(&event->child_count);
>> }
>
> So lsat time I said something about SMP ordering here. Where did that
> go?

I am not quite sure about this one. I guess the following is sufficient.
Could you please help me double check?

Thanks,
Song


static inline u64 perf_event_count(struct perf_event *event)
{
struct perf_event *master;
u64 count;

again:
master = READ_ONCE(event->dup_master);
if (master == EVENT_TOMBSTONE)
goto again;

if (likely(master != event))
count = local64_read(&event->count);
else
count = local64_read(&event->master_count);

return count + atomic64_read(&event->child_count);
}

\
 
 \ /
  Last update: 2020-04-29 22:45    [W:0.189 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site