hujun260 opened a new pull request, #18177:
URL: https://github.com/apache/nuttx/pull/18177

   ## Summary
   
   Enable userspace access to hardware Performance Monitoring Unit (PMU) on 
ARM64 Cortex-R82 architecture. This allows applications to directly read 
hardware performance counters via `up_perf_gettime()` without requiring 
syscalls, enabling efficient performance profiling and timing measurements.
   
   ## Changes
   
   **File: arch/arm64/Kconfig**
   - Add `ARCH_HAVE_PERF_EVENTS_USER_ACCESS` capability selection for Cortex-R82
   - Conditional on `!ARCH_CLUSTER_PMU` (standard PMU mode only)
   
   **File: arch/arm64/src/common/Make.defs**
   - Add `arm64_perf.c` to CMN_UCSRCS for userspace library compilation
   - Enables userspace PMU functions in protected/kernel builds
   
   **File: arch/arm64/src/common/CMakeLists.txt**
   - Add `arm64_perf.c` to arch_interface target for non-flat builds
   - Include chip directory for proper header resolution
   
   **File: arch/arm64/src/common/arm64_perf.c**
   - Move `up_perf_gettime()` outside `CONFIG_BUILD_FLAT || __KERNEL__` block
   - Function now accessible from both kernel and userspace
   - Other functions (up_perf_init, up_perf_getfreq, up_perf_convert) remain 
kernel-only
   
   ## Impact
   
   - **Performance**: Eliminates syscall overhead for performance counter reads
   - **Profiling**: Applications can profile themselves directly using hardware 
counters
   - **Consistency**: Aligns Cortex-R82 with other architectures supporting 
userspace PMU access
   - **Compatibility**: No impact on kernel-only PMU usage patterns
   
   ## Technical Details
   
   **Userspace PMU access pattern:**
   
   ```c
   // Application can now directly call:
   clock_t start = up_perf_gettime();
   // ... code to profile ...
   clock_t elapsed = up_perf_gettime() - start;
   // No syscall overhead - direct register read


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to