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.
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):
- 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.
- Use real-time priority (SCHED_FIFO w/ priority 99) for the
DPDK threads and
echo -1 > /proc/sys/kernel/sched_rt_runtime_us
to disable the runtime limit. With the runtime limit in place,
the SCHED_FIFO performance will be significantly worse than
SCHED_OTHER.
- Use the following kernel command line (similar to yours;
isolates all but 2 cores on a 12 core machine):
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
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.
I compile my kernel with the following config enabled:
NO_HZ_FULL, RCU_NOCB_CPU, CONTEXT_TRACKING_FORCE
- 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):
for CPU in $CPU_LIST ;
do echo 0 > /sys/devices/system/cpu/cpu$CPU/online
done
for CPU in $CPU_LIST ;
do echo 1 > /sys/devices/system/cpu/cpu$CPU/online
done
- 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.
- 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.
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.
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).
Best regards,
Carsten
[1] https://lwn.net/Articles/659490/
[2] https://lwn.net/Articles/816298/
[3]
https://lore.kernel.org/lkml/20220315153132.717153751@fedora.localdomain/
On 23.06.22 20:03, Antonio Di Bacco
wrote:
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?