SlideShare uma empresa Scribd logo
1 de 43
Baixar para ler offline
Embedded Linux Conference Europe 2013

Bridging the gap between hardware
and software tracing
christian.babeux@efficios.com 
1
@c_bab 
Source: arm.com [1] 2
ARM Cortex A9

Source: arm.com [1] 3
ARM Cortex A9
PTM
Program Trace
Macrocell

Source: arm.com [1] 4
whoami


Christian Babeux, Software Developer, EfficiOS,



Background in embedded and ASIC tools,



Active contributor to the LTTng projects:
●
●



lttng-tools, lttng-ust, babeltrace,
CI infra, Website, Twitter.

AUR package maintainer for Arch Linux.
5
Content


What is hardware tracing?,



Why is it useful?,



ARM Coresight & ETM,



Freescale QorIQ & Nexus tracing,



LTTng & hardware tracing.
6
What is hardware tracing?


7
What is hardware tracing?
 Hardware component(s) used to traces instructions
and data movement of a processing device

 Real-time observation
Low intrusiveness

8
What is hardware tracing? Cont.
●

External trace

9
What is hardware tracing? Cont.
●

Pros
–
–

●

Can accommodate high data bandwidth
Minimal impact on system performance

–

Trace port not always available

–

Custom hardware needed

Cons

10
What is hardware tracing? Cont.
●

Self-hosted trace

11
What is hardware tracing? Cont.
●

Pros
–
–

●

Self-contained, facilities can be used by host OS
No need for special hardware

–

Limited internal buffer space

–

Might impact system performance

Cons

12
Hardware tracing support
●

ARM
–
–

Program Trace Flow Macrocell (PTM),

–
●

Embedded Trace Macrocell (ETM),
System Trace Macrocell (STM)

PowerPC
–
–

●

Freescale QorIQ with Nexus tracing
Branch History Rolling Buffer (BHRB)

–

Intel Processor Tracing (PT)

–

Last Branch Record (LBR), Branch Trace Store (BTS)

Intel

13
Hardware tracing vs. software tracing
●

Software tracing:
–
–

Can be intrusive

–

Can be slow

–

●

Static instrumentation or dynamic code patching

Tracepoint level granularity

Hardware tracing:
–

Tracing done on hardware

–

Instrumentation not required

–

Instruction level granularity
14
Why hardware tracing is useful


15
Why hardware tracing is useful
 Profiling
–

Very fine granularity profiling

 Performance measurement
 Code coverage
 Monitoring
–

Statistics on application currently running?
16
Why hardware tracing is useful cont.
 Snapshot on crash/anomaly
–

Trace overwrites old data until anomaly detected

 Event trigger trace
 Hardware-assisted software tracing
–

Use hardware facility (ringbuffer)

17
ARM Coresight & ETM


18
ARM Coresight
●

Coresight
–
–

Trace and debug a complete SoC

–

●

Collection of hardware components
Open architecture

Trace source
–

Processing elements (CPU, DSP, etc.)

–

Buses

–

System trace (generated from software)
19
ARM ETM
●

ETM
–

Monitor the core internal bus

–

Instructions + data trace

–

Hardware filters and triggers

–

Trace stream compression

–

Traces can be saved in internal buffer (ETB) or shared
system memory

20
ARM Coresight

Source: arm.com [2] 21
State of Coresight & ETM in Linux
●

ETM tracer implementation available in Linux
–

●

Coresight support status
–

●

Seems to work only on specific hardware

Framework patchset proposed by Pratik Pratel [3]

Trace decoder availability?

22
Interested about Coresight/ETM?

“Hardware Trace in the Kernel” BoF
by Pawel Moll from ARM
Today, 4:30 PM in Pentland

23
Freescale QorIQ & Nexus tracing


24
Freescale QorIQ
●

PowerPC based platform targeted for high-performance
communications usage
–

Multiple e500mc processors,

–

DPAA support (packet processing offloading),

–

