How do I test and / or benchmark traditional Linux Kernel vs Linux Kernel with RT Preempt patch?

376 views Asked by At

I am working on a project to contrast and observe the performance gain with Preempt RT patch for Linux.

What kind of C programs should I look to execute on the two different kernels to gain good understanding of the benifits that Preempt RT patch offers.

Looking for suggestions on the programs.

1

There are 1 answers

0
Clifford On

To compare/demonstrate specifically the scheduling characteristics perhaps implement a system where:

  1. An interrupt is generated via a digital input IN
  2. The interrupt handler passes the input event via a semaphore to a high priority user process.
  3. The user process, on receipt of the semaphore creates a (say) 10ms pulse on a digital output OUT.

Then:

  1. Drive IN with a series of pulses from a signal generator
  2. Attach an oscilloscope to IN and OUT.
  3. Trigger the scope on the active (interrupt generating) edge of IN
  4. Measure the time and variance between the interrupt-edge on IN and the start of the pulse on OUT.
  5. Trigger the scope on the rising edge of the pulse on OUT.
  6. Measure the length and variance of the pulse width.

Most modern scopes have a "persistence" feature where the trace is not cleared between sweeps. That is useful for measuring the variance.

If you lack a scope or a signal/function generator, you could use a switch, and software timestamps in the ISR and in the user process to log event times. But you would need to ensure in the user task that no preemption occurs between capturing the time and setting the OUT state by using a critical section, and will likely need to debounce the switch. That, in the case would simply be a matter of not setting the semaphore if the last event timestamp was less than say 20ms ago.

If PREEMPT-RT is doing its job, the tests should exhibit lower latency, greater precision and less variance than with the default scheduler regardless of the load of other (lower priority) processes running. If that still does not meet your requirements you may need a real RTOS.

If this characteristic is not your application requires, then you may not need or benefit from PREEMPT-RT and inappropriate allocation of process priorities or poor task design may even cause your application to fail to meet requirements. To make PREEMPT-RT work you have to know what you are doing; it does not magically make your system "real-time"; rather it facilitates the implementation of real-time systems.