On Sun, Jul 27, 2025 at 9:21 PM Byungchul Park <byungchul@xxxxxx> wrote:
+ * Return: the pointer to struct netmem_desc * regardless of its
+ * underlying type.
*/
-static inline struct net_iov *__netmem_clear_lsb(netmem_ref netmem)
+static inline struct netmem_desc *netmem_to_nmdesc(netmem_ref netmem)
{
- return (struct net_iov *)((__force unsigned long)netmem & ~NET_IOV);
+ if (netmem_is_net_iov(netmem))
+ return &((struct net_iov *)((__force unsigned long)netmem &
+ ~NET_IOV))->desc;
+
+ return __netmem_to_nmdesc(netmem);
The if statement generates overhead. I'd rather avoid it. We can
implement netmem_to_nmdesc like this, no?
netmem_to_nmdesc(netmem_ref netmem)
{
return (struct netmem_desc)((__force unsigned long)netmem & ~NET_IOV);
}
Because netmem_desc is the first element in both net_iov and page for
the moment. (yes I know that will change eventually, but we don't have
to incur overhead of an extra if statement until netmem_desc is
removed from page, right?)