Support the Nexus debugging & tracing standard.

Source: radiolocman 25
[4]
Nexus standard
●

●

●

ISO standard for debugging embedded systems (IEEEISTO-5001-2003),
Designed for low pin count, standard set of connectors
(JTAG or Debug port),
Multiple level of Nexus “compliance”.

26
Nexus standard level
●

Level 1:
–
–

●

Run time control only (run, stop, breakpoints, etc.)
Tracing not supported

Level 2:
–

●

Level 3:
–

●

Ownership and program trace
Data write trace & memory read/write on the fly

Level 4:
–

Memory substitution

–

Trace triggering via a watchpoint
27
Nexus standard format
●

Packet based output format,
–

Standard defines public messages, vendors can define
extensions (TCODES)

–

Fixed packet size per message, last packet can be of
variable length

–

Message can have an optional timestamp

28
Example decoded Nexus message
Message # 328
TCODE : 2 Ownership Trace Message
SRC ID : 0 Core0 / CPU0 (Clst0:Core0:Thread0)
PID INDEX : 0x02 - Sync PID
PID VALUE : 0x01e01bf59c - LPIDR, MSR[GS],
PID/NPIDR (ref:DC1[OTS]), MSR[PR]
TIMESTAMP : 1140061 (0x11655d)
Message # 329
TCODE : 27 Resource Full Message
SRC ID : 0 Core0 / CPU0 (Clst0:Core0:Thread0)
RCODE : 0x8 - Timestamp counter
RDATA : 0x00ffffff
TIMESTAMP : 0 (0x0)
29
State of Nexus in Linux
●

Nexus qoriq-debug kernel module,
–

Available in Freescale QorIQ SDK Yocto Layer

–

Implements a debugfs with memory mapped access to
Nexus control register

–

cat /sys/kernel/debug/npc/trace_buffer > trace

30
Nexus debugfs
root@p3041ds:~# ls -al /sys/kernel/debug/qoriq-dbg
[...]
drwxr-xr-x 2 root root 0 Aug 6 20:22 cpu0
drwxr-xr-x 2 root root 0 Aug 6 20:22 cpu1
drwxr-xr-x 2 root root 0 Aug 6 20:22 cpu2
drwxr-xr-x 2 root root 0 Aug 6 20:22 cpu3
drwxr-xr-x 2 root root 0 Aug 6 20:22 ddr1
drwxr-xr-x 2 root root 0 Aug 6 20:22 dpaa
[...]
drwxr-xr-x 2 root root 0 Aug 6 20:22 npc
drwxr-xr-x 2 root root 0 Aug 6 20:22 nxc
[...]
root@p3041ds:~# ls -al /sys/kernel/debug/qoriq-dbg/cpu0
[...]
-rw-rw-rw- 1 root root 0 Aug 6 20:22 dc1
-rw-rw-rw- 1 root root 0 Aug 6 20:22 dc2
-rw-rw-rw- 1 root root 0 Aug 6 20:22 dc4
--w--w--w- 1 root root 0 Aug 6 20:22 ddam
[...]

31
State of Nexus in Linux
●

Nexus decoder availability
–

●

Released as part of the babeltrace project

Open-source software to reconstruct program flow not
yet developed
–

Integrate such functionality in an IDE ? perf?

32
LTTng & Hardware tracing


33
Project overview




34
Tracers

●

●

lttng-modules: kernel tracer module, compatible
with kernels from 2.6.38* to 3.11,
lttng-ust: user-space tracer, in-process library.

* Kernel tracing is now possible on 2.6.32 to 2.6.37 by backport of 3
Linux Kernel patches [1].
35
Utilities


●

lttng-tools: cli utilities and daemons for trace control,
–

lttng: cli utility for tracing control,

–

lttng-sessiond: tracing registry daemon,

–

lttng-consumerd: consume trace data,

–

lttng-relayd: network streaming daemon.
36
Viewers


●

●
●

