Re: [PATCH v7] perf: Sharing PMU counters across compatible events

From: Song Liu
Date: Wed Dec 04 2019 - 17:18:58 EST




> On Nov 28, 2019, at 12:30 AM, Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> On Fri, Nov 15, 2019 at 03:55:04PM -0800, Song Liu wrote:
>
> SNIP
>
>> add_event_to_ctx(event, ctx);
>> }
>> @@ -2745,21 +2998,26 @@ static void __perf_event_enable(struct perf_event *event,
>> {
>> struct perf_event *leader = event->group_leader;
>> struct perf_event_context *task_ctx;
>> + int was_active;
>> + int event_type;
>>
>> if (event->state >= PERF_EVENT_STATE_INACTIVE ||
>> event->state <= PERF_EVENT_STATE_ERROR)
>> return;
>>
>> + event_type = perf_event_can_share(event) ? EVENT_ALL : EVENT_TIME;
>> + was_active = ctx->is_active;
>> if (ctx->is_active)
>> - ctx_sched_out(ctx, cpuctx, EVENT_TIME);
>> + ctx_sched_out(ctx, cpuctx, event_type);
>
> you're scheduling everything out in here, so cpuctx->task_ctx
> will become NULL and trigger the check below

Good point!

>
> I dont think you need to do it here, ctx_resched will do that
> for you later, this here is just to keep the time updated

We will need to schedule out all events for perf_event_setup_dup()
though. Let me try to move perf_event_setup_dup() to ctx_resched().

Thanks,
Song