linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anshuman Khandual <anshuman.khandual@arm.com>
To: James Clark <james.clark@arm.com>
Cc: Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
	Marc Zyngier <maz@kernel.org>,
	Suzuki Poulose <suzuki.poulose@arm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	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
Subject: Re: [V14 3/8] drivers: perf: arm_pmuv3: Enable branch stack sampling framework
Date: Tue, 21 Nov 2023 14:43:54 +0530	[thread overview]
Message-ID: <c8ddb80b-4228-4ed3-bc54-fba334b70c2b@arm.com> (raw)
In-Reply-To: <4fa8ca52-b40c-65ec-59a0-7ad14c4e93b7@arm.com>



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 <linux/perf/arm_pmu.h>
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.

  reply	other threads:[~2023-11-21  9:14 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14  5:13 [V14 0/8] arm64/perf: Enable branch stack sampling Anshuman Khandual
2023-11-14  5:13 ` [V14 1/8] arm64/sysreg: Add BRBE registers and fields Anshuman Khandual
2023-11-14  5:13 ` [V14 2/8] KVM: arm64: Prevent guest accesses into BRBE system registers/instructions Anshuman Khandual
2023-11-14  5:13 ` [V14 3/8] drivers: perf: arm_pmuv3: Enable branch stack sampling framework Anshuman Khandual
2023-11-14  9:58   ` James Clark
2023-11-15  5:44     ` Anshuman Khandual
2023-11-15  9:37       ` James Clark
2023-11-21  9:13         ` Anshuman Khandual [this message]
2023-11-14 12:14   ` James Clark
2023-11-15  7:22     ` Anshuman Khandual
2023-11-15 10:07       ` James Clark
2023-11-21  9:57         ` Anshuman Khandual
2023-11-23 12:35           ` James Clark
2023-11-27  8:06             ` Anshuman Khandual
2023-11-14 17:10   ` James Clark
2023-11-30  3:58     ` Anshuman Khandual
2023-11-14  5:13 ` [V14 4/8] drivers: perf: arm_pmuv3: Enable branch stack sampling via FEAT_BRBE Anshuman Khandual
2023-11-14 12:11   ` James Clark
2023-11-21 10:47     ` Anshuman Khandual
2023-11-14  5:13 ` [V14 5/8] KVM: arm64: nvhe: Disable branch generation in nVHE guests Anshuman Khandual
2023-11-14  9:16   ` James Clark
2023-11-21 11:12     ` Anshuman Khandual
2023-11-23 13:54       ` James Clark
2023-11-27  8:25         ` Anshuman Khandual
2023-11-14  5:13 ` [V14 6/8] perf: test: Speed up running brstack test on an Arm model Anshuman Khandual
2023-11-14  5:13 ` [V14 7/8] perf: test: Remove empty lines from branch filter test output Anshuman Khandual
2023-11-14  5:13 ` [V14 8/8] perf: test: Extend branch stack sampling test for Arm64 BRBE Anshuman Khandual
2023-11-14 17:17 ` [V14 0/8] arm64/perf: Enable branch stack sampling James Clark
2023-11-22  5:15   ` Anshuman Khandual
2023-11-23 16:23     ` James Clark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c8ddb80b-4228-4ed3-bc54-fba334b70c2b@arm.com \
    --to=anshuman.khandual@arm.com \
    --cc=acme@kernel.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.clark@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=robh@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).