Skip to contentSkip to conversation

virtio_net: lower limit on buffer size

PATCH Superseded Michael S. Tsirkin 4 participants 12 messages Jun 1, 2017 – Jun 5, 2017

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

PATCH 1/1 virtio_net: lower limit on buffer size

commit d85b758f72b0 "virtio_net: fix support for small rings" was supposed to increase the buffer size for small rings but had an unintentional side effect of decreasing it for large rings. This seems to break some setups - it's not yet clear why, but increasing buffer size back to what it was before helps.

Fixes d85b758f72b0 "virtio_net: fix support for small rings"

---

Can reporters please confirm whether the following helps?
If it does I think we should queue it even though I expect I'll need to investigate the exact reasons for the failure down the road - probably a hypervisor bug.

 drivers/net/virtio_net.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio_net.c +3 -2
index 87b5c20..60abb5d 100644
@@ -842,7 +842,7 @@ static unsigned int get_mergeable_buf_len(struct receive_queue *rq,
 	unsigned int len;
 
 	len = hdr_len + clamp_t(unsigned int, ewma_pkt_len_read(avg_pkt_len),
-				rq->min_buf_len - hdr_len, PAGE_SIZE - hdr_len);
+				rq->min_buf_len, PAGE_SIZE - hdr_len);
 	return ALIGN(len, L1_CACHE_BYTES);
 }
 
@@ -2039,7 +2039,8 @@ static unsigned int mergeable_min_buf_len(struct virtnet_info *vi, struct virtqu
 	unsigned int buf_len = hdr_len + ETH_HLEN + VLAN_HLEN + packet_len;
 	unsigned int min_buf_len = DIV_ROUND_UP(buf_len, rq_size);
 
-	return max(min_buf_len, hdr_len);
+	return max(max(min_buf_len, hdr_len) - hdr_len,
+		   (unsigned int)GOOD_PACKET_LEN);
 }
 
 static int virtnet_find_vqs(struct virtnet_info *vi)
Signature · 1 line
MST
#1 lore raw
Quoted 7 lines · Michael S. Tsirkin

commit d85b758f72b0 "virtio_net: fix support for small rings" was supposed to increase the buffer size for small rings but had an unintentional side effect of decreasing it for large rings. This seems to break some setups - it's not yet clear why, but increasing buffer size back to what it was before helps.

Quoted 7 lines
Fixes d85b758f72b0 "virtio_net: fix support for small rings"

---

Can reporters please confirm whether the following helps?

Works for me.

--b.

Quoted 32 lines

If it does I think we should queue it even though I expect I'll need to investigate the exact reasons for the failure down the road - probably a hypervisor bug.

 drivers/net/virtio_net.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio_net.c +3 -2
index 87b5c20..60abb5d 100644
@@ -842,7 +842,7 @@ static unsigned int get_mergeable_buf_len(struct receive_queue *rq,
 	unsigned int len;
 
 	len = hdr_len + clamp_t(unsigned int, ewma_pkt_len_read(avg_pkt_len),
-				rq->min_buf_len - hdr_len, PAGE_SIZE - hdr_len);
+				rq->min_buf_len, PAGE_SIZE - hdr_len);
 	return ALIGN(len, L1_CACHE_BYTES);
 }
 
@@ -2039,7 +2039,8 @@ static unsigned int mergeable_min_buf_len(struct virtnet_info *vi, struct virtqu
 	unsigned int buf_len = hdr_len + ETH_HLEN + VLAN_HLEN + packet_len;
 	unsigned int min_buf_len = DIV_ROUND_UP(buf_len, rq_size);
 
-	return max(min_buf_len, hdr_len);
+	return max(max(min_buf_len, hdr_len) - hdr_len,
+		   (unsigned int)GOOD_PACKET_LEN);
 }
 
 static int virtnet_find_vqs(struct virtnet_info *vi)
Signature · 1 line
MST
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin

