On 5/14/19 3:08 PM, Ilya Maximets wrote:
Needed for the future post-copy live migration support for
vhost-user ports.

Signed-off-by: Ilya Maximets <[email protected]>
---
  lib/util.c              | 15 +++++++++++++++
  lib/util.h              |  3 +++
  vswitchd/ovs-vswitchd.c |  2 ++
  3 files changed, 20 insertions(+)

diff --git a/lib/util.c b/lib/util.c
index 5679232ff..156555ebe 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -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)
  {
diff --git a/lib/util.h b/lib/util.h
index 53354f1c6..c26605abd 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -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;
diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c
index 719196937..4ee23ca43 100644
--- a/vswitchd/ovs-vswitchd.c
+++ b/vswitchd/ovs-vswitchd.c
@@ -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");


Reviewed-by: Maxime Coquelin <[email protected]>

Thanks,
Maxime
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to