[CRIU] [PATCH] early_init: Force to unlimit files on early init

Cyrill Gorcunov gorcunov at gmail.com
Tue Mar 12 23:43:02 MSK 2019


On Tue, Mar 12, 2019 at 10:35:17PM +0200, Mike Rapoport wrote:
> On Tue, Mar 12, 2019 at 08:29:25PM +0300, Cyrill Gorcunov wrote:
> > From: Cyrill Gorcunov <gorcunov at virtuozzo.com>
> > 
> > It is so because when we checkpoint containers with huge number
> > of files opened we get
> > 
> >  | (00.659733) Error (criu/util.c:403): Can't open 57950: Too many open files
> >  | (00.659741) Error (criu/proc_parse.c:2399): Can't open 57950/task on procfs: Too many open files
> >  | (00.675635) Error (criu/cr-dump.c:2111): Dumping FAILED.
> >  | Failed to checkpoint the Container
> > 
> > simply because we're opening more files for criu itself. This mostly
> > reverts a148e87469a36dc75e263259e39ed30336343fc8
> > 
> > Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
> > ---
> >  criu/cr-restore.c | 32 --------------------------------
> >  criu/crtools.c    | 33 +++++++++++++++++++++++++++++++++
> >  2 files changed, 33 insertions(+), 32 deletions(-)
> 
> ...
>  
> > diff --git a/criu/crtools.c b/criu/crtools.c
> > index 3f64000c1e87..5da09beaa75f 100644
> > --- a/criu/crtools.c
> > +++ b/criu/crtools.c
> > @@ -51,8 +51,41 @@
> >  #include "sysctl.h"
> >  #include "img-remote.h"
> >  
> > +static void rlimit_unlimit_nofile_self(void)
> 
> Nit: does '_self' suffix have some real meaning? Can we just drop it?
> Same for the pr_{perror,debug}

It means that we're unlimiting _own_ resources not
some other pid.
 
> > +{
> > +	struct rlimit new;
> > +
> > +	new.rlim_cur = kdat.sysctl_nr_open;
> > +	new.rlim_max = kdat.sysctl_nr_open;
> > +
> > +	if (prlimit(getpid(), RLIMIT_NOFILE, &new, NULL)) {
> > +		pr_perror("rlimir: Can't setup RLIMIT_NOFILE for self");
> 
>                           ^ rlimit
> 

? Unfortunately our logger doesn't allow to setup temp prefixes,
so I put rlimit here for easier greps.


More information about the CRIU mailing list