babeltrace: cli text viewer, trace converter, plugin
system,
lttngtop: ncurse top-like viewer,
Eclipse lttng plugin: front-end for lttng, collect,
visualize and analyze traces, highly extensible.
37
Hardware tracing support
●

Initial attempt to support hardware tracing:
–
–

●

Babeltrace Nexus to CTF converter [5]
Goal: Leverage existing traces visualizer

Encountered issues:
–

Traces are not self-contained, need sideband
information

–

Internal trace buffer size limitation

–

Synchronization with other traces can be tricky
38
Hardware tracing support demo

DEMO
39
Future work
●

●

●

Decoder/Converter for ARM ETM?
Control hardware tracing facilities with the lttngtools command-line?
Custom views for hardware traces in Eclipse plugin

40
Conclusion
●

Availability and usefulness of hardware tracing

●

Initial support for self-hosted hardware tracing

●

Common abstraction for hardware tracing in the
Linux kernel?

41
Questions ?

?



www.efficios.com

 lttng.org
 lttng-dev@lists.lttng.org
 @lttng_project

42
References
[1] - http://www.arm.com/images/processor/Cortex-A9-osprey.jpg
[2] - http://www.arm.com/images/CoreSight_Diagram_Tiny.jpg
[3] - https://lkml.org/lkml/2012/12/19/331
[4] - http://www.rlocman.ru/i/Image/2010/06/24/2.jpg
[5] - https://github.com/cbab/babeltrace/tree/nexus

43

Mais conteúdo relacionado

Mais procurados

OMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
OMFW 2012: Analyzing Linux Kernel Rootkits with VolatlityOMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
OMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
Andrew Case
 
