Messages in this thread | | | Date | Fri, 9 Jun 2023 12:44:12 +0530 | Subject | Re: [PATCH V11 05/10] arm64/perf: Add branch stack support in ARMV8 PMU | From | Anshuman Khandual <> |
| |
[..]
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; }
| |