SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
Thu 6 March, 10:05am, Santosh Shukla, Mike Holmes
LCA14-401: BoF, Networking -
Debug/tracing/counter
• Introduction
• Use case
• libperf and in-kernel perf API
• Test analysis direct user access vs syscall
based perf counter access
• Design Issues and Next step
• QA
Fast access to perf Counters
• Access to perf counters is not fast enough in the
embedded networking space.
• We think we need
• The fastest access from user space. (see use
case)
• Shared when read only (no locking overhead).
• Stable API (based on libperf)
• Easy way to access to SoC specific counters
Introduction
• In fast path (could be ODP in future), There’ll be a
method to analyze odp crash dump based on statistics.
• Because crash dump statistics are based on the perf hw
counters, really low overhead counter access is needed.
Should provide near accurate cpu or bus clock cycle
precision.
• For example, in the fast path - per-packet budgeting is
1000 cpu cycle, then measuring can not take 3000 cpu
cycle as it does today with syscall based perf counter in
linux.
Use Case
Perf provides a syscall method to open a perf file descriptor for user space
application to access the counters, and attach the events to them.
sys_perf_counter_open - The syscall
- event type attributes for monitoring/sampling
- target pid
- target cpu
- group_fd
- flags
Event type :
- PERF_TYPE_HARDWARE
- PERF_TYPE_SOFTWARE
- PERF_TYPE_TRACEPOINT
- PERF_TYPE_HW_CACHE
- PERF_TYPE_RAW (for raw tracepoint data)
Perf
attr.sample_type
{
bitmask
PERF_SAMPLE_IP
PERF_SAMPLE_TID
PERF_SAMPLE_TIME
PERF_SAMPLE_CALLCHAIN
PERF_SAMPLE_ID
PERF_SAMPLE_CPU
}
attr config bitfield
{
disabled: off by default
inherit: children inherit it
exclude_{user,kernel,hv,idle}: don’t count these
mmap: include mmap data
comm: include comm data
inherit_stat: per task counts
enable_on_exec: next exec enables
}
perf continued..
• Libperf creates set of file descriptors for bunch of perf events..by calling
sys_perf_open_event() api, and does enable/disable/read operation on
them .
current API has :
libperf_initialize : sets up a set of fd's for profiling
code to read from
libperf_finalize : read from fd’s, print and close all
pef FD.
libperf_readcounter : read perf counter.
libperf_enablecounter : Enable perf counter
libperf_disablecounter : disable perf counter
libperf_close : Close fd
Libperf
• Raw Proposal :
• Mmaping hw counters to user space could be a way forward for fast
access, removing overhead with the current kernel implementation.
• Adding scalable framework in user space ..could be libperf so to read
cpu specific counter, counter on offload block and other variant of
counters.
• Current mmapped based perf support in kernel:
• in-kernel perf supports mmaped based persistent ring-buffer
implementation for user space.
• This implementation is limited in performance due to the following.
The hw counter mappable and stored into ring-buffer with lots of
synchronisation overhead for user space to access i.e.. rmb for every
perf read counter, locking, async wake-up event for user space to
read statistics.
design issues, next step investigation
• But,
• The current kernel mappable events are exclusive, and
are not shareable, they won't fall back to sysfs perf event
mode. Therefore it is not scalable.
• The current kernel counter overhead is still significant,
therefore the current implementation won't achieve 1000
cycle requirement for fast path model, example ODP
crash dump statistics requirement mentioned in prev slide
[4].
Next Step continued..
• Effort to investigate and try to evaluate these issues :
• Focus on exclusive fast access approach
• HW counter pinned to specific core, specific task
• Avoid sync primitives in kernel space while reading hw counter, Let
user space application handle this job.
• Educate libperf to handle sync primitive and decide on locking policy.
• Design should be flexible enough to fall back to syscall based perf
mode.
• Respect SMP policy as much as possible.
Next Step continued..
Userspace fast access flow control arrow key - too shor
Application should be squa
Both these inside Soc
Arm Processor Core
event extensions
Custom user space application detail -
• Ran test application on arndale to demonstrate delta of user vs kernel space perf
counter. Result shows close to 9x improvement.
• Tiny test kernel module enables,disable perf counter for user mode.
/* enable */
asm ("MCR p15, 0, %0, C9, C14, 0nt" :: "r"(1));
/* disable */
asm ("MCR p15, 0, %0, C9, C14, 2nt" :: "r"(0x8000000f));
• User app uses x86 style timer api to read perf counter.
static inline uint32_t
rdtsc32(void)
{
#if defined(__GNUC__) && defined(__ARM_ARCH_7A__)
uint32_t r = 0;
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(r) );
return r;
#else
#error Unsupported architecture/compiler!
#endif
}
Benchmarking current & proposed access
Libperf application using perf syscall -
• Create perf event FD using perf_event_open syscall.
• Reads perf counter event from file descriptor.
init(void)
{
static struct perf_event_attr attr;
attr.type = PERF_TYPE_HARDWARE;
attr.config = PERF_COUNT_HW_CPU_CYCLES;
fddev = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0);
}
• Both application runs in a tight loop for some duration and
there delta recorded for comparison..
Benchmarking cont..
• Enable pmu direct user space vs perf syscall based
application.
Benchmarking cont..
[1]ARM A15 Performance counter registers
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0438c/BIIFDEEJ.
html
[2]LNG CARD
https://cards.linaro.org/browse/LNG-260
[3]Perf 0n A15
https://perf.wiki.kernel.org/index.php/Tutorial
[4]http://neocontra.blogspot.com/2013/05/user-mode-performance-counters-for.
html
[5]https://github.com/thoughtpolice/enable_arm_pmu
[6]Lib perf https://github.com/theonewolf/libperf
[7]http://www.linux-kongress.org/2010/slides/lk2010-perf-acme.pdf
Reference links
QA
More about Linaro Connect: http://connect.linaro.org
More about Linaro: http://www.linaro.org/about/
More about Linaro engineering: http://www.linaro.org/engineering/
Linaro members: www.linaro.org/members

