Projects STRLCPY criu Commits b548ed94
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    criu/cr-dump.c
    skipped 1556 lines
    1557 1557   struct pstree_item *item;
    1558 1558   int ret = -1;
    1559 1559   
     1560 + /*
     1561 + * We might need a lot of pipes to fetch huge number of pages to dump.
     1562 + */
     1563 + rlimit_unlimit_nofile();
     1564 + 
    1560 1565   root_item = alloc_pstree_item();
    1561 1566   if (!root_item)
    1562 1567   goto err;
    skipped 190 lines
    1753 1758   pr_info("========================================\n");
    1754 1759   pr_info("Dumping processes (pid: %d)\n", pid);
    1755 1760   pr_info("========================================\n");
     1761 + 
     1762 + /*
     1763 + * We will fetch all file descriptors for each task, their number can
     1764 + * be bigger than a default file limit, so we need to raise it to the
     1765 + * maximum.
     1766 + */
     1767 + rlimit_unlimit_nofile();
    1756 1768   
    1757 1769   root_item = alloc_pstree_item();
    1758 1770   if (!root_item)
    skipped 157 lines
  • ■ ■ ■ ■ ■ ■
    criu/cr-restore.c
    skipped 2329 lines
    2330 2330  {
    2331 2331   int ret = -1;
    2332 2332   
     2333 + if (init_service_fd())
     2334 + return 1;
     2335 + 
    2333 2336   if (cr_plugin_init(CR_PLUGIN_STAGE__RESTORE))
    2334 2337   return -1;
    2335 2338   
    skipped 1214 lines
  • ■ ■ ■ ■ ■ ■
    criu/crtools.c
    skipped 19 lines
    20 20   
    21 21  #include <sys/utsname.h>
    22 22   
    23  -#include <sys/time.h>
    24  -#include <sys/resource.h>
    25  - 
    26 23  #include "int.h"
    27 24  #include "page.h"
    28 25  #include "common/compiler.h"
    skipped 21 lines
    50 47  #include "setproctitle.h"
    51 48  #include "sysctl.h"
    52 49   
    53  -static void rlimit_unlimit_nofile(void)
    54  -{
    55  - struct rlimit new;
    56  - 
    57  - new.rlim_cur = kdat.sysctl_nr_open;
    58  - new.rlim_max = kdat.sysctl_nr_open;
    59  - 
    60  - if (prlimit(getpid(), RLIMIT_NOFILE, &new, NULL)) {
    61  - pr_perror("rlimit: Can't setup RLIMIT_NOFILE for self");
    62  - return;
    63  - } else
    64  - pr_debug("rlimit: RLIMIT_NOFILE unlimited for self\n");
    65  - 
    66  - service_fd_rlim_cur = kdat.sysctl_nr_open;
    67  -}
    68  - 
    69  -static int early_init(const char *cmd)
    70  -{
    71  - static const char *nofile_cmds[] = {
    72  - "swrk", "service",
    73  - "dump", "pre-dump",
    74  - "restore",
    75  - };
    76  - size_t i;
    77  - 
    78  - /*
    79  - * Service fd engine implies that file descriptors
    80  - * used won't be borrowed by the rest of the code
    81  - * and default 1024 limit is not enough for high
    82  - * loaded test/containers. Thus use kdat engine
    83  - * to fetch current system level limit for numbers
    84  - * of files allowed to open up and lift up own
    85  - * limits.
    86  - *
    87  - * Note we have to do it before the service fd
    88  - * get inited and we dont exit with errors here
    89  - * because in worst scenario where clash of fd
    90  - * happen we simply exit with explicit error
    91  - * during real action stage.
    92  - *
    93  - * Same time raising limits cause kernel fdtable
    94  - * to bloat so we do this only on the @nofile_cmds:
    95  - *
    96  - * - on dump criu needs additional files for sfd,
    97  - * thus if container already has many files opened
    98  - * we need to have at least not less space when
    99  - * fetching fds from a target process;
    100  - *
    101  - * - on pre-dump we might need a lot of pipes to
    102  - * fetch huge number of pages to dump;
    103  - *
    104  - * - on restore we still need to raise limits since
    105  - * there is no guarantee that on dump we've not
    106  - * been hitting fd limit already;
    107  - *
    108  - * - swrk and service obtain requests on the fly,
    109  - * thus we don't know if on of above will be
    110  - * there thus raise limits.
    111  - */
    112  - for (i = 0; i < ARRAY_SIZE(nofile_cmds); i++) {
    113  - if (strcmp(nofile_cmds[i], cmd))
    114  - continue;
    115  - if (!kerndat_files_stat(true))
    116  - rlimit_unlimit_nofile();
    117  - break;
    118  - }
    119  - 
    120  - if (init_service_fd())
    121  - return 1;
    122  - 
    123  - return 0;
    124  -}
    125  - 
    126 50  int main(int argc, char *argv[], char *envp[])
    127 51  {
    128 52   int ret = -1;
    skipped 28 lines
    157 81   goto usage;
    158 82   
    159 83   log_set_loglevel(opts.log_level);
    160  - 
    161  - if (early_init(argv[optind]))
    162  - return -1;
    163 84   
    164 85   if (!strcmp(argv[1], "swrk")) {
    165 86   if (argc < 3)
    skipped 357 lines
  • ■ ■ ■ ■ ■ ■
    criu/include/util.h
    skipped 349 lines
    350 350  extern int epoll_run_rfds(int epfd, struct epoll_event *evs, int nr_fds, int tmo);
    351 351  extern int epoll_prepare(int nr_events, struct epoll_event **evs);
    352 352   
     353 +extern void rlimit_unlimit_nofile(void);
     354 + 
    353 355  extern int call_in_child_process(int (*fn)(void *), void *arg);
    354 356  #ifdef __GLIBC__
    355 357  extern void print_stack_trace(pid_t pid);
    skipped 27 lines
  • ■ ■ ■ ■ ■ ■
    criu/servicefd.c
    skipped 67 lines
    68 68   struct rlimit64 rlimit;
    69 69   
    70 70   /*
     71 + * Service fd engine implies that file descriptors used won't be
     72 + * borrowed by the rest of the code and default 1024 limit is not
     73 + * enough for high loaded test/containers. Thus use kdat engine to
     74 + * fetch current system level limit for numbers of files allowed to
     75 + * open up and lift up own limits.
     76 + *
     77 + * Note we have to do it before the service fd get initialized and we
     78 + * don't exit with errors here because in worst scenario where clash of
     79 + * fd happen we simply exit with explicit error during real action
     80 + * stage.
     81 + */
     82 + rlimit_unlimit_nofile();
     83 + 
     84 + /*
    71 85   * Service FDs are those that most likely won't
    72 86   * conflict with any 'real-life' ones
    73 87   */
    skipped 213 lines
  • ■ ■ ■ ■ ■ ■
    criu/util.c
    skipped 19 lines
    20 20  #include <sys/mman.h>
    21 21  #include <sys/wait.h>
    22 22  #include <sys/socket.h>
     23 +#include <sys/time.h>
     24 +#include <sys/resource.h>
    23 25  #include <netdb.h>
    24 26  #include <netinet/in.h>
    25 27  #include <netinet/tcp.h>
    26 28  #include <sched.h>
    27 29  #include <ctype.h>
    28 30   
     31 +#include "kerndat.h"
    29 32  #include "page.h"
    30 33  #include "util.h"
    31 34  #include "image.h"
    skipped 1315 lines
    1347 1350   close_pid_proc();
    1348 1351   return ret;
    1349 1352  }
     1353 + 
     1354 +void rlimit_unlimit_nofile(void)
     1355 +{
     1356 + struct rlimit new;
     1357 + 
     1358 + new.rlim_cur = kdat.sysctl_nr_open;
     1359 + new.rlim_max = kdat.sysctl_nr_open;
     1360 + 
     1361 + if (prlimit(getpid(), RLIMIT_NOFILE, &new, NULL)) {
     1362 + pr_perror("rlimit: Can't setup RLIMIT_NOFILE for self");
     1363 + return;
     1364 + } else
     1365 + pr_debug("rlimit: RLIMIT_NOFILE unlimited for self\n");
     1366 + 
     1367 + service_fd_rlim_cur = kdat.sysctl_nr_open;
     1368 +}
     1369 + 
    1350 1370   
    1351 1371  #ifdef __GLIBC__
    1352 1372  #include <execinfo.h>
    skipped 16 lines
Please wait...
Page is in error, reload to recover