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.24
------>
commit 24188cc35a134f10d1bf73d0766640499c345f26
Author: Kirill Tkhai <ktk...@virtuozzo.com>
Date:   Fri Apr 30 13:52:42 2021 +0300

    ve/fs/files: Add fdtable_align() helper
    
    Patchset description:
    Shrink big fdtable on criu restore
    
    This patchset allows to avoid memory overuse introduced by service fds on 
criu
    restore.
    The solution is simple: smartly check for closed fd number, and shrink 
fdtable
    if this could be made. The checks are happen in is_pseudosuper mode, so we 
do
    not affect performance on normal work mode.
    
    The problem is we can't solve this for 100% case in userspace.
    Kernel allows to fix that completely.
    
    https://jira.sw.ru/browse/PSBM-78827
    
    Eric Dumazet (1):
          ms/fs/file.c: don't acquire files->file_lock in fd_install()
    
    Kirill Tkhai (3):
          files: Add new argument to expand_files()
          files: Add fdtable_align() helper
          files: Shrink big fdtable on close in is_pseudosuper mode
    
    Mateusz Guzik (1):
          ms/vfs: grab the lock instead of blocking in __fd_install during 
resizing
    
    ============================================================
    This patch description:
    
    Move alignment functionality from expand_fdtable() to separate function.
    This will be used in next patch.
    
    Signed-off-by: Kirill Tkhai <ktk...@virtuozzo.com>
    Reviewed-by: Cyrill Gorcunov <gorcu...@openvz.org>
    
    (cherry picked from vz7 commit 2437df57ec6e ("ve/fs/files: Add 
fdtable_align()
    helper"))
    Signed-off-by: Andrey Zhadchenko <andrey.zhadche...@virtuozzo.com>
---
 fs/file.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index 866912fd02d6..4f68ef0f6ee0 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -82,11 +82,8 @@ static void copy_fdtable(struct fdtable *nfdt, struct 
fdtable *ofdt, bool shrink
        copy_fd_bitmaps(nfdt, ofdt, ofdt->max_fds);
 }
 
-static struct fdtable * alloc_fdtable(unsigned int nr)
+static unsigned int fdtable_align(unsigned int nr)
 {
-       struct fdtable *fdt;
-       void *data;
-
        /*
         * Figure out how many fds we actually want to support in this fdtable.
         * Allocation steps are keyed to the size of the fdarray, since it
@@ -108,6 +105,16 @@ static struct fdtable * alloc_fdtable(unsigned int nr)
        if (unlikely(nr > sysctl_nr_open))
                nr = ((sysctl_nr_open - 1) | (BITS_PER_LONG - 1)) + 1;
 
+       return nr;
+}
+
+static struct fdtable * alloc_fdtable(unsigned int nr)
+{
+       struct fdtable *fdt;
+       void *data;
+
+       nr = fdtable_align(nr);
+
        fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL_ACCOUNT);
        if (!fdt)
                goto out;
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to