[Wroclaw #3] Trusted Computing
[Wroclaw #3] Trusted Computing[Wroclaw #3] Trusted Computing
[Wroclaw #3] Trusted Computing
OWASP
 
Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...
Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...
Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...
linuxlab_conf
 
Claudio Scordino - Handling mixed criticality on embedded multi-core systems
Claudio Scordino - Handling mixed criticality on embedded multi-core systemsClaudio Scordino - Handling mixed criticality on embedded multi-core systems
Claudio Scordino - Handling mixed criticality on embedded multi-core systems
linuxlab_conf
 
Demystifying Security Root of Trust Approaches for IoT/Embedded - SFO17-304
Demystifying Security Root of Trust Approaches for IoT/Embedded  - SFO17-304Demystifying Security Root of Trust Approaches for IoT/Embedded  - SFO17-304
Demystifying Security Root of Trust Approaches for IoT/Embedded - SFO17-304
Linaro
 

Mais procurados (20)

Linuxconeurope2011.ext4btrfs.talk
Linuxconeurope2011.ext4btrfs.talkLinuxconeurope2011.ext4btrfs.talk
Linuxconeurope2011.ext4btrfs.talk
 
New Zephyr features: LWM2M / FOTA Framework - SFO17-113
New Zephyr features: LWM2M / FOTA Framework - SFO17-113New Zephyr features: LWM2M / FOTA Framework - SFO17-113
New Zephyr features: LWM2M / FOTA Framework - SFO17-113
 
Mac Memory Analysis with Volatility
Mac Memory Analysis with VolatilityMac Memory Analysis with Volatility
Mac Memory Analysis with Volatility
 
IPS_3M_eng
IPS_3M_engIPS_3M_eng
IPS_3M_eng
 
Netmap presentation
Netmap presentationNetmap presentation
Netmap presentation
 
LAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel AwarenessLAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel Awareness
 
OMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
OMFW 2012: Analyzing Linux Kernel Rootkits with VolatlityOMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
OMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
 
Secure IoT Firmware for RISC-V
Secure IoT Firmware for RISC-VSecure IoT Firmware for RISC-V
Secure IoT Firmware for RISC-V
 
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
 
Hunting Mac Malware with Memory Forensics
Hunting Mac Malware with Memory ForensicsHunting Mac Malware with Memory Forensics
Hunting Mac Malware with Memory Forensics
 
Alessio Lama - Development and testing of a safety network protocol
Alessio Lama - Development and testing of a safety network protocolAlessio Lama - Development and testing of a safety network protocol
Alessio Lama - Development and testing of a safety network protocol
 
Nodes and Networks for HPC computing
Nodes and Networks for HPC computingNodes and Networks for HPC computing
Nodes and Networks for HPC computing
 
[Wroclaw #3] Trusted Computing
[Wroclaw #3] Trusted Computing[Wroclaw #3] Trusted Computing
[Wroclaw #3] Trusted Computing
 
U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0
 
Developing TI RTOS Applications and BLE Profiles
Developing TI RTOS Applications and BLE ProfilesDeveloping TI RTOS Applications and BLE Profiles
Developing TI RTOS Applications and BLE Profiles
 
Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...
Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...
Valerio Di Giampietro - Introduction To IoT Reverse Engineering with an examp...
 
Linux Kernel Platform Development: Challenges and Insights
 Linux Kernel Platform Development: Challenges and Insights Linux Kernel Platform Development: Challenges and Insights
Linux Kernel Platform Development: Challenges and Insights
 
Claudio Scordino - Handling mixed criticality on embedded multi-core systems
Claudio Scordino - Handling mixed criticality on embedded multi-core systemsClaudio Scordino - Handling mixed criticality on embedded multi-core systems
Claudio Scordino - Handling mixed criticality on embedded multi-core systems
 
Demystifying Security Root of Trust Approaches for IoT/Embedded - SFO17-304
Demystifying Security Root of Trust Approaches for IoT/Embedded  - SFO17-304Demystifying Security Root of Trust Approaches for IoT/Embedded  - SFO17-304
Demystifying Security Root of Trust Approaches for IoT/Embedded - SFO17-304
 
An Essential Relationship between Real-time and Resource Partitioning
An Essential Relationship between Real-time and Resource PartitioningAn Essential Relationship between Real-time and Resource Partitioning
An Essential Relationship between Real-time and Resource Partitioning
 

Semelhante a Bridging the gap between hardware and software tracing

Lcu14 101- coresight overview
Lcu14 101- coresight overviewLcu14 101- coresight overview
Lcu14 101- coresight overview
Linaro
 
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CanSecWest
 
Tank water level & monitoring solution based on the STM32L476 MCU
Tank water level & monitoring solution based on the STM32L476 MCUTank water level & monitoring solution based on the STM32L476 MCU
Tank water level & monitoring solution based on the STM32L476 MCU
Julio César Carrasquel
 
Microprocessor.ppt
Microprocessor.pptMicroprocessor.ppt
Microprocessor.ppt
safia kalwar
 
microcontrollersstm32wlseriesproductwebinarpresentation1625231766205.pdf
microcontrollersstm32wlseriesproductwebinarpresentation1625231766205.pdfmicrocontrollersstm32wlseriesproductwebinarpresentation1625231766205.pdf
microcontrollersstm32wlseriesproductwebinarpresentation1625231766205.pdf
adfadfadf
 

Semelhante a Bridging the gap between hardware and software tracing (20)

LTTng-UST: Efficient System-Wide User-Space Tracing
LTTng-UST: Efficient System-Wide User-Space TracingLTTng-UST: Efficient System-Wide User-Space Tracing
LTTng-UST: Efficient System-Wide User-Space Tracing
 
BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!
 
Lcu14 101- coresight overview
Lcu14 101- coresight overviewLcu14 101- coresight overview
Lcu14 101- coresight overview
 
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSDLAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
 
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
 
Tank water level & monitoring solution based on the STM32L476 MCU
Tank water level & monitoring solution based on the STM32L476 MCUTank water level & monitoring solution based on the STM32L476 MCU
Tank water level & monitoring solution based on the STM32L476 MCU
 
No[1][1]
No[1][1]No[1][1]
No[1][1]
 
AAME ARM Techcon2013 004v02 Debug and Optimization
AAME ARM Techcon2013 004v02 Debug and OptimizationAAME ARM Techcon2013 004v02 Debug and Optimization
AAME ARM Techcon2013 004v02 Debug and Optimization
 
Blackhat USA 2016 - What's the DFIRence for ICS?
Blackhat USA 2016 - What's the DFIRence for ICS?Blackhat USA 2016 - What's the DFIRence for ICS?
Blackhat USA 2016 - What's the DFIRence for ICS?
 
Microprocessor.ppt
Microprocessor.pptMicroprocessor.ppt
Microprocessor.ppt
 
uCluster
uClusteruCluster
uCluster
 
Design of 32 Bit Processor Using 8051 and Leon3 (Progress Report)
Design of 32 Bit Processor Using 8051 and Leon3 (Progress Report)Design of 32 Bit Processor Using 8051 and Leon3 (Progress Report)
Design of 32 Bit Processor Using 8051 and Leon3 (Progress Report)
 
Introduction to FreeRTOS
Introduction to FreeRTOSIntroduction to FreeRTOS
Introduction to FreeRTOS
 
Track 5 session 5 - st dev con 2016 - stm32 hands on seminar - cloud connec...
Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connec...Track 5   session 5 - st dev con 2016 - stm32 hands on seminar - cloud connec...
Track 5 session 5 - st dev con 2016 - stm32 hands on seminar - cloud connec...
 
Kernel Recipes 2015: Kernel packet capture technologies
Kernel Recipes 2015: Kernel packet capture technologiesKernel Recipes 2015: Kernel packet capture technologies
Kernel Recipes 2015: Kernel packet capture technologies
 
Tos tutorial
Tos tutorialTos tutorial
Tos tutorial
 
microcontrollersstm32wlseriesproductwebinarpresentation1625231766205.pdf
microcontrollersstm32wlseriesproductwebinarpresentation1625231766205.pdfmicrocontrollersstm32wlseriesproductwebinarpresentation1625231766205.pdf
microcontrollersstm32wlseriesproductwebinarpresentation1625231766205.pdf
 
Intel® RDT Hands-on Lab
Intel® RDT Hands-on LabIntel® RDT Hands-on Lab
Intel® RDT Hands-on Lab
 
A Retasking Framework For Wireless Sensor Networks
A Retasking Framework For Wireless Sensor NetworksA Retasking Framework For Wireless Sensor Networks
A Retasking Framework For Wireless Sensor Networks
 
K vector embedded_linux_workshop
K vector embedded_linux_workshopK vector embedded_linux_workshop
K vector embedded_linux_workshop
 

Último

Último (20)

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
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
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
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
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 ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 

Bridging the gap between hardware and software tracing

  • 1. Embedded Linux Conference Europe 2013 Bridging the gap between hardware and software tracing christian.babeux@efficios.com  1 @c_bab 
  • 3. ARM Cortex A9 Source: arm.com [1] 3
  • 4. ARM Cortex A9 PTM Program Trace Macrocell Source: arm.com [1] 4
  • 5. whoami  Christian Babeux, Software Developer, EfficiOS,  Background in embedded and ASIC tools,  Active contributor to the LTTng projects: ● ●  lttng-tools, lttng-ust, babeltrace, CI infra, Website, Twitter. AUR package maintainer for Arch Linux. 5
  • 6. Content  What is hardware tracing?,  Why is it useful?,  ARM Coresight & ETM,  Freescale QorIQ & Nexus tracing,  LTTng & hardware tracing. 6
  • 7. What is hardware tracing?  7
  • 8. What is hardware tracing?  Hardware component(s) used to traces instructions and data movement of a processing device  Real-time observation Low intrusiveness 8
  • 9. What is hardware tracing? Cont. ● External trace 9
  • 10. What is hardware tracing? Cont. ● Pros – – ● Can accommodate high data bandwidth Minimal impact on system performance – Trace port not always available – Custom hardware needed Cons 10
  • 11. What is hardware tracing? Cont. ● Self-hosted trace 11
  • 12. What is hardware tracing? Cont. ● Pros – – ● Self-contained, facilities can be used by host OS No need for special hardware – Limited internal buffer space – Might impact system performance Cons 12
  • 13. Hardware tracing support ● ARM – – Program Trace Flow Macrocell (PTM), – ● Embedded Trace Macrocell (ETM), System Trace Macrocell (STM) PowerPC – – ● Freescale QorIQ with Nexus tracing Branch History Rolling Buffer (BHRB) – Intel Processor Tracing (PT) – Last Branch Record (LBR), Branch Trace Store (BTS) Intel 13
  • 14. Hardware tracing vs. software tracing ● Software tracing: – – Can be intrusive – Can be slow – ● Static instrumentation or dynamic code patching Tracepoint level granularity Hardware tracing: – Tracing done on hardware – Instrumentation not required – Instruction level granularity 14
  • 15. Why hardware tracing is useful  15
  • 16. Why hardware tracing is useful  Profiling – Very fine granularity profiling  Performance measurement  Code coverage  Monitoring – Statistics on application currently running? 16
  • 17. Why hardware tracing is useful cont.  Snapshot on crash/anomaly – Trace overwrites old data until anomaly detected  Event trigger trace  Hardware-assisted software tracing – Use hardware facility (ringbuffer) 17
  • 18. ARM Coresight & ETM  18
  • 19. ARM Coresight ● Coresight – – Trace and debug a complete SoC – ● Collection of hardware components Open architecture Trace source – Processing elements (CPU, DSP, etc.) – Buses – System trace (generated from software) 19
  • 20. ARM ETM ● ETM – Monitor the core internal bus – Instructions + data trace – Hardware filters and triggers – Trace stream compression – Traces can be saved in internal buffer (ETB) or shared system memory 20
  • 22. State of Coresight & ETM in Linux ● ETM tracer implementation available in Linux – ● Coresight support status – ● Seems to work only on specific hardware Framework patchset proposed by Pratik Pratel [3] Trace decoder availability? 22
  • 23. Interested about Coresight/ETM? “Hardware Trace in the Kernel” BoF by Pawel Moll from ARM Today, 4:30 PM in Pentland 23
  • 24. Freescale QorIQ & Nexus tracing  24
  • 25. Freescale QorIQ ● PowerPC based platform targeted for high-performance communications usage – Multiple e500mc processors, – DPAA support (packet processing offloading), – Support the Nexus debugging & tracing standard. Source: radiolocman 25 [4]
  • 26. Nexus standard ● ● ● ISO standard for debugging embedded systems (IEEEISTO-5001-2003), Designed for low pin count, standard set of connectors (JTAG or Debug port), Multiple level of Nexus “compliance”. 26
  • 27. Nexus standard level ● Level 1: – – ● Run time control only (run, stop, breakpoints, etc.) Tracing not supported Level 2: – ● Level 3: – ● Ownership and program trace Data write trace & memory read/write on the fly Level 4: – Memory substitution – Trace triggering via a watchpoint 27
  • 28. Nexus standard format ● Packet based output format, – Standard defines public messages, vendors can define extensions (TCODES) – Fixed packet size per message, last packet can be of variable length – Message can have an optional timestamp 28
  • 29. Example decoded Nexus message Message # 328 TCODE : 2 Ownership Trace Message SRC ID : 0 Core0 / CPU0 (Clst0:Core0:Thread0) PID INDEX : 0x02 - Sync PID PID VALUE : 0x01e01bf59c - LPIDR, MSR[GS], PID/NPIDR (ref:DC1[OTS]), MSR[PR] TIMESTAMP : 1140061 (0x11655d) Message # 329 TCODE : 27 Resource Full Message SRC ID : 0 Core0 / CPU0 (Clst0:Core0:Thread0) RCODE : 0x8 - Timestamp counter RDATA : 0x00ffffff TIMESTAMP : 0 (0x0) 29
  • 30. State of Nexus in Linux ● Nexus qoriq-debug kernel module, – Available in Freescale QorIQ SDK Yocto Layer – Implements a debugfs with memory mapped access to Nexus control register – cat /sys/kernel/debug/npc/trace_buffer > trace 30
  • 31. Nexus debugfs root@p3041ds:~# ls -al /sys/kernel/debug/qoriq-dbg [...] drwxr-xr-x 2 root root 0 Aug 6 20:22 cpu0 drwxr-xr-x 2 root root 0 Aug 6 20:22 cpu1 drwxr-xr-x 2 root root 0 Aug 6 20:22 cpu2 drwxr-xr-x 2 root root 0 Aug 6 20:22 cpu3 drwxr-xr-x 2 root root 0 Aug 6 20:22 ddr1 drwxr-xr-x 2 root root 0 Aug 6 20:22 dpaa [...] drwxr-xr-x 2 root root 0 Aug 6 20:22 npc drwxr-xr-x 2 root root 0 Aug 6 20:22 nxc [...] root@p3041ds:~# ls -al /sys/kernel/debug/qoriq-dbg/cpu0 [...] -rw-rw-rw- 1 root root 0 Aug 6 20:22 dc1 -rw-rw-rw- 1 root root 0 Aug 6 20:22 dc2 -rw-rw-rw- 1 root root 0 Aug 6 20:22 dc4 --w--w--w- 1 root root 0 Aug 6 20:22 ddam [...] 31
  • 32. State of Nexus in Linux ● Nexus decoder availability – ● Released as part of the babeltrace project Open-source software to reconstruct program flow not yet developed – Integrate such functionality in an IDE ? perf? 32
  • 33. LTTng & Hardware tracing  33
  • 35. Tracers ● ● lttng-modules: kernel tracer module, compatible with kernels from 2.6.38* to 3.11, lttng-ust: user-space tracer, in-process library. * Kernel tracing is now possible on 2.6.32 to 2.6.37 by backport of 3 Linux Kernel patches [1]. 35
  • 36. Utilities  ● lttng-tools: cli utilities and daemons for trace control, – lttng: cli utility for tracing control, – lttng-sessiond: tracing registry daemon, – lttng-consumerd: consume trace data, – lttng-relayd: network streaming daemon. 36
  • 37. Viewers  ● ● ● babeltrace: cli text viewer, trace converter, plugin system, lttngtop: ncurse top-like viewer, Eclipse lttng plugin: front-end for lttng, collect, visualize and analyze traces, highly extensible. 37
  • 38. Hardware tracing support ● Initial attempt to support hardware tracing: – – ● Babeltrace Nexus to CTF converter [5] Goal: Leverage existing traces visualizer Encountered issues: – Traces are not self-contained, need sideband information – Internal trace buffer size limitation – Synchronization with other traces can be tricky 38
  • 39. Hardware tracing support demo DEMO 39
  • 40. Future work ● ● ● Decoder/Converter for ARM ETM? Control hardware tracing facilities with the lttngtools command-line? Custom views for hardware traces in Eclipse plugin 40
  • 41. Conclusion ● Availability and usefulness of hardware tracing ● Initial support for self-hosted hardware tracing ● Common abstraction for hardware tracing in the Linux kernel? 41
  • 42. Questions ? ?  www.efficios.com  lttng.org  lttng-dev@lists.lttng.org  @lttng_project 42
  • 43. References [1] - http://www.arm.com/images/processor/Cortex-A9-osprey.jpg [2] - http://www.arm.com/images/CoreSight_Diagram_Tiny.jpg [3] - https://lkml.org/lkml/2012/12/19/331 [4] - http://www.rlocman.ru/i/Image/2010/06/24/2.jpg [5] - https://github.com/cbab/babeltrace/tree/nexus 43