From: Felix Fietkau <nbd@nbd.name>
To: Vincent Whitchurch <Vincent.Whitchurch@axis.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"joabreu@synopsys.com" <joabreu@synopsys.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"peppe.cavallaro@st.com" <peppe.cavallaro@st.com>,
"alexandre.torgue@st.com" <alexandre.torgue@st.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
kernel <kernel@axis.com>
Subject: Re: [PATCH net] net: stmmac: Use hrtimer for TX coalescing
Date: Fri, 25 Aug 2023 19:38:18 +0200 [thread overview]
Message-ID: <a4ee2e37-6b2f-4cab-aab8-b9c46a7c1334@nbd.name> (raw)
In-Reply-To: <2e1db3c654b4e76c7249e90ecf8fa9d64046cbb8.camel@axis.com>
On 25.08.23 15:42, Vincent Whitchurch wrote:
> On Wed, 2023-08-23 at 22:18 +0200, Felix Fietkau wrote:
>> Based on tests by OpenWrt users, it seems that this one is causing a
>> significant performance regression caused by wasting lots of CPU cycles
>> re-arming the hrtimer on every single packet. More info:
>> https://github.com/openwrt/openwrt/issues/11676#issuecomment-1690492666
>
> It looks like there was an attempt to avoid the re-arming of the timer
> in ->xmit() a while ago (pre-dating the hrtimer usage) in commit
> 4ae0169fd1b3c792b66be58995b7e6b629919ecf ("net: stmmac: Do not keep
> rearming the coalesce timer in stmmac_xmit"), but that got reverted
> later due to regressions. The coalescing code has been reworked since
> then but the removal of the re-arming was never attempted again.
>
>> My suggestion for fixing this properly would be:
>> - keep a separate timestamp for last tx packet
>> - do not modify the timer if it's scheduled already
>> - in the timer function, check the last tx timestamp and re-arm the
>> timer if necessary.
>
> Would you mind explain the reasons for maintaining a timestamp and
> checking it in the expiry function? Is that to obtain the same effect
> as the driver's current behaviour of postponing the expiry of the timer
> for each packet?
Exactly. I did something very similar in mac80211 in the past, when
expensive mod_timer calls were showing up in my perf measurements.
Functionally it should be the same, it just avoids excessive re-sorting
in timer data structures.
> Is that really desired? According to the commit
> message in 4ae0169fd1b3c792b66be58995b7e6b629919ecf, "Once the timer is
> armed it should run after the time expires for the first packet sent and
> not the last one."
>
> Since the timer expiry function schedules napi, and the napi poll
> function stmmac_tx_clean() re-arms the timer if it sees that there are
> pending tx packets, shouldn't an implementation similar to hip04_eth.c
> (which doesn't save/check the last tx timestamp) be sufficient?
To be honest, I didn't look very closely at what the timer does and how
coalescing works. I don't know if delaying the timer processing with
every tx is the right choice, or if it should be armed only once.
However, as you pointed out, the commit that dropped the re-arming was
reverted because of regressions.
My suggestions are intended to preserve the existing behavior as much as
possible (in order to avoid regressions), while also achieving the
benefit of significantly reducing CPU cycles wasted by re-arming the timer.
- Felix
next prev parent reply other threads:[~2023-08-25 17:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 15:02 [PATCH net] net: stmmac: Use hrtimer for TX coalescing Vincent Whitchurch
2020-11-24 0:46 ` Jakub Kicinski
2020-11-24 4:11 ` Vincent Whitchurch
2020-11-24 16:50 ` Jakub Kicinski
2023-08-23 20:18 ` Felix Fietkau
2023-08-25 13:42 ` Vincent Whitchurch
2023-08-25 17:38 ` Felix Fietkau [this message]
2023-08-30 14:55 ` Vincent Whitchurch
2023-08-30 18:05 ` Maxim Mikityanskiy
2023-09-18 12:56 ` Vincent Whitchurch
2023-09-19 17:53 ` Maxim Mikityanskiy
2023-08-30 21:06 ` Felix Fietkau
2023-09-01 11:31 ` Vincent Whitchurch
2023-09-01 11:53 ` Felix Fietkau
2023-09-08 10:42 ` Vincent Whitchurch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a4ee2e37-6b2f-4cab-aab8-b9c46a7c1334@nbd.name \
--to=nbd@nbd.name \
--cc=Vincent.Whitchurch@axis.com \
--cc=alexandre.torgue@st.com \
--cc=davem@davemloft.net \
--cc=joabreu@synopsys.com \
--cc=kernel@axis.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).