Re: [PATCH v2] net: stmmac: Improve Tx timer arm logic further
From: Nazle Asmade, Muhammad Nazim Amirul <hidden>
Date: 2026-05-29 06:48:02
Also in:
linux-arm-kernel, lkml
On 28/5/2026 9:58 am, Andrew Lunn wrote:
quoted
pre-patch behaviour. The meaning of tx_coal_timer is unchanged.quoted
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); - elseWith this code, the timer is always tx_coal_timer in the future.quoted
+ 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
Hi Andrew, Yes, you have it right. I have updated the commit message in v3 to correctly describe this behaviour change. Thanks, Nazim