]> git.proxmox.com Git - mirror_ovs.git/commitdiff
vswitchd: Track status of memory locking.
authorIlya Maximets <i.maximets@samsung.com>
Tue, 14 May 2019 13:08:42 +0000 (16:08 +0300)
committerIlya Maximets <i.maximets@samsung.com>
Fri, 24 May 2019 12:31:28 +0000 (15:31 +0300)
Needed for the future post-copy live migration support for
vhost-user ports.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/util.c
lib/util.h
vswitchd/ovs-vswitchd.c

index 5679232ffc5f23de98ed7eee6130bea8f6de743d..7b8ab81f6ee1a5ac9389b6bdb1f0b4e8aa3b8922 100644 (file)
@@ -63,6 +63,9 @@ DEFINE_PER_THREAD_MALLOCED_DATA(char *, subprogram_name);
 /* --version option output. */
 static char *program_version;
 
+/* 'true' if mlockall() succeeded. */
+static bool is_memory_locked = false;
+
 /* Buffer used by ovs_strerror() and ovs_format_message(). */
 DEFINE_STATIC_PER_THREAD_DATA(struct { char s[128]; },
                               strerror_buffer,
@@ -94,6 +97,18 @@ ovs_assert_failure(const char *where, const char *function,
     }
 }
 
+void
+set_memory_locked(void)
+{
+    is_memory_locked = true;
+}
+
+bool
+memory_locked(void)
+{
+    return is_memory_locked;
+}
+
 void
 out_of_memory(void)
 {
index 53354f1c6f0ff21e9d8b39d1efebd453b93241af..c26605abdce3cb938f2a046b79a592110fdfa9c4 100644 (file)
@@ -140,6 +140,9 @@ void ctl_timeout_setup(unsigned int secs);
 
 void ovs_print_version(uint8_t min_ofp, uint8_t max_ofp);
 
+void set_memory_locked(void);
+bool memory_locked(void);
+
 OVS_NO_RETURN void out_of_memory(void);
 void *xmalloc(size_t) MALLOC_LIKE;
 void *xcalloc(size_t, size_t) MALLOC_LIKE;
index 7191969373004100ee1912986951a77a44350714..4ee23ca435e93fca0505a0f4545932390548183d 100644 (file)
@@ -94,6 +94,8 @@ main(int argc, char *argv[])
 #ifdef HAVE_MLOCKALL
         if (mlockall(MCL_CURRENT | MCL_FUTURE)) {
             VLOG_ERR("mlockall failed: %s", ovs_strerror(errno));
+        } else {
+            set_memory_locked();
         }
 #else
         VLOG_ERR("mlockall not supported on this system");