1

Say on a non-RT Linux kernel (4.14, Angstrom distro, running on iMX6) I have a program that receives UDP packets (< 1400 bytes) that come in at a very steady data rate. Basically,

  • the essence of the program is:

    while (true)
    {  recv( sockFd, ... );
       update_loop_interval_histogram(); // O(1)
    }
    
  • To minimize the maximally occuring delay time (loop intervals), I started my process with:

    chrt --fifo 99 ./programName
    

    setting the scheduler to a "real-time" mode SCHED_FIFO with highest priority.

  • the CPU affinity of my process is fixed to the 2nd core.

  • Next to that, I ran a benchmark program instance per core, deliberately getting the CPU load to 100%.

That way, I get a maximum loop interval of ~10ms (vs. ~25ms without SCHED_FIFO). The occurence of this is rare. During e.g. an hour runtime, the counts sum of all intervals <400µs divided by the sum of all counts of all other interval time occurences from 400µs to 10000µs is over 1.5 million. But as rare as it is, it's still bad.

Is that the best one can reliably get on a non-RealTime Linux kernel, or are there further tweaks to be made to get to something like 5ms maximum interval time?

6
  • Does your kernel have CONFIG_PREEMPT enabled?
    – sawdust
    Commented Jan 22, 2019 at 20:23
  • # CONFIG_PREEMPT is not set ---- # CONFIG_PREEMPT_NONE is not set ---- CONFIG_PREEMPT_VOLUNTARY=y
    – sktpin
    Commented Jan 23, 2019 at 9:30
  • So while the test system mentioned above has CONFIG_PREEMPT disabled, I also tested it no a quad core ARM board which had a Linux intallation where CONFIG_PREEMPT was enabled. The highest time I saw there so far was 9ms, and I only ran for ~30min. Not so much difference
    – sktpin
    Commented Jan 23, 2019 at 15:05
  • Are you sure that your UDP source is fast enough? Any proofs? :-)
    – leonp
    Commented Jan 24, 2019 at 9:05
  • 1
    In my long life I have seen many miracles...:-) What I should do is to connect PC via HUB (not switch) and make a recording with wireshark. Check the timing around the point when you see this irregularity. With a good PC wireshark is reliable enough for such a case. My suspect is that IP stack in your HW box still exist and may introduce problems...
    – leonp
    Commented Jan 24, 2019 at 10:47

0