[6/7] cr-service: require non-cooperative userfaultfd for lazy-pages

Submitted by Mike Rapoport on Aug. 15, 2017, 6:23 a.m.

Details

Message ID 1502778234-24415-7-git-send-email-rppt@linux.vnet.ibm.com
State New
Series "lazy-pages: update checks for availability of userfaultfd"
Headers show

Commit Message

Mike Rapoport Aug. 15, 2017, 6:23 a.m.
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@linux.vnet.ibm.com>
---
 criu/cr-check.c     |  2 +-
 criu/cr-service.c   | 19 ++++---------------
 criu/include/uffd.h |  2 ++
 3 files changed, 7 insertions(+), 16 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/cr-check.c b/criu/cr-check.c
index e6bb14a..93e4700 100644
--- a/criu/cr-check.c
+++ b/criu/cr-check.c
@@ -1056,7 +1056,7 @@  static int check_uffd(void)
 	return 0;
 }
 
-static int check_uffd_noncoop(void)
+int check_uffd_noncoop(void)
 {
 	if (check_uffd())
 		return -1;
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 79abc16..741085f 100644
--- a/criu/include/uffd.h
+++ b/criu/include/uffd.h
@@ -9,4 +9,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_ */