• Steven Rostedt's avatar
    ring-buffer: add benchmark and tester · 5092dbc9
    Steven Rostedt authored
    This patch adds code that can benchmark the ring buffer as well as
    test it. This code can be compiled into the kernel (not recommended)
    or as a module.
    
    A separate ring buffer is used to not interfer with other users, like
    ftrace. It creates a producer and a consumer (option to disable creation
    of the consumer) and will run for 10 seconds, then sleep for 10 seconds
    and then repeat.
    
    While running, the producer will write 10 byte loads into the ring
    buffer with just putting in the current CPU number. The reader will
    continually try to read the buffer. The reader will alternate from reading
    the buffer via event by event, or by full pages.
    
    The output is a pr_info, thus it will fill up the syslogs.
    
      Starting ring buffer hammer
      End ring buffer hammer
      Time:     9000349 (usecs)
      Overruns: 12578640
      Read:     5358440  (by events)
      Entries:  0
      Total:    17937080
      Missed:   0
      Hit:      17937080
      Entries per millisec: 1993
      501 ns per entry
      Sleeping for 10 secs
      Starting ring buffer hammer
      End ring buffer hammer
      Time:     9936350 (usecs)
      Overruns: 0
      Read:     28146644  (by pages)
      Entries:  74
      Total:    28146718
      Missed:   0
      Hit:      28146718
      Entries per millisec: 2832
      353 ns per entry
      Sleeping for 10 secs
    
    Time:      is the time the test ran
    Overruns:  the number of events that were overwritten and not read
    Read:      the number of events read (either by pages or events)
    Entries:   the number of entries left in the buffer
                     (the by pages will only read full pages)
    Total:     Entries + Read + Overruns
    Missed:    the number of entries that failed to write
    Hit:       the number of entries that were written
    
    The above example shows that it takes ~353 nanosecs per entry when
    there is a reader, reading by pages (and no overruns)
    
    The event by event reader slowed the producer down to 501 nanosecs.
    
    [ Impact: see how changes to the ring buffer affect stability and performance ]
    Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
    5092dbc9
ring_buffer_benchmark.c 7.43 KB