Skip to contentSkip to conversation

kernel: relay: use __GFP_ZERO in relay_alloc_buf

PATCH Applied Elijah Wright 1 participant 1 message Jun 10, 2025 Relay

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel: relay: use __GFP_ZERO in relay_alloc_buf

passing the __GFP_ZERO flag to alloc_page should result in less overhead than using memset()

---
 kernel/relay.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/relay.c +1 -2
index c0c93a04d4ce..3ee5b038d0d9 100644
@@ -118,7 +118,7 @@ static void *relay_alloc_buf(struct rchan_buf *buf, size_t *size)
 		return NULL;
 
 	for (i = 0; i < n_pages; i++) {
-		buf->page_array[i] = alloc_page(GFP_KERNEL);
+		buf->page_array[i] = alloc_page(GFP_KERNEL | __GFP_ZERO);
 		if (unlikely(!buf->page_array[i]))
 			goto depopulate;
 		set_page_private(buf->page_array[i], (unsigned long)buf);
@@ -127,7 +127,6 @@ static void *relay_alloc_buf(struct rchan_buf *buf, size_t *size)
 	if (!mem)
 		goto depopulate;
 
-	memset(mem, 0, *size);
 	buf->page_count = n_pages;
 	return mem;
 
Signature · 1 line
2.43.0