commit d85b758f72b0 "virtio_net: fix support for small rings" was supposed to increase the buffer size for small rings but had an unintentional side effect of decreasing it for large rings. This seems to break some setups - it's not yet clear why, but increasing buffer size back to what it was before helps.

Quoted 7 lines
Fixes d85b758f72b0 "virtio_net: fix support for small rings"

---

Can reporters please confirm whether the following helps?

Works for me.

--b.

Quoted 32 lines

If it does I think we should queue it even though I expect I'll need to investigate the exact reasons for the failure down the road - probably a hypervisor bug.

 drivers/net/virtio_net.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio_net.c +3 -2
index 87b5c20..60abb5d 100644
@@ -842,7 +842,7 @@ static unsigned int get_mergeable_buf_len(struct receive_queue *rq,
 	unsigned int len;
 
 	len = hdr_len + clamp_t(unsigned int, ewma_pkt_len_read(avg_pkt_len),
-				rq->min_buf_len - hdr_len, PAGE_SIZE - hdr_len);
+				rq->min_buf_len, PAGE_SIZE - hdr_len);
 	return ALIGN(len, L1_CACHE_BYTES);
 }
 
@@ -2039,7 +2039,8 @@ static unsigned int mergeable_min_buf_len(struct virtnet_info *vi, struct virtqu
 	unsigned int buf_len = hdr_len + ETH_HLEN + VLAN_HLEN + packet_len;
 	unsigned int min_buf_len = DIV_ROUND_UP(buf_len, rq_size);
 
-	return max(min_buf_len, hdr_len);
+	return max(max(min_buf_len, hdr_len) - hdr_len,
+		   (unsigned int)GOOD_PACKET_LEN);
 }
 
 static int virtnet_find_vqs(struct virtnet_info *vi)
Signature · 1 line
MST
#3 lore raw
In reply to Michael S. Tsirkin

Hello!

Quoted 1 line · Michael S. Tsirkin

commit d85b758f72b0 "virtio_net: fix support for small rings"

Commit d85b758f72b0 ("virtio_net: fix support for small rings")

Quoted 7 lines

was supposed to increase the buffer size for small rings but had an unintentional side effect of decreasing it for large rings. This seems to break some setups - it's not yet clear why, but increasing buffer size back to what it was before helps.

Fixes d85b758f72b0 "virtio_net: fix support for small rings"
Fixes d85b758f72b0 ("virtio_net: fix support for small rings")
Quoted 3 lines

[...]

MBR, Sergei

#4 lore raw
Quoted 14 lines · Sergei Shtylyov

Hello!

Quoted 1 line · Michael S. Tsirkin

commit d85b758f72b0 "virtio_net: fix support for small rings"

Commit d85b758f72b0 ("virtio_net: fix support for small rings")

Quoted 6 lines

was supposed to increase the buffer size for small rings but had an unintentional side effect of decreasing it for large rings. This seems to break some setups - it's not yet clear why, but increasing buffer size back to what it was before helps.

Quoted 3 lines
Quoted 1 line
Fixes d85b758f72b0 "virtio_net: fix support for small rings"
Fixes d85b758f72b0 ("virtio_net: fix support for small rings")

I may be bikeshedding, but, personally I never do the parens--they're redundant given the quotes, and space is often tight.

--b.

Quoted 7 lines
Quoted 4 lines

[...]

MBR, Sergei

#5 lore raw
Quoted 10 lines · J. Bruce Fields
Quoted 10 lines
Quoted 1 line

commit d85b758f72b0 "virtio_net: fix support for small rings"

Commit d85b758f72b0 ("virtio_net: fix support for small rings")

Quoted 6 lines

was supposed to increase the buffer size for small rings but had an unintentional side effect of decreasing it for large rings. This seems to break some setups - it's not yet clear why, but increasing buffer size back to what it was before helps.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Fixes d85b758f72b0 "virtio_net: fix support for small rings"
Fixes d85b758f72b0 ("virtio_net: fix support for small rings")