Mais conteúdo relacionado

Mais de Linaro

Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Linaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
Linaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
Linaro
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
Linaro
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
Linaro
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
Linaro
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted boot
Linaro
 
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
Linaro
 
HKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready ProgramHKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready Program
Linaro
 
HKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NNHKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NN
Linaro
 
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
Linaro
 
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
Linaro
 
HKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: IntroductionHKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: Introduction
Linaro
 
HKG18-116 - RAS Solutions for Arm64 Servers
HKG18-116 - RAS Solutions for Arm64 ServersHKG18-116 - RAS Solutions for Arm64 Servers
HKG18-116 - RAS Solutions for Arm64 Servers
Linaro
 
HKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightHKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with Coresight
Linaro
 

Mais de Linaro (20)

Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening Keynote
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP Workshop
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allHKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
 
HKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MHKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8M
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted boot
 
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
 
HKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready ProgramHKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready Program
 
HKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NNHKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NN
 
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
 
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
 
HKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: IntroductionHKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: Introduction
 
HKG18-116 - RAS Solutions for Arm64 Servers
HKG18-116 - RAS Solutions for Arm64 ServersHKG18-116 - RAS Solutions for Arm64 Servers
HKG18-116 - RAS Solutions for Arm64 Servers
 
HKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightHKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with Coresight
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

