[RTEMS Project] #3665: Add low level event recording infrastructure

RTEMS trac trac at rtems.org
Wed Dec 19 07:01:36 UTC 2018


#3665: Add low level event recording infrastructure
------------------------------+-----------------------------
  Reporter:  Sebastian Huber  |      Owner:  Sebastian Huber
      Type:  enhancement      |     Status:  assigned
  Priority:  normal           |  Milestone:  5.1
 Component:  lib              |    Version:  5
  Severity:  normal           |   Keywords:
Blocked By:                   |   Blocking:
------------------------------+-----------------------------
 Add low level event recording infrastructure for system and user defined
 events. The infrastructure should be able to record high frequency events
 such as

 * SMP lock acquire/release,
 * interrupt entry/exit,
 * thread switches,
 * UMA zone allocate/free,
 * Ethernet packet input/output, etc.

 It should allow post-mortem analysis in fatal error handlers, e.g. the
 last events should be in the record buffer, the newest event overwrites
 the oldest event. It should be possible to detect record buffer overflows
 for consumers that expect a continuous stream of events, e.g. to display
 the system state in real-time.

 The framework should support high-end SMP machines (more than 1GHz
 processor frequency, more than four processors).

 The existing capture engine tries to solve this problem, but its
 performance is not good enough for high-end production systems. The main
 issues are the variable-size buffers and the use of SMP locks for
 synchronization. To fix this, the API would change significantly.

 Add a new API instead. The implementation should use per-processor data
 structures and no atomic read-modify-write operations. It is pretty much a
 per-processor ring buffer for record events.

 Use the CPU counter to get the time of events. Combine it with periodic
 uptime events to synchronize it with CLOCK_REALTIME.

 Here is an example of the
 {{{
 /**
  * @brief Produces a record item.
  *
  * @param event The record event without a time stamp for the item.
  * @param data The record data for the item.
  */
 void rtems_record_produce( rtems_record_event event, rtems_record_data
 data );
 }}}
 function PowerPC machine code generated by GCC:
 {{{
 00000000 <rtems_record_produce>:
    0:   7d 00 00 a6     mfmsr   r8
    4:   7c 00 01 46     wrteei  0
    8:   7d 2e 82 a6     mfspr   r9,526
    c:   7d 50 42 a6     mfsprg  r10,0
   10:   81 4a 02 b4     lwz     r10,692(r10)
   14:   55 29 50 2a     rlwinm  r9,r9,10,0,21
   18:   7d 23 1b 78     or      r3,r9,r3
   1c:   81 2a 00 00     lwz     r9,0(r10)
   20:   80 ca 00 08     lwz     r6,8(r10)
   24:   38 e9 00 01     addi    r7,r9,1
   28:   7d 29 30 38     and     r9,r9,r6
   2c:   55 29 18 38     rlwinm  r9,r9,3,0,28
   30:   7d 2a 4a 14     add     r9,r10,r9
   34:   90 69 00 48     stw     r3,72(r9)
   38:   90 89 00 4c     stw     r4,76(r9)
   3c:   7c 20 04 ac     lwsync
   40:   90 ea 00 00     stw     r7,0(r10)
   44:   7d 00 01 06     wrtee   r8
   48:   4e 80 00 20     blr
 }}}
 Just 19 instructions, no branches, no stack frame, no atomic-read-modify-
 write, just a light weight synchronization to ensure that the consumer
 reads not half finished items.

--
Ticket URL: <http://devel.rtems.org/ticket/3665>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list