I may be bikeshedding, but, personally I never do the parens--they're redundant given the quotes, and space is often tight.

Just see Documetation/process/submitting-patches.rst.

MBR, Sergei

#6 lore raw
In reply to J. Bruce Fields
Quoted 10 lines · J. Bruce Fields
Quoted 10 lines
Quoted 1 line

commit d85b758f72b0 "virtio_net: fix support for small rings"

Commit d85b758f72b0 ("virtio_net: fix support for small rings")

Quoted 6 lines

was supposed to increase the buffer size for small rings but had an unintentional side effect of decreasing it for large rings. This seems to break some setups - it's not yet clear why, but increasing buffer size back to what it was before helps.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Fixes d85b758f72b0 "virtio_net: fix support for small rings"
Fixes d85b758f72b0 ("virtio_net: fix support for small rings")

I may be bikeshedding, but, personally I never do the parens--they're redundant given the quotes, and space is often tight.

Just see Documetation/process/submitting-patches.rst.

MBR, Sergei

#7 lore raw
Quoted 12 lines · Sergei Shtylyov
Quoted 10 lines · J. Bruce Fields
Quoted 10 lines
Quoted 1 line

commit d85b758f72b0 "virtio_net: fix support for small rings"

Commit d85b758f72b0 ("virtio_net: fix support for small rings")

Quoted 6 lines

was supposed to increase the buffer size for small rings but had an unintentional side effect of decreasing it for large rings. This seems to break some setups - it's not yet clear why, but increasing buffer size back to what it was before helps.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Fixes d85b758f72b0 "virtio_net: fix support for small rings"
Fixes d85b758f72b0 ("virtio_net: fix support for small rings")

I may be bikeshedding, but, personally I never do the parens--they're redundant given the quotes, and space is often tight.

Just see Documetation/process/submitting-patches.rst.

Yeah, I know, I claim it's a bad rule (but I'm too lazy to send a patch, so, weight my opinion accordingly).

--b.

#8 lore raw
In reply to Sergei Shtylyov
Quoted 12 lines · Sergei Shtylyov
Quoted 10 lines · J. Bruce Fields
Quoted 10 lines
Quoted 1 line

commit d85b758f72b0 "virtio_net: fix support for small rings"

Commit d85b758f72b0 ("virtio_net: fix support for small rings")

Quoted 6 lines

was supposed to increase the buffer size for small rings but had an unintentional side effect of decreasing it for large rings. This seems to break some setups - it's not yet clear why, but increasing buffer size back to what it was before helps.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Fixes d85b758f72b0 "virtio_net: fix support for small rings"
Fixes d85b758f72b0 ("virtio_net: fix support for small rings")

I may be bikeshedding, but, personally I never do the parens--they're redundant given the quotes, and space is often tight.

Just see Documetation/process/submitting-patches.rst.

Yeah, I know, I claim it's a bad rule (but I'm too lazy to send a patch, so, weight my opinion accordingly).

--b.

#9 lore raw
In reply to Sergei Shtylyov
Quoted 14 lines · Sergei Shtylyov

Hello!

Quoted 1 line · Michael S. Tsirkin

commit d85b758f72b0 "virtio_net: fix support for small rings"

Commit d85b758f72b0 ("virtio_net: fix support for small rings")

Quoted 6 lines

was supposed to increase the buffer size for small rings but had an unintentional side effect of decreasing it for large rings. This seems to break some setups - it's not yet clear why, but increasing buffer size back to what it was before helps.

Quoted 3 lines
Quoted 1 line
Fixes d85b758f72b0 "virtio_net: fix support for small rings"
Fixes d85b758f72b0 ("virtio_net: fix support for small rings")

I may be bikeshedding, but, personally I never do the parens--they're redundant given the quotes, and space is often tight.

--b.

Quoted 7 lines
Quoted 4 lines

[...]

MBR, Sergei