LCA14: LCA14-401: BoF - Networking - Debug/tracing/counter

  • 1. Thu 6 March, 10:05am, Santosh Shukla, Mike Holmes LCA14-401: BoF, Networking - Debug/tracing/counter
  • 2. • Introduction • Use case • libperf and in-kernel perf API • Test analysis direct user access vs syscall based perf counter access • Design Issues and Next step • QA Fast access to perf Counters
  • 3. • Access to perf counters is not fast enough in the embedded networking space. • We think we need • The fastest access from user space. (see use case) • Shared when read only (no locking overhead). • Stable API (based on libperf) • Easy way to access to SoC specific counters Introduction
  • 4. • In fast path (could be ODP in future), There’ll be a method to analyze odp crash dump based on statistics. • Because crash dump statistics are based on the perf hw counters, really low overhead counter access is needed. Should provide near accurate cpu or bus clock cycle precision. • For example, in the fast path - per-packet budgeting is 1000 cpu cycle, then measuring can not take 3000 cpu cycle as it does today with syscall based perf counter in linux. Use Case
  • 5. Perf provides a syscall method to open a perf file descriptor for user space application to access the counters, and attach the events to them. sys_perf_counter_open - The syscall - event type attributes for monitoring/sampling - target pid - target cpu - group_fd - flags Event type : - PERF_TYPE_HARDWARE - PERF_TYPE_SOFTWARE - PERF_TYPE_TRACEPOINT - PERF_TYPE_HW_CACHE - PERF_TYPE_RAW (for raw tracepoint data) Perf
  • 6. attr.sample_type { bitmask PERF_SAMPLE_IP PERF_SAMPLE_TID PERF_SAMPLE_TIME PERF_SAMPLE_CALLCHAIN PERF_SAMPLE_ID PERF_SAMPLE_CPU } attr config bitfield { disabled: off by default inherit: children inherit it exclude_{user,kernel,hv,idle}: don’t count these mmap: include mmap data comm: include comm data inherit_stat: per task counts enable_on_exec: next exec enables } perf continued..
  • 7. • Libperf creates set of file descriptors for bunch of perf events..by calling sys_perf_open_event() api, and does enable/disable/read operation on them . current API has : libperf_initialize : sets up a set of fd's for profiling code to read from libperf_finalize : read from fd’s, print and close all pef FD. libperf_readcounter : read perf counter. libperf_enablecounter : Enable perf counter libperf_disablecounter : disable perf counter libperf_close : Close fd Libperf
  • 8. • Raw Proposal : • Mmaping hw counters to user space could be a way forward for fast access, removing overhead with the current kernel implementation. • Adding scalable framework in user space ..could be libperf so to read cpu specific counter, counter on offload block and other variant of counters. • Current mmapped based perf support in kernel: • in-kernel perf supports mmaped based persistent ring-buffer implementation for user space. • This implementation is limited in performance due to the following. The hw counter mappable and stored into ring-buffer with lots of synchronisation overhead for user space to access i.e.. rmb for every perf read counter, locking, async wake-up event for user space to read statistics. design issues, next step investigation
  • 9. • But, • The current kernel mappable events are exclusive, and are not shareable, they won't fall back to sysfs perf event mode. Therefore it is not scalable. • The current kernel counter overhead is still significant, therefore the current implementation won't achieve 1000 cycle requirement for fast path model, example ODP crash dump statistics requirement mentioned in prev slide [4]. Next Step continued..
  • 10. • Effort to investigate and try to evaluate these issues : • Focus on exclusive fast access approach • HW counter pinned to specific core, specific task • Avoid sync primitives in kernel space while reading hw counter, Let user space application handle this job. • Educate libperf to handle sync primitive and decide on locking policy. • Design should be flexible enough to fall back to syscall based perf mode. • Respect SMP policy as much as possible. Next Step continued..
  • 11. Userspace fast access flow control arrow key - too shor Application should be squa Both these inside Soc Arm Processor Core event extensions
  • 12. Custom user space application detail - • Ran test application on arndale to demonstrate delta of user vs kernel space perf counter. Result shows close to 9x improvement. • Tiny test kernel module enables,disable perf counter for user mode. /* enable */ asm ("MCR p15, 0, %0, C9, C14, 0nt" :: "r"(1)); /* disable */ asm ("MCR p15, 0, %0, C9, C14, 2nt" :: "r"(0x8000000f)); • User app uses x86 style timer api to read perf counter. static inline uint32_t rdtsc32(void) { #if defined(__GNUC__) && defined(__ARM_ARCH_7A__) uint32_t r = 0; asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(r) ); return r; #else #error Unsupported architecture/compiler! #endif } Benchmarking current & proposed access
  • 13. Libperf application using perf syscall - • Create perf event FD using perf_event_open syscall. • Reads perf counter event from file descriptor. init(void) { static struct perf_event_attr attr; attr.type = PERF_TYPE_HARDWARE; attr.config = PERF_COUNT_HW_CPU_CYCLES; fddev = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0); } • Both application runs in a tight loop for some duration and there delta recorded for comparison.. Benchmarking cont..
  • 14. • Enable pmu direct user space vs perf syscall based application. Benchmarking cont..
  • 15. [1]ARM A15 Performance counter registers http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0438c/BIIFDEEJ. html [2]LNG CARD https://cards.linaro.org/browse/LNG-260 [3]Perf 0n A15 https://perf.wiki.kernel.org/index.php/Tutorial [4]http://neocontra.blogspot.com/2013/05/user-mode-performance-counters-for. html [5]https://github.com/thoughtpolice/enable_arm_pmu [6]Lib perf https://github.com/theonewolf/libperf [7]http://www.linux-kongress.org/2010/slides/lk2010-perf-acme.pdf Reference links
  • 16. QA
  • 17. More about Linaro Connect: http://connect.linaro.org More about Linaro: http://www.linaro.org/about/ More about Linaro engineering: http://www.linaro.org/engineering/ Linaro members: www.linaro.org/members