lkml.org 
[lkml]   [2018]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/1] perf: Sharing PMU counters across compatible events
On Tue, Sep 11, 2018 at 01:29:32PM +0000, Song Liu wrote:

SNIP

> >>>
> >>> jirka
> >>
> >> I am not sure I am following. The pmu is disabled when we call
> >> event_pmu_add(). Why do we need to read before calling pmu->add()?
> >> And this is the first added dup event for this master, so we don't
> >> need to worry about others.
> >>
> >> Does this make sense?
> >
> > I was just thinking since the pmu is disable we could
> > we don't need to read the event on 2 places.. it's almost
> > identic code
>
> How about something like:
>
>
> +/* PMU sharing aware version of event->pmu->add() */
> +static int event_pmu_add(struct perf_event *event,
> + struct perf_event_context *ctx)
> +{
> + struct perf_event_dup *dup;
> + int ret;
> +
> + /* no sharing, just do event->pmu->add() */
> + if (event->dup_id == -1)
> + return event->pmu->add(event, PERF_EF_START);
> +
> + dup = &ctx->dup_events[event->dup_id];
> +
> + if (dup->active_event_count = 0) {
> + /* try add master */
> + ret = event->pmu->add(dup->master, PERF_EF_START);
> + if (ret)
> + return ret;
> + }
> +
> + dup->active_event_count++;
> + event->pmu->read(dup->master);
> + event->dup_base_count = dup_read_count(dup);
> + event->dup_base_child_count = dup_read_child_count(dup);
> +
> + return 0;
> +}

yep, seems ok

jirka

\
 
 \ /
  Last update: 2018-09-23 23:45    [W:0.063 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site