[Devel] [PATCH vz7 2/2] relay: use kvzalloc for rchan structure allocation

Oleg Babin obabin at virtuozzo.com
Tue May 8 15:30:33 MSK 2018


Size of rchan structure depends on NR_CPUS definition which can be
configured by the user and can become quite large.

E.g. if NR_CPUS equals to 5120 (real world scenario) then it makes
sizeof(struct rchan) == 41320 meaning the 4th memory order.

Use kvmalloc() for rchan structure allocation to fallback to vmalloc()
in case of high order page is not available at the moment.

https://jira.sw.ru/browse/HCI-53
Signed-off-by: Oleg Babin <obabin at virtuozzo.com>
---
 kernel/relay.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/relay.c b/kernel/relay.c
index 1b2a7dc4..6311d79 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -199,7 +199,7 @@ free_buf:
 static void relay_destroy_channel(struct kref *kref)
 {
 	struct rchan *chan = container_of(kref, struct rchan, kref);
-	kfree(chan);
+	kvfree(chan);
 }
 
 /**
@@ -592,7 +592,7 @@ struct rchan *relay_open(const char *base_filename,
 	if (subbuf_size > UINT_MAX / n_subbufs)
 		return NULL;
 
-	chan = kzalloc(sizeof(struct rchan), GFP_KERNEL);
+	chan = kvzalloc(sizeof(struct rchan), GFP_KERNEL);
 	if (!chan)
 		return NULL;
 
-- 
1.8.3.1



More information about the Devel mailing list