[Devel] [PATCH RHEL8 COMMIT] fs/pipe: Use kvcalloc for pipe buffers

Konstantin Khorenko khorenko at virtuozzo.com
Tue May 11 18:48:29 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.27
------>
commit fab0e7b44e839d16509957dbaaf4128ef994bcbf
Author: Cyrill Gorcunov <gorcunov at virtuozzo.com>
Date:   Tue May 11 18:48:28 2021 +0300

    fs/pipe: Use kvcalloc for pipe buffers
    
    To restore big slabs of memory (more than 1G) via pipes we need
    pipes to be able to carry such sizes, for this sake Andrey propose
    to use kvcalloc calls. Looking into the code I didn't find a reason
    why we can't do so, thus here is a patch.
    
    https://jira.sw.ru/browse/PSBM-69201
    
    CC: Andrey Vagin <avagin at virtuozzo.com>
    CC: Andrey Ryabinin <aryabinin at virtuozzo.com>
    CC: Konstantin Khorenko <khorenko at virtuozzo.com>
    CC: "Denis V. Lunev" <den at virtuozzo.com>
    Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
    
    Rebase to vz8
     - Change kvmalloc to kvcalloc to respect mainline kmalloc->kcalloc change
     - Rename patch "Use kvmalloc..." -> "Use kvcalloc..."
    
    (cherry-picked from vz7 commit 606b246f934c ("fs/pipe: Use kvmalloc for pipe
    buffers"))
    Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 fs/pipe.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/pipe.c b/fs/pipe.c
index cac019cb19fc..90de2ee163c0 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -646,7 +646,7 @@ struct pipe_inode_info *alloc_pipe_info(void)
 	if (too_many_pipe_buffers_hard(user_bufs) && is_unprivileged_user())
 		goto out_revert_acct;
 
-	pipe->bufs = kcalloc(pipe_bufs, sizeof(struct pipe_buffer),
+	pipe->bufs = kvcalloc(pipe_bufs, sizeof(struct pipe_buffer),
 			     GFP_KERNEL_ACCOUNT);
 
 	if (pipe->bufs) {
@@ -679,7 +679,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
 	}
 	if (pipe->tmp_page)
 		__free_page(pipe->tmp_page);
-	kfree(pipe->bufs);
+	kvfree(pipe->bufs);
 	kfree(pipe);
 }
 
@@ -1089,7 +1089,7 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg)
 		goto out_revert_acct;
 	}
 
-	bufs = kcalloc(nr_pages, sizeof(*bufs),
+	bufs = kvcalloc(nr_pages, sizeof(*bufs),
 		       GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
 	if (unlikely(!bufs)) {
 		ret = -ENOMEM;
@@ -1118,7 +1118,7 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg)
 	}
 
 	pipe->curbuf = 0;
-	kfree(pipe->bufs);
+	kvfree(pipe->bufs);
 	pipe->bufs = bufs;
 	pipe->buffers = nr_pages;
 	return nr_pages * PAGE_SIZE;


More information about the Devel mailing list