Thread (49 messages) flat view 49 messages, 4 authors, 2025-07-28

Re: [PATCH net-next v9 2/8] netmem: introduce utility APIs to use struct netmem_desc

From: Pavel Begunkov <asml.silence@gmail.com>
Date: 2025-07-12 11:58:19
Also in: bpf, linux-mm, linux-rdma, lkml

On 7/10/25 09:28, Byungchul Park wrote:
...> +
quoted hunk ↗ jump to hunk
  static inline struct net_iov *netmem_to_net_iov(netmem_ref netmem)
  {
  	if (netmem_is_net_iov(netmem))
@@ -314,6 +340,21 @@ static inline netmem_ref netmem_compound_head(netmem_ref netmem)
  	return page_to_netmem(compound_head(netmem_to_page(netmem)));
  }
  
+#define nmdesc_to_page(nmdesc)		(_Generic((nmdesc),		\
+	const struct netmem_desc * :	(const struct page *)(nmdesc),	\
+	struct netmem_desc * :		(struct page *)(nmdesc)))
Considering that nmdesc is going to be separated from pages and
accessed through indirection, and back reference to the page is
not needed (at least for net/), this helper shouldn't even exist.
And in fact, you don't really use it ...
+static inline struct netmem_desc *page_to_nmdesc(struct page *page)
+{
+	VM_BUG_ON_PAGE(PageTail(page), page);
+	return (struct netmem_desc *)page;
+}
+
+static inline void *nmdesc_address(struct netmem_desc *nmdesc)
+{
+	return page_address(nmdesc_to_page(nmdesc));
+}
... That's the only caller, and nmdesc_address() is not used, so
just nuke both of them. This helper doesn't even make sense.

Please avoid introducing functions that you don't use as a general
rule.
+
  /**
   * __netmem_address - unsafely get pointer to the memory backing @netmem
   * @netmem: netmem reference to get the pointer for
-- 
Pavel Begunkov
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help