[CRIU] [PATCH 2/5] kdat: Relax uffd checks

Mike Rapoport rppt at linux.vnet.ibm.com
Wed Apr 26 22:30:22 PDT 2017


On Wed, Apr 26, 2017 at 12:24:12PM +0300, Pavel Emelyanov wrote:
> Always check for uffd features.
> 
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
> ---
>  criu/cr-check.c        | 2 +-
>  criu/cr-service.c      | 4 ++--
>  criu/include/kerndat.h | 2 +-
>  criu/kerndat.c         | 8 ++++----
>  criu/uffd.c            | 2 +-
>  5 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/criu/cr-check.c b/criu/cr-check.c
> index 8d13504..8ef5d23 100644
> --- a/criu/cr-check.c
> +++ b/criu/cr-check.c
> @@ -1075,7 +1075,7 @@ static int check_uffd(void)
>  		UFFD_FEATURE_EVENT_UNMAP |
>  		UFFD_FEATURE_EVENT_REMOVE;
> 
> -	if (kerndat_uffd(true))
> +	if (kerndat_uffd())
>  		return -1;
> 
>  	if ((kdat.uffd_features & features) != features) {
> diff --git a/criu/cr-service.c b/criu/cr-service.c
> index d59ab8b..73a32d2 100644
> --- a/criu/cr-service.c
> +++ b/criu/cr-service.c
> @@ -893,7 +893,7 @@ static int handle_feature_check(int sk, CriuReq * msg)
> 
>  		if ((msg->features->has_lazy_pages == 1) &&
>  		    (msg->features->lazy_pages == true)) {
> -			ret = kerndat_uffd(true);
> +			ret = kerndat_uffd();
> 
>  			/*
>  			 * Not checking for specific UFFD features yet.
> @@ -902,7 +902,7 @@ static int handle_feature_check(int sk, CriuReq * msg)
>  			 * be extended in the future for a more detailed
>  			 * UFFD feature check.
>  			 */
> -			if (ret)
> +			if (ret || (kdat.uffd_features == 0))

You are making test for uffd features more strict here, and prevent using
lazy-pages with older (up to 4.11) versions of userfault. If this was
intentionally, please add comment about it and update the commit message.

>  				feat.lazy_pages = false;
>  			else
>  				feat.lazy_pages = true;
> diff --git a/criu/include/kerndat.h b/criu/include/kerndat.h
> index b8508ff..4945a4b 100644
> --- a/criu/include/kerndat.h
> +++ b/criu/include/kerndat.h
> @@ -70,7 +70,7 @@ enum {
>  extern int kerndat_fs_virtualized(unsigned int which, u32 kdev);
> 
>  extern int kerndat_tcp_repair();
> -extern int kerndat_uffd(bool need_uffd);
> +extern int kerndat_uffd(void);
>  extern int kerndat_has_nspid(void);
> 
>  #endif /* __CR_KERNDAT_H__ */
> diff --git a/criu/kerndat.c b/criu/kerndat.c
> index 9c47b13..416b1bc 100644
> --- a/criu/kerndat.c
> +++ b/criu/kerndat.c
> @@ -586,7 +586,7 @@ static int kerndat_compat_restore(void)
>  	return 0;
>  }
> 
> -int kerndat_uffd(bool need_uffd)
> +int kerndat_uffd(void)
>  {
>  	struct uffdio_api uffdio_api;
>  	int uffd;
> @@ -598,8 +598,8 @@ int kerndat_uffd(bool need_uffd)
>  	 * on this system. Additionally checking for ENOSYS
>  	 * makes sure it is actually not implemented.
>  	 */
> -	if (uffd == -1 && errno == ENOSYS) {
> -		if (!need_uffd)
> +	if (uffd == -1) {
> +		if (errno == ENOSYS)
>  			return 0;
> 
>  		pr_err("Lazy pages are not available\n");
> @@ -718,7 +718,7 @@ int kerndat_init_rst(void)
>  	if (!ret)
>  		ret = kerndat_compat_restore();
>  	if (!ret)
> -		ret = kerndat_uffd(opts.lazy_pages);
> +		ret = kerndat_uffd();
>  	if (!ret)
>  		ret = kerndat_socket_netns();
>  	if (!ret)
> diff --git a/criu/uffd.c b/criu/uffd.c
> index b2cf102..7caa840 100644
> --- a/criu/uffd.c
> +++ b/criu/uffd.c
> @@ -1115,7 +1115,7 @@ int cr_lazy_pages(bool daemon)
>  	int lazy_sk;
>  	int ret;
> 
> -	if (kerndat_uffd(true))
> +	if (kerndat_uffd() || (kdat.uffd_features == 0))

Ditto

>  		return -1;
> 
>  	if (prepare_dummy_pstree())
> -- 
> 2.5.5
> 



More information about the CRIU mailing list