Re: [RFC][PATCH] perf: Rewrite core context handling
From: Alexey Budankov
Date: Wed Oct 17 2018 - 11:59:20 EST
Hi Alex,
On 17.10.2018 18:01, Alexander Shishkin wrote:
> Alexey Budankov <alexey.budankov@xxxxxxxxxxxxxxx> writes:
>
>> Since it reduces to single cpu context (and single task context) at all times,
>> ideally, it would probably be coded as simple as this:
>>
>> perf_rotate_context()
>> {
>> cpu = this_cpu_ptr(&cpu_context)
>> for_every_pmu(pmu, cpu)
>> for_every_event_ctx(event_ctx, pmu)
>> rotate(event_ctx, pmu)
>> }
>>
>> so rotate(event_ctx, pmu) would operate on common events objects semantics
>> and memory layout, and PMU specific code handle SW/HW programming differences.
>
> Ok, what's event_ctx and how does that simplify things?
Currently, rotate_ctx() is called twice from perf_rotate_context()
for cpu and task contexts:
struct perf_cpu_context {
struct perf_event_context ctx;
struct perf_event_context *task_ctx;
If it would be implemented in a loop that could, probably, reduce
complexity of perf_rotate_context(), partly pushing the complexity
*down* to SW/HW pmu specific code and perf_rotate_context() would
become scalable for any number of contexts.
Thanks,
Alexey
>
> Regards,
> --
> Alex
>