Re: [PATCH] net: af_packet: add af_packet hrtimer mode
From: Xin Zhao <hidden>
Date: 2025-08-08 07:44:30
Also in:
lkml
On Wed, 2025-08-08 at 14:01 +0800, Eric wrote:
I have some doubts why AF_PACKET timer would be involved in the performance of an application. Are you sure about your requirements ? I do not know what application you are running, but I wonder if using TX timestamps, and EDT model to deliver your packets in a more accurate way would be better. Some qdiscs already use hrtimer and get sub 50 usec latency out of the box, or whatever time a cpu sleeping in deep state takes to wake up.
Dear Eric, Let me explain our requirements. Initially, we used regular UDP reception function to process LiDAR data packets, and at that time, the packet latency was acceptable. However, due to insufficient CPU resources on our system, we needed to optimize the CPU consumption of various tasks, including the task of processing LiDAR data packets. Therefore, our original requirement was to reduce the CPU consumption and context switching overhead of the program that processes LiDAR data. To achieve this, we employed the AF_PACKET + MMAP programming model and found that it indeed resulted in significant improvements. However, we noticed a side effect: even with a 2-millisecond retire timeout set, the processing latency for received packets still fluctuated to over 8 milliseconds. Nevertheless, we still wanted to continue using the AF_PACKET + MMAP programming model to improve CPU utilization. Therefore, we modified the implementation of AF_PACKET and switched to using hrtimer, which resulted in keeping the processing latency within 2 milliseconds. In this way, we can continue to use the AF_PACKET + MMAP programming model to optimize the LiDAR processing tasks. Thanks Xin Zhao