xdp-tutorial icon indicating copy to clipboard operation
xdp-tutorial copied to clipboard

xdp/kernel poll time from nic can be reduced ?

Open Adarsh97 opened this issue 3 years ago • 3 comments

The requirement is like if I am receiving 2 packets with interval of 10 micro second (example value), then xdp(kernel) has to be time stamped the packet with 10 micro second gap, what is currently observing is i am time stamping from xdp (kernel space) with bpf_ktime_get(), but many packets are getting nearly equal times with nano second gap, what i am suspecting is the polling happen in fixed interval only, so within that interval many packets has arrived, then all of them processed nearly at the same time. So is there any way to avoid this process of taking packet together for processing, I want to time stamp each packet at the time they have arrived.

Adarsh97 avatar Apr 25 '21 13:04 Adarsh97

Adarsh Sunilkumar @.***> writes:

The requirement is like if I am receiving 2 packets with interval of 10 micro second (example value), then xdp(kernel) has to be time stamped the packet with 10 micro second gap, what is currently observing is i am time stamping from xdp (kernel space) with bpf_ktime_get(), but many packets are getting nearly equal times with nano second gap, what i am suspecting is the polling happen in fixed interval only, so within that interval many packets has arrived, then all of them processed nearly at the same time. So is there any way to avoid this process of taking packet together for processing, I want to time stamp each packet at the time they have arrived.

Yeah, the kernel processes packets in batches due to NAPI. Nothing much that can be done about this; if you want more accurate timestamps you'll have to get them from the hardware. There's work in progress to support this from XDP as well...

tohojo avatar Apr 25 '21 19:04 tohojo

Can I reduce kernel polling time to get better accuracy in time stamping ? or can i go from polling to interrupt driven mechanism ?

Adarsh97 avatar Apr 28 '21 14:04 Adarsh97

Adarsh Sunilkumar @.***> writes:

Can I reduce kernel polling time to get better accuracy in time stamping ? or can i go from polling to interrupt driven mechanism ?

You can tune the device IRQ settings and adjust the NAPI budget - see lots of details on network stack tuning here:

https://blog.packagecloud.io/eng/2016/06/22/monitoring-tuning-linux-networking-stack-receiving-data/#tuning-network-data-arrival

However do note that interrupt processing itself has non-negligible overhead, so you may not actually get better performance from this...

tohojo avatar Apr 29 '21 10:04 tohojo