[igt-dev] [PATCH i-g-t v21 10/35] lib/intel_allocator_msgchannel: Scale to 4k of parallel clients

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Mon Mar 1 16:13:38 UTC 2021


When playing with multiprocess mode in allocator we're currently
using sysvipc message queues in blocking mode (request/response).
We can calculate then what is maximum depth for the queue for
requested number of children. Change alters kernel queue depth
to cover 4k users (1 is main thread and 4095 are children).

We're still prone to unlimited wait in allocator thread
(more than 4095 children successfully send the messages)
but we're going to address this later.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Andrzej Turko <andrzej.turko at linux.intel.com>
Cc: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 lib/intel_allocator_msgchannel.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/intel_allocator_msgchannel.c b/lib/intel_allocator_msgchannel.c
index 74a0f9286..ab116b44f 100644
--- a/lib/intel_allocator_msgchannel.c
+++ b/lib/intel_allocator_msgchannel.c
@@ -17,6 +17,7 @@ extern __thread pid_t child_tid;
 
 #define FTOK_IGT_ALLOCATOR_KEY "/tmp/igt.allocator.key"
 #define FTOK_IGT_ALLOCATOR_PROJID 2020
+#define MAXQLEN 4096
 
 #define ALLOCATOR_REQUEST 1
 
@@ -62,6 +63,13 @@ static void msgqueue_init(struct msg_channel *channel)
 	queue = msgget(key, IPC_CREAT);
 	igt_debug("msg queue: %d\n", queue);
 
+	igt_assert(msgctl(queue, IPC_STAT, &qstat) == 0);
+	igt_debug("msg size in bytes: %lu\n", qstat.msg_qbytes);
+	qstat.msg_qbytes = MAXQLEN * sizeof(struct msgqueue_buf);
+	igt_debug("resizing queue to support %d requests\n", MAXQLEN);
+	igt_assert_f(msgctl(queue, IPC_SET, &qstat) == 0,
+		     "Couldn't change queue size to %lu\n", qstat.msg_qbytes);
+
 	msgdata = calloc(1, sizeof(*msgdata));
 	igt_assert(msgdata);
 	msgdata->key = key;
-- 
2.26.0



More information about the igt-dev mailing list