lkml.org 
[lkml]   [2023]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH V11 05/10] arm64/perf: Add branch stack support in ARMV8 PMU
From
[..]

On 6/8/23 15:43, Suzuki K Poulose wrote:
>>> | static int armv8pmu_probe_pmu(struct arm_pmu *cpu_pmu)
>>> | {
>>> |         struct armv8pmu_probe_info probe = {
>>> |                 .pmu = cpu_pmu,
>>> |                 .present = false,
>>> |         };
>>> |         int ret;
>>> |
>>> |         ret = smp_call_function_any(&cpu_pmu->supported_cpus,
>>> |                                     __armv8pmu_probe_pmu,
>>> |                                     &probe, 1);
>>> |         if (ret)
>>> |                 return ret;
>>> |         if (!probe.present)
>>> |                 return -ENODEV;
>>> |
>>> |           if (!arm_pmu_branch_stack_supported(cpu_pmu))
>>> |             return 0;
>>> |
>>> |         ret = armv8pmu_private_alloc(cpu_pmu);
>>> |         if (ret)
>>> |         return ret;
>>> |       
>>> |          ret = branch_records_alloc(cpu_pmu);
>>> |          if (ret)
>>> |          armv8pmu_private_free(cpu_pmu);
>>> |       
>>> |        return ret;
>>> | }


After splitting the task ctx cache management from pmu private data
management, the above function will look something like this taking
care of all error path freeing as well.

static int armv8pmu_probe_pmu(struct arm_pmu *cpu_pmu)
{
struct armv8pmu_probe_info probe = {
.pmu = cpu_pmu,
.present = false,
};
int ret;

ret = armv8pmu_private_alloc(cpu_pmu);
if (ret)
return ret;

ret = smp_call_function_any(&cpu_pmu->supported_cpus,
__armv8pmu_probe_pmu,
&probe, 1);
if (ret)
goto probe_err;

if (!probe.present) {
ret = -ENODEV;
goto probe_err;
}

if (cpu_pmu->has_branch_stack) {
ret = armv8pmu_task_ctx_cache_alloc(cpu_pmu);
if (ret)
goto probe_err;

ret = branch_records_alloc(cpu_pmu);
if (ret) {
armv8pmu_task_ctx_cache_free(cpu_pmu);
goto probe_err;
}
return 0;
}
armv8pmu_private_free(cpu_pmu);
return 0;

probe_err:
armv8pmu_private_free(cpu_pmu);
return ret;
}

\
 
 \ /
  Last update: 2023-06-09 09:15    [W:0.125 / U:0.684 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site