From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
Eric Dumazet <edumazet@google.com>
Subject: [PATCH net-next 3/4] net: inline net_is_devmem_iov()
Date: Thu, 22 Jan 2026 04:57:18 +0000 [thread overview]
Message-ID: <20260122045720.1221017-4-edumazet@google.com> (raw)
In-Reply-To: <20260122045720.1221017-1-edumazet@google.com>
1) Inline this small helper to reduce code size and decrease cpu costs.
2) Constify its argument.
3) Move it to include/net/netmem.h, as a prereq for the following patch.
$ scripts/bloat-o-meter -t vmlinux.2 vmlinux.3
add/remove: 0/2 grow/shrink: 0/4 up/down: 0/-158 (-158)
Function old new delta
validate_xmit_skb 866 857 -9
__pfx_net_is_devmem_iov 16 - -16
net_is_devmem_iov 22 - -22
get_netmem 152 130 -22
put_netmem 140 114 -26
tcp_recvmsg_locked 3860 3797 -63
Total: Before=22566015, After=22565857, chg -0.00%
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/netmem.h | 12 ++++++++++++
net/core/devmem.c | 5 -----
net/core/devmem.h | 7 +------
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/include/net/netmem.h b/include/net/netmem.h
index 9e10f4ac50c3d4381d2404c3b079366dfc08bab7..2113a197abb315f608ee3d6d3e8a60811b3781f8 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -389,6 +389,18 @@ static inline unsigned long netmem_get_dma_addr(netmem_ref netmem)
return netmem_to_nmdesc(netmem)->dma_addr;
}
+#if defined(CONFIG_NET_DEVMEM)
+static inline bool net_is_devmem_iov(const struct net_iov *niov)
+{
+ return niov->type == NET_IOV_DMABUF;
+}
+#else
+static inline bool net_is_devmem_iov(const struct net_iov *niov)
+{
+ return false;
+}
+#endif
+
void get_netmem(netmem_ref netmem);
void put_netmem(netmem_ref netmem);
diff --git a/net/core/devmem.c b/net/core/devmem.c
index 185ed2a73d1cfa55858e4e0d42be365f612662fa..63f093f7d2b23f01929b83746ae25779d3f925d0 100644
--- a/net/core/devmem.c
+++ b/net/core/devmem.c
@@ -30,11 +30,6 @@ static DEFINE_XARRAY_FLAGS(net_devmem_dmabuf_bindings, XA_FLAGS_ALLOC1);
static const struct memory_provider_ops dmabuf_devmem_ops;
-bool net_is_devmem_iov(struct net_iov *niov)
-{
- return niov->type == NET_IOV_DMABUF;
-}
-
static void net_devmem_dmabuf_free_chunk_owner(struct gen_pool *genpool,
struct gen_pool_chunk *chunk,
void *not_used)
diff --git a/net/core/devmem.h b/net/core/devmem.h
index 2534c8144212c79f09389201ae190511948977fb..1c5c18581fcb146450cfb18a4b1d0ce8a17b96a9 100644
--- a/net/core/devmem.h
+++ b/net/core/devmem.h
@@ -141,7 +141,7 @@ struct net_iov *
net_devmem_alloc_dmabuf(struct net_devmem_dmabuf_binding *binding);
void net_devmem_free_dmabuf(struct net_iov *ppiov);
-bool net_is_devmem_iov(struct net_iov *niov);
+
struct net_devmem_dmabuf_binding *
net_devmem_get_binding(struct sock *sk, unsigned int dmabuf_id);
struct net_iov *
@@ -214,11 +214,6 @@ static inline u32 net_devmem_iov_binding_id(const struct net_iov *niov)
return 0;
}
-static inline bool net_is_devmem_iov(struct net_iov *niov)
-{
- return false;
-}
-
static inline struct net_devmem_dmabuf_binding *
net_devmem_get_binding(struct sock *sk, unsigned int dmabuf_id)
{
--
2.52.0.457.g6b5491de43-goog
next prev parent reply other threads:[~2026-01-22 4:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 4:57 [PATCH net-next 0/4] net: few critical helpers are inlined again Eric Dumazet
2026-01-22 4:57 ` [PATCH net-next 1/4] net: always inline skb_frag_unref() and __skb_frag_unref() Eric Dumazet
2026-01-22 4:57 ` [PATCH net-next 2/4] gro: change the BUG_ON() in gro_pull_from_frag0() Eric Dumazet
2026-01-23 16:45 ` Simon Horman
2026-01-22 4:57 ` Eric Dumazet [this message]
2026-01-22 4:57 ` [PATCH net-next 4/4] net: inline get_netmem() and put_netmem() Eric Dumazet
2026-01-26 20:26 ` Bobby Eshleman
2026-01-25 22:00 ` [PATCH net-next 0/4] net: few critical helpers are inlined again patchwork-bot+netdevbpf
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=20260122045720.1221017-4-edumazet@google.com \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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