#10 lore raw
In reply to Michael S. Tsirkin
Quoted 11 lines · Michael S. Tsirkin

commit d85b758f72b0 "virtio_net: fix support for small rings" was supposed to increase the buffer size for small rings but had an unintentional side effect of decreasing it for large rings. This seems to break some setups - it's not yet clear why, but increasing buffer size back to what it was before helps.

Fixes d85b758f72b0 "virtio_net: fix support for small rings"
Quoted 6 lines

---

Can reporters please confirm whether the following helps?
If it does I think we should queue it even though I expect I'll need to investigate the exact reasons for the failure down the road - probably a hypervisor bug.

Hi

This patch fixes the problem for me.

Mikulas

Quoted 29 lines
 drivers/net/virtio_net.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio_net.c +3 -2
index 87b5c20..60abb5d 100644
@@ -842,7 +842,7 @@ static unsigned int get_mergeable_buf_len(struct receive_queue *rq,
 	unsigned int len;
 
 	len = hdr_len + clamp_t(unsigned int, ewma_pkt_len_read(avg_pkt_len),
-				rq->min_buf_len - hdr_len, PAGE_SIZE - hdr_len);
+				rq->min_buf_len, PAGE_SIZE - hdr_len);
 	return ALIGN(len, L1_CACHE_BYTES);
 }
 
@@ -2039,7 +2039,8 @@ static unsigned int mergeable_min_buf_len(struct virtnet_info *vi, struct virtqu
 	unsigned int buf_len = hdr_len + ETH_HLEN + VLAN_HLEN + packet_len;
 	unsigned int min_buf_len = DIV_ROUND_UP(buf_len, rq_size);
 
-	return max(min_buf_len, hdr_len);
+	return max(max(min_buf_len, hdr_len) - hdr_len,
+		   (unsigned int)GOOD_PACKET_LEN);
 }
 
 static int virtnet_find_vqs(struct virtnet_info *vi)
Signature · 1 line
MST
#11 lore raw
In reply to Michael S. Tsirkin
Quoted 11 lines · Michael S. Tsirkin

commit d85b758f72b0 "virtio_net: fix support for small rings" was supposed to increase the buffer size for small rings but had an unintentional side effect of decreasing it for large rings. This seems to break some setups - it's not yet clear why, but increasing buffer size back to what it was before helps.

Fixes d85b758f72b0 "virtio_net: fix support for small rings"
Quoted 6 lines

---

Can reporters please confirm whether the following helps?
If it does I think we should queue it even though I expect I'll need to investigate the exact reasons for the failure down the road - probably a hypervisor bug.

Hi

This patch fixes the problem for me.

Mikulas

Quoted 29 lines
 drivers/net/virtio_net.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio_net.c +3 -2
index 87b5c20..60abb5d 100644
@@ -842,7 +842,7 @@ static unsigned int get_mergeable_buf_len(struct receive_queue *rq,
 	unsigned int len;
 
 	len = hdr_len + clamp_t(unsigned int, ewma_pkt_len_read(avg_pkt_len),
-				rq->min_buf_len - hdr_len, PAGE_SIZE - hdr_len);
+				rq->min_buf_len, PAGE_SIZE - hdr_len);
 	return ALIGN(len, L1_CACHE_BYTES);
 }
 
@@ -2039,7 +2039,8 @@ static unsigned int mergeable_min_buf_len(struct virtnet_info *vi, struct virtqu
 	unsigned int buf_len = hdr_len + ETH_HLEN + VLAN_HLEN + packet_len;
 	unsigned int min_buf_len = DIV_ROUND_UP(buf_len, rq_size);
 
-	return max(min_buf_len, hdr_len);
+	return max(max(min_buf_len, hdr_len) - hdr_len,
+		   (unsigned int)GOOD_PACKET_LEN);
 }
 
 static int virtnet_find_vqs(struct virtnet_info *vi)
Signature · 1 line
MST