[CRIU] [PATCH] cr-service: require non-cooperative userfaultfd for lazy-pages

Adrian Reber areber at redhat.com
Wed Aug 9 10:00:14 MSK 2017


Acked-by: Adrian Reber <areber at redhat.com>

On Wed, Aug 09, 2017 at 08:41:52AM +0300, Mike Rapoport wrote:
> Without non-cooperative userfaultfd some programs may fail during lazy
> restore because they perform operations that cannot be handled by the
> lazy-pages daemon.
> 
> Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
> ---
> 
> I've noticed that we don't really have RPC support for lazy-pages. I've
> rechecked Adrian's pull request to runc and there is a requirement to run
> lazy-pages daemon manually.
> Do we want to add an RPC interface for lazy-pages?
> Another possibility is to fork() lazy-pages from restore...
> 
>  criu/cr-check.c     |  2 +-
>  criu/cr-service.c   | 19 ++++---------------
>  criu/include/uffd.h |  2 ++
>  3 files changed, 7 insertions(+), 16 deletions(-)
> 
> diff --git a/criu/cr-check.c b/criu/cr-check.c
> index b1de144..24a94c1 100644
> --- a/criu/cr-check.c
> +++ b/criu/cr-check.c
> @@ -1059,7 +1059,7 @@ static int check_uffd(void)
>  	return 0;
>  }
>  
> -static int check_uffd_noncoop(void)
> +int check_uffd_noncoop(void)
>  {
>  	unsigned long features = UFFD_FEATURE_EVENT_FORK |
>  		UFFD_FEATURE_EVENT_REMAP |
> diff --git a/criu/cr-service.c b/criu/cr-service.c
> index 18ba2fd..1e83716 100644
> --- a/criu/cr-service.c
> +++ b/criu/cr-service.c
> @@ -40,6 +40,7 @@
>  #include <sys/un.h>
>  #include <sys/socket.h>
>  #include "common/scm.h"
> +#include "uffd.h"
>  
>  #include "setproctitle.h"
>  
> @@ -895,22 +896,10 @@ static int handle_feature_check(int sk, CriuReq * msg)
>  				feat.mem_track = false;
>  		}
>  
> +		/* For lazy-pages we need non-coopetative userfaultfd */
>  		if ((msg->features->has_lazy_pages == 1) &&
> -		    (msg->features->lazy_pages == true)) {
> -			ret = kerndat_uffd();
> -
> -			/*
> -			 * Not checking for specific UFFD features yet.
> -			 * If no error is returned it is probably
> -			 * enough for basic UFFD functionality. This can
> -			 * be extended in the future for a more detailed
> -			 * UFFD feature check.
> -			 */
> -			if (ret || !kdat.has_uffd)
> -				feat.lazy_pages = false;
> -			else
> -				feat.lazy_pages = true;
> -		}
> +		    (msg->features->lazy_pages == true))
> +			feat.lazy_pages = !check_uffd_noncoop();
>  
>  		resp.features = &feat;
>  		resp.type = msg->type;
> diff --git a/criu/include/uffd.h b/criu/include/uffd.h
> index 4d790ce..653041f 100644
> --- a/criu/include/uffd.h
> +++ b/criu/include/uffd.h
> @@ -6,4 +6,6 @@ extern int setup_uffd(int pid, struct task_restore_args *task_args);
>  extern int lazy_pages_setup_zombie(int pid);
>  extern int prepare_lazy_pages_socket(void);
>  
> +extern int check_uffd_noncoop(void);
> +
>  #endif /* __CR_UFFD_H_ */
> -- 
> 2.7.4
> 


More information about the CRIU mailing list