Re: [PATCH] net: af_packet: add af_packet hrtimer mode

From: Xin Zhao
Date: Fri Aug 08 2025 - 00:33:58 EST


On Wed, 2025-08-06 at 15:25 +0800, Ferenc wrote:

> Do you have performance numbers? It would be nice to see the test environment,
> measurements carried out and some latency/jitter numbers.

Dear Ferenc,

We test it on 6.1.134 rt-linux version, we set 2ms as the retire timeout, the
following test result describe the packet details including cur_ts_us(time when
the sample code handle the packet) and cur_pk_ts_us(time when the packet send)
and delay(time unit is us, the gap between cur_ts_us and cur_pk_ts_us).
Test result before change to hrtimer:
--------num_pkts:54--------
pack_size_:902, atx_udp_seq:86152515, cur_ts_us:[1749707679501254], cur_pkg_ts_us:[1749707679492443], delay:8811
pack_size_:902, atx_udp_seq:86152516, cur_ts_us:[1749707679501260], cur_pkg_ts_us:[1749707679492590], delay:8670
pack_size_:902, atx_udp_seq:86152517, cur_ts_us:[1749707679501266], cur_pkg_ts_us:[1749707679492737], delay:8529
pack_size_:902, atx_udp_seq:86152518, cur_ts_us:[1749707679501274], cur_pkg_ts_us:[1749707679492884], delay:8391
...
Test result after change to hrtimer:
--------num_pkts:14--------
pack_size_:902, atx_udp_seq:42679600, cur_ts_us:[1750220805104634], cur_pkg_ts_us:[1750220805101776], delay:2858
pack_size_:902, atx_udp_seq:42679601, cur_ts_us:[1750220805104635], cur_pkg_ts_us:[1750220805101923], delay:2712
pack_size_:902, atx_udp_seq:42679602, cur_ts_us:[1750220805104636], cur_pkg_ts_us:[1750220805102074], delay:2562
pack_size_:902, atx_udp_seq:42679603, cur_ts_us:[1750220805104638], cur_pkg_ts_us:[1750220805102223], delay:2415
...
In our system, we care about the delay value, cpu usage and context switches.
Use af_packet the cpu usage of the lidar process change from about 16.91% to
12.92%, the context switches change from about 900+ per second to 400+ per
second. The benefits of using AF_PACKET are significant enough that we need
to adopt it. After using hrtimer instead of timer, the impact of the delay
has also been controlled, which is what we hoped for.

Thanks
Xin Zhao