[Devel] [PATCH RH9 28/30] fs/pipe: Use kvcalloc for pipe buffers
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Tue Sep 28 21:49:19 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 vz7 commit 606b246f934c ("fs/pipe: Use kvmalloc for pipe
buffers"))
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
(cherry picked from vz8 commit f7e7ab79c22584567beedf9f596267b2fa29729c)
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 6d4342b..7f07ce7 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -802,7 +802,7 @@ struct pipe_inode_info *alloc_pipe_info(void)
if (too_many_pipe_buffers_hard(user_bufs) && pipe_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) {
@@ -845,7 +845,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);
}
@@ -1260,7 +1260,7 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
if (nr_slots < n)
return -EBUSY;
- bufs = kcalloc(nr_slots, sizeof(*bufs),
+ bufs = kvcalloc(nr_slots, sizeof(*bufs),
GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
if (unlikely(!bufs))
return -ENOMEM;
@@ -1288,7 +1288,7 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
head = n;
tail = 0;
- kfree(pipe->bufs);
+ kvfree(pipe->bufs);
pipe->bufs = bufs;
pipe->ring_size = nr_slots;
if (pipe->max_usage > nr_slots)
--
1.8.3.1
More information about the Devel
mailing list