From 31aa88aefb9f1a31c3704246ceb37a771571ea55 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Wed, 20 Aug 2008 00:57:40 +0000 Subject: [PATCH] Provide a way to configure (at compile time) message and queue sizes. 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" git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1656 fd59a12c-fef9-0310-b244-a6a79926bd2f --- 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 495e4305..977f60c0 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 e9b11d2b..73f964a0 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 146d1e46..a7a59323 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 e42dbfa8..4810bb9b 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 2d095c98..dc96fdf5 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 a5a5511f..4a0715a7 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