Deploying Lttng on Exotic Embedded Architectures

Deploying Lttng on Exotic Embedded Architectures

Deploying LTTng on Exotic Embedded Architectures Mathieu Desnoyers Michel R. Dagenais École Polytechnique de Montréal École Polytechnique de Montréal [email protected] [email protected] Abstract shipping LTTng with their Linux distribution to provide similar features as in VxWorks. Mon- tavista also integrates LTTng to their Carrier This paper presents the considerations that Grade Linux distribution. comes into play when porting the LTTng tracer to a new architecture. Given the aleady portable LTTng currently supports the following archi- design of the tracer, very targeted additions can tectures : enable tracing on a great variety of architec- tures. The main challenge is to understand the architecture time-base in enough depth to • X86 32/64 integrate it to LTTng by creating a lock-less fast and fine-grained trace clock. The ARM • MIPS OMAP3 LTTng port will be used as an exam- ple. • PowerPC 32/64 • ARM1 1 Introduction • S390 2 Gathering an execution trace at the operating • Sparc 32/643 system level has been an important part of the embedded system development process, as il- • SH644 lustrates the case of the Mars Pathfinder[5] pri- ority inversion, solved by gathering an execu- tion trace. This paper presents the key abstractions re- In the Linux environment, such system-wide quired to port LTTng to a new architecture, facility is just becoming accepted in the main- mainly describing what considerations must be line kernel, but with the kernel developer audi- taken into account when designing a trace clock ence as main target. The portability issues and time source suitable for tracing, meeting the lack of user-oriented tools to manipulate the platform-specific constraints. information may be indications of two points 1Limited time-stamping precision where the current state of Linux kernel tracing 2Partial instrumentation is not up to the tools embedded systems devel- 3Partial instrumentation opers are used to. For instance, WindRiver is 4Partial instrumentation 1 2 State of the Art 3.1 Instrumentation Looking at some of the most widely used open- First, the instrumentation must be expanded to source tracing alternatives, we can see that include some architecture-specific events. Dtrace[3], Ftrace (as of Linux kernel 2.6.29) and SystemTAP [4] are three of the solutions System call instrumentation has to be added at that are the closest to LTTng. system call entry and exit syscall_trace. LTTng already adds a thread flag to the low-level ker- Dtrace does not require the same level of porta- nel assembly to call into the standard system bility, given Solaris only targets Intel x86 and call tracing callback of each architecture sup- Sparc architectures. Therefore, this tracer as- ported by the Linux kernel. sumes access to a time-stamp counter register. Given that LTTng instrumentation covers Ftrace uses the scheduler time-source due to its architecture-agnostic sites for most of its event low performance impact. However, on 32-bits sources, only few supplementary architecture- architecture, this time-source is using 64-bits specific tracepoints are required : variables without using the proper sequence lock synchronization primitives. While having a scheduler doing a wrong decision once in a • kernel_thread_create while is acceptable, having incorrect timing in- formation in a trace can be very confusing. • syscall_trace 5 SystemTAP is using the time source primitives • ipc_call provided by the Linux kernel. Those are tak- • trap_entry, trap_exit ing a sequence lock to protect non-atomic data structure accesses. This implies that instrumen- • page_fault_entry, page_fault_exit tation coverage cannot include non-maskable interrupt handlers NMIs, because a NMI tak- ing a sequence read lock nested over a sequence In some cases (x86 for instance), a few interrupt write lock would deadlock. handlers do not use the architecture-agnostic code to connect to their interrupt vector. In those cases, new irq_entry and irq_exit events are needed in the architecture code. 3 Porting LTTng to a new architec- ture 3.2 Time Source In the case of LTTng, even though it uses very efficient binary buffers to extract the data out of 3.2.1 Architectural Variety kernel-space, all its design deals with type size and endianness issues by making sure the infor- The time sources available on different archi- mation written in the trace is self-described by tectures vary greatly. On x86-based architec- a meta-data information channel. tures, the tsc register[2][6] can usually be used as a fast and fine-grained time source. The We will now see what work still has to be done when porting LTTng to a new architecture. 5IPC : Inter-Process Communication 2 PowerPC has the tb register which allows all The tracer also needs the timer presented to the cores to read a common time source through a tracer to appear as being reasonably synchro- register read. nized across cores. At least, a maximum bound on the time precision error should be ensured. However, embedded architectures like ARM and MIPS usually either depend on an external The time-base needs to be fast, given it has to memory-mapped I/O timer to provide a time- be read for each event record. This can eas- source, or on a 32-bits only register read. ily drag system’s resources. It also needs to be scalable if the architecture aims at supporting One of the main problems encountered with SMP. Any data structure used to keep track of tracing clock source design is the different lim- time-base state should be designed so it can be itations founds in various architectures. For in- read from any context. Therefore, locking must stance, MIPS and ARM only provide 32-bits be chosen with great care. clock sources, either through a local register or through external memory mapped I/O. These counters overflow too frequently to be usable 3.2.3 Design Considerations per se without being extended to 64-bits. Given those requirements, some design choices Some architectures provide fast register-based become clear. First, whenever a cycles counter time counters that are not synchronized across register is available on the architecture, it cores. In those cases, more evolved algorithms should be used as a per-event time source. must be deployed to make the time base appear reasonably synchronized across cores. External memory-mapped I/O timers should only be used as a time source when strictly re- Yet another problem faced is that some archi- quired, because they are typically much slower tectures (e.g. ARM OMAP3) stops the CPU than the cycle counter register, and do not scale time base register counter in sleep modes. The well. The HPET6 has been measured to add re- same appears on various AMD and Intel pro- spectively a 10%, 11% and 19% performance cessors which stop the tsc register during idle. impact to LTTng on 1, 2 and 8 cores, while the performance impact is constant with a scalable time-source like the cycle counter. However, those external timer counters can be useful to 3.2.2 Characteristics Required resynchronize the cycle counter when coming back from sleep or idle, if these events do not The main concern, when porting LTTng to a occur too frequently. different architecture, is to create a trace clock suited to the architecture restrictions which of- Regarding locking, the sequence lock (seqlock) fers the following characteristics. should be avoided, because it would cause deadlocks if used in a NMI handler. It would LTTng relies on a 64-bits monotonic time base also deadlock if instrumentation is added to a available system-wide. 32-bits would be too code path protected by the write sequence lock. few, given it would overflow every 4.29 sec- The best solution is therefore to use RCU-like onds at 1 GHz. A channel only recording rare algorithms to manage data updates. It lets any events would not allow to detect longer time deltas accurately. 6HPET : High-Precision Event Timer[1] 3 reader context successfully read a valid copy of 5 Variable Frequency Support Dis- the data. cussion Extension of 32-bits to 64-bits timestamps is provided by the LTTng trace-clock-32-to-64 Architectures like the ARM OMAP3 and some module, which lets any kernel context read the AMD and Intel processors base the time-stamp 64-bits time-base atomically using a RCU-like counter register on the CPU’s frequency, which algorithm. may vary depending on various conditions. The kernel can ask the frequency to be continu- ously adapted to match the workload, tempera- ture sensors can slow down the CPU frequency 4 ARM OMAP3 Example to make sure it does not overheat, etc. This frequency modulation is usually done per-core, which means that the cycle counter register will Those general guidelines being drawn, this sec- be non-synchronized across cores. Newer Intel tion shows how they can be applied to a real-life and AMD architectures fix this issue by letting scenario. This involves porting LTTng to the the tsc register run at a lower, synchronized, ARM OMAP3 architecture. frequency. The ARM OMAP3 has a 31-bits (usable) cy- However, those architectures with non- cle counter register called ccnt. A hardware synchronized cycle counter register still have bug prevents using the 32nd bit because of a to be supported. If we are lucky, the OS is race between the CP14 and CP15 coprocessor informed of the frequency change and calls register accesses and the ccnt register overflow. a notifier chain. In the opposite case, e.g. The solution is to periodically clear the high or- some AMD CPUs, the speed is throttled by the der bit to make sure overflow never happens.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us