<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>I've been working on this issue occasionally for a 2+ years now.
      Unfortunately, it is not easy to solve and substantiated
      information on it is also hard to come by.</p>
    <p>My current, **empirically founded** solution to get interfering
      interrupts down as much as possible is the following (last tested
      about a year ago with kernel ~5.10):</p>
    <ol>
      <li>Don't run anything on CPU 0. It's the boot CPU and may run
        some Linux voodoo that cannot be transferred to other CPUs. Read
        this somewhere, but haven't been able to substantiate that.
        Also, disable SMT or keep the SMT-siblings isolated, too, to
        avoid contention on cache and memory. May both be superstition,
        but I don't see any potential down-side to it.<br>
      </li>
      <li>Use real-time priority (SCHED_FIFO w/ priority 99) for the
        DPDK threads and<br>
        echo -1 > /proc/sys/kernel/sched_rt_runtime_us<br>
        to disable the runtime limit. With the runtime limit in place,
        the SCHED_FIFO performance will be significantly worse than
        SCHED_OTHER.<br>
      </li>
      <li>Use the following kernel command line (similar to yours;
        isolates all but 2 cores on a 12 core machine):<br>
        isolcpus=nohz,domain,2-11,14-23 nohz_full=2-11,14-23
        rcu_nocbs=2-11,14-23 rcu_nocb_poll irqaffinity=0-1,12-13<br>
        Note that this only works properly with a NO_HZ kernel. The
        kernel boot log should contain an error message if above
        parameters are used on a non-NO_HZ kernel.<br>
        I compile my kernel with the following config enabled:
        NO_HZ_FULL, RCU_NOCB_CPU, CONTEXT_TRACKING_FORCE</li>
      <li>Force remaining interrupts off the isolated CPUs by first
        stopping all of them and subsequently starting them again (some
        interrupts may remain on the isolated CPUs regardless of
        irqaffinit=; mileage may vary):<br>
        for CPU in $CPU_LIST ;<br>
            do echo 0 > /sys/devices/system/cpu/cpu$CPU/online<br>
        done<br>
        for CPU in $CPU_LIST ;<br>
            do echo 1 > /sys/devices/system/cpu/cpu$CPU/online<br>
        done</li>
      <li>Check which interrupts still occur on the isolated CPUs while
        running your DPDK progam via /proc/interrupts. I've had issues
        with some hardware drivers' interrupts (e.g., RAID controllers)
        refusing to be kicked off the isolated CPUs despite all of the
        above. Try to move your sensitive threads to different CPUs.<br>
      </li>
      <li>Despair. Even if you succeed in getting all hardware
        interrupts disabled, the kernel will still occasionally
        interrupt your program, e.g., for some accounting business.</li>
    </ol>
    <p>The last point is where intervention from the kernel side is
      required. Work on that has been underway for several years
      [1,2,3], but nothing has been mainlined yet.</p>
    <p>Hope this helps. We've been able to get worst case packet
      forwarding jitter down to less than 10 µs, with anything above 3
      µs being very rare (see attached histogram; your mileage may vary;
      measured by comparing TSC values between DPDK rx and tx calls).</p>
    <p>Best regards,<br>
      Carsten<br>
    </p>
    <p>[1] <a class="moz-txt-link-freetext" href="https://lwn.net/Articles/659490/">https://lwn.net/Articles/659490/</a><br>
      [2] <a class="moz-txt-link-freetext" href="https://lwn.net/Articles/816298/">https://lwn.net/Articles/816298/</a><br>
      [3]
<a class="moz-txt-link-freetext" href="https://lore.kernel.org/lkml/20220315153132.717153751@fedora.localdomain/">https://lore.kernel.org/lkml/20220315153132.717153751@fedora.localdomain/</a><br>
    </p>
    <div class="moz-cite-prefix">On 23.06.22 20:03, Antonio Di Bacco
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAO8pfF=yo37Ng5QAcopL=6LgKMHr4+=pPcONPATyS+OD0GLgfg@mail.gmail.com">
      <pre class="moz-quote-pre" wrap="">I'm running a DPDK thread on an isolated core. I also set some  flags
that could help keeping the core at rest on linux like: nosoftlockup
nohz_full rcu_nocbs irqaffinity.

Unfortunately the thread gets some interruptions that stop the thread
for about 20-30 micro seconds. This seems smal but my application
suffers a lot.

I also tried to use  rte_thread_set_priority that indeed has a strong
effect but unfortunately creates problems to Linux (like network not
working).

Is there any other knob that could help running the DPDK thread with
minimum or no interruptions at all?
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">
</pre>
  </body>
</html>