Skip to contentSkip to conversation

hv_netvsc: Remove unnecessary round_up for recv_completion_cnt

PATCH Applied Haiyang Zhang 2 participants 2 messages Mar 30, 2020 – Mar 31, 2020

Subsystems (4)
lore
Share & tools
lore

Haiyang Zhang

author maintainer
#0 lore raw

PATCH 1/1 hv_netvsc: Remove unnecessary round_up for recv_completion_cnt

The vzalloc_node(), already rounds the total size to whole pages, and sizeof(u64) is smaller than sizeof(struct recv_comp_data). So round_up of recv_completion_cnt is not necessary, and may cause extra memory allocation.

To save memory, remove this unnecessary round_up for recv_completion_cnt.

---
 drivers/net/hyperv/netvsc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/hyperv/netvsc.c +5 -4
index 1b320bc..ca68aa1 100644
@@ -388,10 +388,11 @@ static int netvsc_init_buf(struct hv_device *device,
 	net_device->recv_section_size = resp->sections[0].sub_alloc_size;
 	net_device->recv_section_cnt = resp->sections[0].num_sub_allocs;
 
-	/* Setup receive completion ring */
-	net_device->recv_completion_cnt
-		= round_up(net_device->recv_section_cnt + 1,
-			   PAGE_SIZE / sizeof(u64));
+	/* Setup receive completion ring.
+	 * Add 1 to the recv_section_cnt because at least one entry in a
+	 * ring buffer has to be empty.
+	 */
+	net_device->recv_completion_cnt = net_device->recv_section_cnt + 1;
 	ret = netvsc_alloc_recv_comp_ring(net_device, 0);
 	if (ret)
 		goto cleanup;
Signature · 1 line
1.8.3.1
maintainer Applied
#1 lore raw

From: Haiyang Zhang <[email protected]>
Date: Mon, 30 Mar 2020 12:29:13 -0700

Quoted 8 lines

The vzalloc_node(), already rounds the total size to whole pages, and sizeof(u64) is smaller than sizeof(struct recv_comp_data). So round_up of recv_completion_cnt is not necessary, and may cause extra memory allocation.

To save memory, remove this unnecessary round_up for recv_completion_cnt.

Applied, thanks.