This patch makes it possible to override the following #defines:
MESSAGE_SIZE_MAX
MESSAGE_QUEUE_MAX
SIZEQUEUE
FLOW_CONTROL_ENTRIES_ENABLE

If MESSAGE_SIZE_MAX is defined as 1024*64 (64K) and
MESSAGE_QUEUE_MAX defined as 512 you can change corosync's
memory footprint from ~48M to ~8M

So if you define MESSAGE_QUEUE_MAX, the queue size will
not be based on the message size any more.

To use this define the defines on the command line:
make CFLAGS="-DMESSAGE_SIZE_MAX=1024*64 -DMESSAGE_QUEUE_MAX=512"
---
 exec/ipc.c                        |    2 ++
 exec/main.h                       |    2 ++
 exec/totemconfig.c                |    4 ++--
 exec/totemsrp.c                   |    2 +-
 include/corosync/engine/coroapi.h |    9 ++++++++-
 include/corosync/totem/totem.h    |    7 +++++++
 6 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/exec/ipc.c b/exec/ipc.c
index eed903d..cccbcbb 100644
--- a/exec/ipc.c
+++ b/exec/ipc.c
@@ -99,7 +99,9 @@ LOGSYS_DECLARE_SUBSYS ("IPC", LOG_INFO);
 /*
  * When there are this many entries left in a queue, turn on flow control
  */
+#ifndef FLOW_CONTROL_ENTRIES_ENABLE
 #define FLOW_CONTROL_ENTRIES_ENABLE 400
+#endif /* FLOW_CONTROL_ENTRIES_ENABLE */
 
 /*
  * When there are this many entries in a queue, turn off flow control
diff --git a/exec/main.h b/exec/main.h
index e9b11d2..73f964a 100644
--- a/exec/main.h
+++ b/exec/main.h
@@ -48,7 +48,9 @@
  * Size of the queue (entries) for I/O's to the API over socket IPC.
  */
 
+#ifndef SIZEQUEUE
 #define SIZEQUEUE 800
+#endif /* SIZEQUEUE */
 
 #define SOCKET_SERVICE_INIT 254
 
diff --git a/exec/totemconfig.c b/exec/totemconfig.c
index f0595b3..ecd9125 100644
--- a/exec/totemconfig.c
+++ b/exec/totemconfig.c
@@ -528,9 +528,9 @@ int totem_config_validate (
                totem_config->net_mtu = 1500;
        }
 
-       if ((MESSAGE_SIZE_MAX / totem_config->net_mtu) < 
totem_config->max_messages) {
+       if ((MESSAGE_QUEUE_MAX) < totem_config->max_messages) {
                sprintf (local_error_reason, "The max_messages parameter (%d 
messages) may not be greater then (%d messages).",
-                       totem_config->max_messages, MESSAGE_SIZE_MAX / 
totem_config->net_mtu);
+                       totem_config->max_messages, MESSAGE_QUEUE_MAX);
                goto parse_error;
        }
 
diff --git a/exec/totemsrp.c b/exec/totemsrp.c
index fa434f8..0b1f91b 100644
--- a/exec/totemsrp.c
+++ b/exec/totemsrp.c
@@ -822,7 +822,7 @@ int totemsrp_initialize (
         * Must have net_mtu adjusted by totemrrp_initialize first
         */
        queue_init (&instance->new_message_queue,
-               (MESSAGE_SIZE_MAX / (totem_config->net_mtu - 25) /* for 
totempg_mcat header */),
+               MESSAGE_QUEUE_MAX,
                sizeof (struct message_item));
 
        return (0);
diff --git a/include/corosync/engine/coroapi.h 
b/include/corosync/engine/coroapi.h
index 65eed7a..0d6c60b 100644
--- a/include/corosync/engine/coroapi.h
+++ b/include/corosync/engine/coroapi.h
@@ -52,7 +52,14 @@ struct corosync_tpg_group {
 
 #define PROCESSOR_COUNT_MAX 384
 #define INTERFACE_MAX 2
-#define MESSAGE_SIZE_MAX        1024*1024 /* (1MB) */
+
+#ifndef MESSAGE_SIZE_MAX
+#define MESSAGE_SIZE_MAX       1024*1024 /* (1MB) */
+#endif /* MESSAGE_SIZE_MAX */
+
+#ifndef MESSAGE_QUEUE_MAX
+#define MESSAGE_QUEUE_MAX MESSAGE_SIZE_MAX / totem_config->net_mtu
+#endif /* MESSAGE_QUEUE_MAX */
 
 #define TOTEM_AGREED   0
 #define TOTEM_SAFE     1
diff --git a/include/corosync/totem/totem.h b/include/corosync/totem/totem.h
index a5a5511..4a0715a 100644
--- a/include/corosync/totem/totem.h
+++ b/include/corosync/totem/totem.h
@@ -36,7 +36,14 @@
 #define TOTEM_H_DEFINED
 #include "totemip.h"
 
+#ifndef MESSAGE_SIZE_MAX
 #define MESSAGE_SIZE_MAX       1024*1024 /* (1MB) */
+#endif /* MESSAGE_SIZE_MAX */
+
+#ifndef MESSAGE_QUEUE_MAX
+#define MESSAGE_QUEUE_MAX MESSAGE_SIZE_MAX / totem_config->net_mtu
+#endif /* MESSAGE_QUEUE_MAX */
+
 #define PROCESSOR_COUNT_MAX    384
 #define FRAME_SIZE_MAX         9000
 #define TRANSMITS_ALLOWED      16
-- 
1.5.6


_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to