Re: [PATCH v2] net: stmmac: Improve Tx timer arm logic further
From: Andrew Lunn
Date: Wed May 27 2026 - 21:58:46 EST
> pre-patch behaviour. The meaning of tx_coal_timer is unchanged.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 3591755ea30b..35da51c26248 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -3341,12 +3341,14 @@ static void stmmac_tx_timer_arm(struct stmmac_priv *priv, u32 queue)
> * Try to cancel any timer if napi is scheduled, timer will be armed
> * again in the next scheduled napi.
> */
> - if (unlikely(!napi_is_scheduled(napi)))
> - hrtimer_start(&tx_q->txtimer,
> - STMMAC_COAL_TIMER(tx_coal_timer),
> - HRTIMER_MODE_REL);
> - else
With this code, the timer is always tx_coal_timer in the future.
> + if (unlikely(!napi_is_scheduled(napi))) {
> + if (unlikely(!(hrtimer_active(&tx_q->txtimer))))
> + hrtimer_start(&tx_q->txtimer,
> + STMMAC_COAL_TIMER(tx_coal_timer),
> + HRTIMER_MODE_REL);
If the timer is not active, it is set to tx_coal_timer in the
future. However, if the timer is active, meaning it is already
counting down, it is left alone, so is less than tx_coal_timer in the
future.
Do i have this right?
Doesn't that change the meaning of the timer. It now actually goes off
sooner?
This is somewhat academic. The point of coalescence is to reduce
overheads. The increase in performance shows that this change does
reduce overheads.
Andrew