Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp248240rdf; Tue, 21 Nov 2023 01:14:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IH32mSUoFcUhTQM6SiY//NCQpQk3vjx+qOu8dc+nSND7fZ3wcq8TX8loDh+o5L8pnGxx8I2 X-Received: by 2002:a9d:4b0a:0:b0:6c6:4843:2ac5 with SMTP id q10-20020a9d4b0a000000b006c648432ac5mr4986910otf.21.1700558072983; Tue, 21 Nov 2023 01:14:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700558072; cv=none; d=google.com; s=arc-20160816; b=Mu0+HSD9Nr6pHi7Fc6us1XwYYmVC/0TDfR+FyLe3dtZZwyq4HyBEiSKTRYA/0IE3ok esPSWzH55slsyq3lzD7rTSsSQb+ZzatCgjZAzJ6X3eMco3H6G/UKxffOhLW29nQANr37 NjzNlcN+Ou9dy77pbQRbTTndGdP6NH0AHgqVva+b85d7tnxh4IrrW7l9+uuWUbrrx7FR lLSIbGLelaG1H2r8MWm/YC2wflxwEjTC4f91w69KMZJCk7RhZYM77+xewoaRgN2q9EBO PaucQdZemlj4T2yQjmaycbOXc0Ta/v4vN9lcSppyJZ5jHG+QcRoCF8EyhiMSK01E0ZaS h5Pw== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=Q3aF+k7dEkmLJyaizAbEKtJZu4ruTxXVeVuz1CnP/YY=; fh=pE2uB+Pj5ycJqeAHmrQX21zOyGN5AMkM6doeLbKSOMs=; b=w8KhPparadNeZ/cjy52Se7/0HBjGSbF+biklRFZQ7FAbZ83ZVZMJ+itA4CFPKcjdsF KcPbN513mf/ecSs9PnGSi/XCJt5DYIdhqJFIdQZsIIBhIR+Q7+zK+pRSIyiD9P8mHyf8 JfsM1GjFFM0o0fM0VkzMbZdLGGuaR+4k2bCZWMcaipmzYxfiglkIhP++UL+o/8xdy0G+ g338aL+Zgy/fHKusXjKdLOdyb7g0Z9RWkErSqWWb8EgwrcTm30gh+j1EfNG1ONaPeP6X zvyrXXlskeiaB4A4ArqQa7IkHocdxtsJARTXSj9vsIn6DHOzmWLytGFw+vPQ+hihA9gL oOcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id a20-20020a634d14000000b005be1ee5ef0dsi10240532pgb.15.2023.11.21.01.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 01:14:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id DF77E804EE57; Tue, 21 Nov 2023 01:14:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231607AbjKUJOG (ORCPT + 99 others); Tue, 21 Nov 2023 04:14:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231431AbjKUJOF (ORCPT ); Tue, 21 Nov 2023 04:14:05 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D3AAB124; Tue, 21 Nov 2023 01:14:01 -0800 (PST) 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 429CAFEC; Tue, 21 Nov 2023 01:14:48 -0800 (PST) Received: from [10.163.36.237] (unknown [10.163.36.237]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 182C33F73F; Tue, 21 Nov 2023 01:13:56 -0800 (PST) Message-ID: Date: Tue, 21 Nov 2023 14:43:54 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [V14 3/8] drivers: perf: arm_pmuv3: Enable branch stack sampling framework Content-Language: en-US To: James Clark Cc: Mark Brown , Rob Herring , Marc Zyngier , Suzuki Poulose , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com References: <20231114051329.327572-1-anshuman.khandual@arm.com> <20231114051329.327572-4-anshuman.khandual@arm.com> <0020aa0d-e9a5-aef6-f33d-817da56411a3@arm.com> <5bf73672-4094-490b-b0a9-b983d512c904@arm.com> <4fa8ca52-b40c-65ec-59a0-7ad14c4e93b7@arm.com> From: Anshuman Khandual In-Reply-To: <4fa8ca52-b40c-65ec-59a0-7ad14c4e93b7@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 01:14:30 -0800 (PST) On 11/15/23 15:07, James Clark wrote: > > > On 15/11/2023 05:44, Anshuman Khandual wrote: >> On 11/14/23 15:28, James Clark wrote: >>> >>> >>> On 14/11/2023 05:13, Anshuman Khandual wrote: >>>> Branch stack sampling support i.e capturing branch records during execution >>>> in core perf, rides along with normal HW events being scheduled on the PMU. >>>> This prepares ARMV8 PMU framework for branch stack support on relevant PMUs >>>> with required HW implementation. >>>> >>> >>> [...] >>> >>>> - All armv8pmu_branch_xxxx() stub definitions have been moved inside >>>> include/linux/perf/arm_pmuv3.h for easy access from both arm32 and >>>> arm64 platforms >>>> >>> >>> This causes lots of W=1 build errors because the prototypes are in >>> arm_pmuv3.h, but arm_brbe.c doesn't include it. >> >> I guess these are the W=1 warnings you mentioned above. >> >> drivers/perf/arm_brbe.c:11:6: warning: no previous prototype for ‘armv8pmu_branch_reset’ [-Wmissing-prototypes] >> 11 | void armv8pmu_branch_reset(void) >> | ^~~~~~~~~~~~~~~~~~~~~ >> drivers/perf/arm_brbe.c:190:6: warning: no previous prototype for ‘armv8pmu_branch_save’ [-Wmissing-prototypes] >> 190 | void armv8pmu_branch_save(struct arm_pmu *arm_pmu, void *ctx) >> | ^~~~~~~~~~~~~~~~~~~~ >> drivers/perf/arm_brbe.c:236:6: warning: no previous prototype for ‘armv8pmu_branch_attr_valid’ [-Wmissing-prototypes] >> 236 | bool armv8pmu_branch_attr_valid(struct perf_event *event) >> | ^~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/perf/arm_brbe.c:269:5: warning: no previous prototype for ‘armv8pmu_task_ctx_cache_alloc’ [-Wmissing-prototypes] >> 269 | int armv8pmu_task_ctx_cache_alloc(struct arm_pmu *arm_pmu) >> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/perf/arm_brbe.c:279:6: warning: no previous prototype for ‘armv8pmu_task_ctx_cache_free’ [-Wmissing-prototypes] >> 279 | void armv8pmu_task_ctx_cache_free(struct arm_pmu *arm_pmu) >> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/perf/arm_brbe.c:303:6: warning: no previous prototype for ‘armv8pmu_branch_probe’ [-Wmissing-prototypes] >> 303 | void armv8pmu_branch_probe(struct arm_pmu *armpmu) >> | ^~~~~~~~~~~~~~~~~~~~~ >> drivers/perf/arm_brbe.c:449:6: warning: no previous prototype for ‘armv8pmu_branch_enable’ [-Wmissing-prototypes] >> 449 | void armv8pmu_branch_enable(struct arm_pmu *arm_pmu) >> | ^~~~~~~~~~~~~~~~~~~~~~ >> drivers/perf/arm_brbe.c:474:6: warning: no previous prototype for ‘armv8pmu_branch_disable’ [-Wmissing-prototypes] >> 474 | void armv8pmu_branch_disable(void) >> | ^~~~~~~~~~~~~~~~~~~~~~~ >> drivers/perf/arm_brbe.c:717:6: warning: no previous prototype for ‘armv8pmu_branch_read’ [-Wmissing-prototypes] >> 717 | void armv8pmu_branch_read(struct pmu_hw_events *cpuc, struct perf_event *event) >> >> Branch helpers are used in ARM PMU V3 driver i.e drivers/perf/arm_pmuv3.c. >> Whether the actual BRBE helper definitions, or their fallback stubs (when >> CONFIG_ARM64_BRBE is not enabled), need to be accessible from arm_pmuv3.c >> driver not from brbe.c implementations itself. >> >>> >>> It seems like the main reason you can't include arm_brbe.h in arm32 code >>> is because there are a load of inline functions and references to >>> registers in there. But these are only used in arm_brbe.c, so they don't >> >> Right, arm32 should not be exposed to BRBE internals via arm_brbe.h header. >> >>> need to be in the header anyway. >> >> Right, these are only used in arm_brbe.c >> >>> >>> If you removed the code from the header and moved it to the source file >>> you could move the brbe prototypes to the brbe header and it would be a >>> bit cleaner and more idiomatic. >> >> Alight, how about the following changes - build tested on arm32 and arm64. >> >> - Move BRBE helpers from arm_brbe.h into arm_brbe.c >> - Move armv8_pmu_xxx() declaration inside arm_brbe.h for arm64 (CONFIG_ARM64_BRBE) >> - Move armv8_pmu_xxx() stub definitions inside arm_pmuv3.c for arm32 (!CONFIG_ARM64_BRBE) >> - Include arm_brbe.h header both in arm_pmuv3.c and arm_brbe.c > > Agree to them all except: > > - Move armv8_pmu_xxx() stub definitions inside arm_pmuv3.c for arm32 > (!CONFIG_ARM64_BRBE) > > Normally you put the stubs right next to the prototypes with #else, so > in this case both would be in arm_brbe.h. Not sure what the reason for > splitting them here is? You already said "include arm_brbe.h in > arm_pmuv3.c", so that covers arm32 too. Not any particular strong reason for the split as such, will move these stubs to the header as well. BRBE header includes which causes the following redefinition warning for the pr_fmt(). drivers/perf/arm_brbe.c:11: warning: "pr_fmt" redefined 11 | #define pr_fmt(fmt) "brbe: " fmt | In file included from ./include/linux/kernel.h:31, from ./include/linux/interrupt.h:6, from ./include/linux/perf/arm_pmu.h:11, from drivers/perf/arm_brbe.h:10, from drivers/perf/arm_brbe.c:9: ./include/linux/printk.h:345: note: this is the location of the previous definition 345 | #define pr_fmt(fmt) fmt Although it should be okay to just drop this custom pr_fmt() from BRBE.