[Devel] [PATCH RH8] fs/pipe: Use kvcalloc for pipe buffers
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Thu May 6 18:44:36 MSK 2021
From: Cyrill Gorcunov <gorcunov at virtuozzo.com>
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 606b246f934c826673c95c4e6504ff1cad83fe9f)
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 cac019c..90de2ee 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;
--
1.8.3.1
More information about the Devel
mailing list