From: Koen Vandeputte <koen.vandeputte@citymesh.com>
To: netdev@vger.kernel.org
Cc: quic_subashab@quicinc.com, quic_stranche@quicinc.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, dnlplm@gmail.com,
linux-kernel@vger.kernel.org,
Koen Vandeputte <koen.vandeputte@citymesh.com>
Subject: [PATCH net-next 3/4] net: rmnet: conditionally expand skb headroom in ingress handler
Date: Fri, 2 Oct 2026 16:35:28 +0200 [thread overview]
Message-ID: <20261002143529.3217189-4-koen.vandeputte@citymesh.com> (raw)
In-Reply-To: <20261002143529.3217189-1-koen.vandeputte@citymesh.com>
Currently, when the rmnet driver processes ingress packets for an Ethernet
device (ARPHRD_ETHER), it unconditionally calls pskb_expand_head() to
ensure there is enough room to push the MAC header. This forces a costly
memory reallocation and payload copy for every single packet on the RX
hotpath, severely degrading throughput and increasing CPU overhead.
In many modern architectures, the underlying physical driver (e.g., USB)
can be configured to pre-allocate this extra ETH_HLEN headroom when
minting the initial SKB.
Optimize the ingress path by checking if skb_headroom(skb) < ETH_HLEN
before triggering the expansion. If the packet arrives with sufficient
headroom, the driver now skips the reallocation entirely and safely pushes
the header. The expensive pskb_expand_head() operation is now strictly a
fallback, allowing properly configured hardware to achieve zero-copy MAC
header insertion.
Testing this using a temporary print in the new condition showed that
the expansion is not triggered as enough space is already available.
Signed-off-by: Koen Vandeputte <koen.vandeputte@citymesh.com>
---
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
index aa5523f4618e..95c3e3934fd3 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
@@ -114,9 +114,11 @@ rmnet_map_ingress_handler(struct sk_buff *skb,
u32 data_format;
if (skb->dev->type == ARPHRD_ETHER) {
- if (pskb_expand_head(skb, ETH_HLEN, 0, GFP_ATOMIC)) {
- kfree_skb(skb);
- return;
+ if (skb_headroom(skb) < ETH_HLEN) {
+ if (pskb_expand_head(skb, ETH_HLEN, 0, GFP_ATOMIC)) {
+ kfree_skb(skb);
+ return;
+ }
}
skb_push(skb, ETH_HLEN);
--
2.43.0
next prev parent reply other threads:[~2026-10-02 14:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 14:35 [PATCH net-next 0/4] net: rmnet: optimize hot paths to alleviate CPU/memory bottlenecks Koen Vandeputte
2026-10-02 14:35 ` [PATCH net-next 1/4] net: rmnet: use fast monotonic time for tx aggregation Koen Vandeputte
2026-10-06 15:00 ` netdev-bot+sashiko
2026-10-02 14:35 ` [PATCH net-next 2/4] net: rmnet: optimize rx deaggregation memory allocation Koen Vandeputte
2026-10-06 15:00 ` netdev-bot+sashiko
2026-10-02 14:35 ` Koen Vandeputte [this message]
2026-10-06 15:00 ` [PATCH net-next 3/4] net: rmnet: conditionally expand skb headroom in ingress handler netdev-bot+sashiko
2026-10-02 14:35 ` [PATCH net-next 4/4] net: rmnet: optimize rx handler by replacing skb_linearize with pskb_may_pull Koen Vandeputte
2026-10-02 20:48 ` Sean Tranchetti
2026-10-06 9:58 ` Koen Vandeputte
2026-10-06 15:00 ` netdev-bot+sashiko
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=20261002143529.3217189-4-koen.vandeputte@citymesh.com \
--to=koen.vandeputte@citymesh.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dnlplm@gmail.com \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=quic_stranche@quicinc.com \
--cc=quic_subashab@quicinc.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