In commit [1] there was added support to enable memory trimming on OVSDB tlog
compation.  However there was no option to get current setting value except
log parsing.  This patch adds new unixctl command
'ovsdb-server/show-memory-trim-on-compaction' to print current setting value.

1: 
https://github.com/openvswitch/ovs/commit/f38f98a2c0dd7fcaf20fbe11d1e67a9b2afc0b2a

Signed-off-by: Vladislav Odintsov <odiv...@gmail.com>
---
 NEWS                 |  4 ++++
 ovsdb/ovsdb-server.c | 28 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/NEWS b/NEWS
index 72b9024e6..8515f4aaa 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,10 @@ Post-v3.1.0
        in order to create OVSDB sockets with access mode of 0770.
    - QoS:
      * Added new configuration option 'jitter' for a linux-netem QoS type.
+  - OVSDB:
+     * New unixctl command 'ovsdb-server/show-memory-trim-on-compaction'.
+       This command shows current value for memory trimming setting for
+       OVSDB server.
 
 
 v3.1.0 - 16 Feb 2023
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index 33ca4910d..1994c0fdc 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -85,6 +85,7 @@ static bool trim_memory = true;
 static unixctl_cb_func ovsdb_server_exit;
 static unixctl_cb_func ovsdb_server_compact;
 static unixctl_cb_func ovsdb_server_memory_trim_on_compaction;
+static unixctl_cb_func ovsdb_server_show_memory_trim_on_compaction;
 static unixctl_cb_func ovsdb_server_reconnect;
 static unixctl_cb_func ovsdb_server_perf_counters_clear;
 static unixctl_cb_func ovsdb_server_perf_counters_show;
@@ -433,6 +434,9 @@ main(int argc, char *argv[])
     unixctl_command_register("ovsdb-server/memory-trim-on-compaction",
                              "on|off", 1, 1,
                              ovsdb_server_memory_trim_on_compaction, NULL);
+    unixctl_command_register("ovsdb-server/show-memory-trim-on-compaction", "",
+                             0, 0, ovsdb_server_show_memory_trim_on_compaction,
+                             NULL);
     unixctl_command_register("ovsdb-server/reconnect", "", 0, 0,
                              ovsdb_server_reconnect, jsonrpc);
 
@@ -1625,6 +1629,30 @@ ovsdb_server_memory_trim_on_compaction(struct 
unixctl_conn *conn,
     unixctl_command_reply(conn, NULL);
 }
 
+/* "ovsdb-server/show-memory-trim-on-compaction": shows whether ovsdb-server
+ * memory-trim-on-compaction setting is enabled or not.  */
+static void
+ovsdb_server_show_memory_trim_on_compaction(struct unixctl_conn *conn,
+                                            int argc OVS_UNUSED,
+                                            const char *argv[] OVS_UNUSED,
+                                            void *arg OVS_UNUSED)
+{
+#if !HAVE_DECL_MALLOC_TRIM
+    unixctl_command_reply_error(conn, "memory trimming is not supported");
+    return;
+#endif
+
+    struct ds s;
+
+    ds_init(&s);
+    ds_put_format(&s, "memory trim on compaction is %s",
+                  trim_memory ? "enabled" : "disabled");
+
+    unixctl_command_reply(conn, ds_cstr(&s));
+
+    ds_destroy(&s);
+}
+
 /* "ovsdb-server/reconnect": makes ovsdb-server drop all of its JSON-RPC
  * connections and reconnect. */
 static void
-- 
2.36.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to