Re: [PATCH 4/9] perf: Generic intel uncore support

Anshuman Khandual
2012-05-11T06:31:15Z

On Wednesday 02 May 2012 07:37 AM, Yan, Zheng wrote:

> +static int __cpuinit uncore_cpu_prepare(int cpu)
> +{
> + struct intel_uncore_type *type;
> + struct intel_uncore_pmu *pmu;
> + struct intel_uncore_box *exist, *box;
> + int i, j, phyid;
> +
> + phyid = topology_physical_package_id(cpu);
> +
> + /* allocate the box data structure */
> + for (i = 0; msr_uncores[i]; i++) {
> + type = msr_uncores[i];
> + for (j = 0; j < type->num_boxes; j++) {
> + exist = NULL;
> + pmu = &type->pmus[j];
> +
> + if (pmu->func_id < 0)
> + pmu->func_id = j;
> + exist = uncore_pmu_find_box(pmu, phyid);
> + if (exist)
> + exist->refcnt++;
> + if (exist)
> + continue;

May be a redundant condition checking ^ ?

> +
> + box = uncore_alloc_box(cpu);
> + if (!box)
> + return -ENOMEM;
> +
> + box->pmu = pmu;
> + box->phy_id = phyid;
> + uncore_pmu_add_box(pmu, box);
> + }
> + }
> + return 0;