[Devel] [PATCH RHEL7 COMMIT] fs/pipe: Use kvmalloc for pipe buffers
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Feb 14 13:37:55 MSK 2018
The commit is pushed to "branch-rh7-3.10.0-693.17.1.vz7.43.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.17.1.vz7.43.4
------>
commit effeb5d21ed02dbb6c155965cb83e8641286451b
Author: Cyrill Gorcunov <gorcunov at virtuozzo.com>
Date: Wed Feb 14 13:37:55 2018 +0300
fs/pipe: Use kvmalloc 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 kvmalloc 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>
---
fs/pipe.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/pipe.c b/fs/pipe.c
index 7bded9f4a0d4..cfc994adb508 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -845,7 +845,7 @@ struct pipe_inode_info *alloc_pipe_info(void)
if (!too_many_pipe_buffers_hard(user)) {
if (too_many_pipe_buffers_soft(user))
pipe_bufs = 1;
- pipe->bufs = kzalloc(sizeof(struct pipe_buffer) * pipe_bufs, GFP_KERNEL);
+ pipe->bufs = kvmalloc(sizeof(struct pipe_buffer) * pipe_bufs, GFP_KERNEL | __GFP_ZERO);
}
if (pipe->bufs) {
@@ -877,7 +877,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);
}
@@ -1235,7 +1235,7 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long nr_pages)
if (nr_pages < pipe->nrbufs)
return -EBUSY;
- bufs = kcalloc(nr_pages, sizeof(*bufs), GFP_KERNEL | __GFP_NOWARN);
+ bufs = kvmalloc(nr_pages * sizeof(*bufs), GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO);
if (unlikely(!bufs))
return -ENOMEM;
@@ -1262,7 +1262,7 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long nr_pages)
account_pipe_buffers(pipe, pipe->buffers, nr_pages);
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