Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1695534rwd; Fri, 9 Jun 2023 00:21:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5K7Bc+44qfqIOPbDCg33GFFTZKXih+P3ZWP5KtIb9iLTdZNrUeJ5ri6v4pxgyZQt20eBy7 X-Received: by 2002:a92:c08f:0:b0:335:56cb:a3a with SMTP id h15-20020a92c08f000000b0033556cb0a3amr865519ile.16.1686295296919; Fri, 09 Jun 2023 00:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686295296; cv=none; d=google.com; s=arc-20160816; b=CK7rEoKzyYle+gv1cPFM9aJgOJ2gpUAOF42xwKSi7eFAVjkFtR4eEIJY6Y8Ywe0viq Ijb94ZrnZc2iPmyBebWLrrECdfqKy9XEVUSvVFgG06UmGr0f48sPcs4r7n0aQC2x1NvC at0WD7yXz55vPAwPvaofYFRw0A6ellWtgpf4NTCfP7a+VQO7kSol/l/TjifZ5agPxdDQ EURH6mAmk5+4NXh4MpP4HZf0gO2RPowYDECduTwzMOuOq+Kw6tvQJN66l/29EqHMPA6q RZk95nMSgp3VZfwnMd0R8hYS3y8l0BPbElE8vzx3Qmgpvs7fbvnv4CynbEtzvKvau5Xo vRFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=+PzUjqu2cUUp+Yrh+5Y9WC1qpO3zOvIfzLutphw+z9s=; b=lh/JVVGLFsT36McC9rUHiFF52gKaLSeu5Trcm0s69hpWYA+c6lIHXrbpAgHj0OVr/D jy3yzmf9trRcdywBOUCV0NVCFsfodqh1VRDOnJt35/nS/bT28zGHB6gD+UNOenCkKjl0 l26OmZ5is7oGMA9vp1vwl8ZynxNieb96pKXN8f4nqaTcDv9g99xHh4/YX02t8KrJnvPu gxL5JsLHveJDMCpeU5zgWogKS6XIC4szQbdHLZZ+fZ1A9IGTd8ofzZk2Mk2cZqXG+FyS LI1mtPUXMGWyKvzf9Wm0g/toEEwuItru5uKym7ow2NlClWwuuB5qd7ozHC3YtZ3rFmZC dwuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 4-20020a630704000000b005347fcae977si2243968pgh.832.2023.06.09.00.21.21; Fri, 09 Jun 2023 00:21:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237687AbjFIHO0 (ORCPT + 99 others); Fri, 9 Jun 2023 03:14:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbjFIHOY (ORCPT ); Fri, 9 Jun 2023 03:14:24 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 647F2272A; Fri, 9 Jun 2023 00:14:23 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 43818AB6; Fri, 9 Jun 2023 00:15:08 -0700 (PDT) Received: from [10.163.44.201] (unknown [10.163.44.201]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B954E3F71E; Fri, 9 Jun 2023 00:14:17 -0700 (PDT) Message-ID: <584cb976-4e21-5dc2-bce2-cd6c3b5d1613@arm.com> Date: Fri, 9 Jun 2023 12:44:12 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH V11 05/10] arm64/perf: Add branch stack support in ARMV8 PMU To: Suzuki K Poulose , Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, Mark Brown , James Clark , Rob Herring , Marc Zyngier , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , linux-perf-users@vger.kernel.org References: <20230531040428.501523-1-anshuman.khandual@arm.com> <20230531040428.501523-6-anshuman.khandual@arm.com> <290b577c-4740-d2e2-d236-c8bbe2f907b9@arm.com> Content-Language: en-US From: Anshuman Khandual In-Reply-To: <290b577c-4740-d2e2-d236-c8bbe2f907b9@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [..] 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; }