Re: [PATCH net-next v7] net: af_packet: Use hrtimer to do the retire operation
From: Xin Zhao
Date: Tue Aug 26 2025 - 11:09:42 EST
On Tue, 2025-08-25 at 20:54 +0800, Willem wrote:
> > I understand that the additional in_scheduled variable is meant to prevent
> > multiple calls to hrtimer_start. However, based on the current logic
> > implementation, the only scenario that would cancel the hrtimer is after calling
> > prb_shutdown_retire_blk_timer. Therefore, once we have called hrtimer_start in
> > prb_setup_retire_blk_timer, we don't need to worry about the hrtimer stopping,
> > and we don't need to execute hrtimer_start again or check if the hrtimer is in
> > an active state. We can simply update the timeout in the callback.
>
> The hrtimer is also canceled when the callback returns
> HRTIMER_NORESTART.
In prb_retire_rx_blk_timer_expired function, the only way to return HRTIMER_NORESTART
is that the pkc->delete_blk_timer is NOT 0.
The delete_blk_timer is only set to 1 in prb_shutdown_retire_blk_timer which is called
by packet_set_ring.
In my understanding, once packet_set_ring is called and prb_shutdown_retire_blk_timer
is executed, the only way to make this af_packet work again is to call packet_set_ring
again to execute prb_setup_retire_blk_timer. At that point, hrtimer_start will be
called again. Therefore, I feel that there is no need to perform the check in
_prb_refresh_rx_retire_blk_timer. Only let prb_setup_retire_blk_timer to hrtimer_start,
is that right?
Thanks
Xin Zhao