Thread (22 messages) 22 messages, 4 authors, 2024-09-04

Re: [PATCH V6 net-next 07/11] net: hibmcge: Implement rx_poll function to receive packets

From: Paolo Abeni <pabeni@redhat.com>
Date: 2024-09-03 12:08:34
Also in: lkml

On 8/30/24 14:16, Jijie Shao wrote:
quoted hunk ↗ jump to hunk
@@ -119,6 +122,20 @@ static void hbg_buffer_free_skb(struct hbg_buffer *buffer)
  	buffer->skb = NULL;
  }
  
+static int hbg_buffer_alloc_skb(struct hbg_buffer *buffer)
+{
+	u32 len = hbg_spec_max_frame_len(buffer->priv, buffer->dir);
+	struct hbg_priv *priv = buffer->priv;
+
+	buffer->skb = netdev_alloc_skb(priv->netdev, len);
+	if (unlikely(!buffer->skb))
+		return -ENOMEM;
It's preferable to allocate the skbuff at packet reception time, inside 
the poll() function, just before passing the skb to the upper stack, so 
that the header contents are fresh in the cache. Additionally that 
increases the change for the allocator could hit its fastpath.
+
+	buffer->skb_len = len;
+	memset(buffer->skb->data, 0, HBG_PACKET_HEAD_SIZE);
Out of sheer ignorace, why do you need to clear the packet data?

thanks,

Paolo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help