From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3964C1A9FB7; Mon, 25 May 2026 13:47:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779716828; cv=none; b=UzQOy1sF24Si1MvAqP8+ioxP6znsSnfYfOHY4eGRZgpv9roDobWAvPNbfkwCS/xyxI326CXYPEZ7T+q5qyuP54wl+IAV5edFdBmNkHZGDIcsRewkOqqNR6nyY4NyAXfNuoENuqTdYrSoG3g7Bvp48eHhcvmdEBRqzO8tVtTi160= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779716828; c=relaxed/simple; bh=+smIya5lm8hQoqXXzv8KCjOV1fJEMbHjx+8oqMm6QJ0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z1Hf08zLiRP9joksH9MvX0b6FdhIrMZQObM15zEthZNk4KHMkSlaIgacsCG/aJAf5yRAXH5mg/BYcuJkscoG78LP71s/8DsUaRB/XJzpYdx0D6pGFbTPjiMVAmFrVuJg/eUgOi41MnKH9Kwtlhjg+1roT36oLY/anB/UEtxzKfw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=44H9Tv3o; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="44H9Tv3o" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=7ROzJMGxgGji9kSxPsQTiQtOcWhXTsX9E1VNaJINSl8=; b=44H9Tv3oI6aUay45FA2s/0JwiI xqcZvzNObbjcHkA6ToiaO/D7Cuf0OhXKHMdhwy1Xt5F42Bctpy69ENTOH9kJakxHi0bPq0uOzIYRY lRWdycm2s0D7GniP/JyOjR73J5Db7qTxK0HNZ148D0+QZZmS1Bb2MZbGMzYL+FSdcC0M=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1wRVdY-004TZz-Ek; Mon, 25 May 2026 15:46:32 +0200 Date: Mon, 25 May 2026 15:46:32 +0200 From: Andrew Lunn To: muhammad.nazim.amirul.nazle.asmade@altera.com Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, rmk+kernel@armlinux.org.uk, maxime.chevallier@bootlin.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: stmmac: Improve Tx timer arm logic further Message-ID: <3766daef-80d0-4657-935a-579bf17a11d4@lunn.ch> References: <20260525061653.22548-1-muhammad.nazim.amirul.nazle.asmade@altera.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260525061653.22548-1-muhammad.nazim.amirul.nazle.asmade@altera.com> On Sun, May 24, 2026 at 11:16:53PM -0700, muhammad.nazim.amirul.nazle.asmade@altera.com wrote: > From: Nazim Amirul > > Currently hrtimer_start is called even if hrtimer is > active. This is unnecessary and expensive in some targets. > This patch avoids calling hrtimer_start unnecessarily. > > Signed-off-by: Rohan G Thomas > Signed-off-by: Nazim Amirul > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > 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 > + 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); Is there a race condition here? I've not thought about it enough to know if there is/is not. Also, does this change the meaning of tx_coal_timer? I think the commit message needs expanding, to cover these issues. For performance changes, it is also normal to include some performance numbers, before/after, in the commit message. Andrew --- pw-bot: cr