All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/intel_allocator: Add flag signalling multiprocess readyness
@ 2022-05-26  7:28 Zbigniew Kempczyński
  0 siblings, 0 replies; 2+ messages in thread
From: Zbigniew Kempczyński @ 2022-05-26  7:28 UTC (permalink / raw)
  To: igt-dev

Currently when children processes try to communicate to not existing
allocator thread they got crash with vague SIGSEGV.

Adding readyness flag and detailed explanation in assert should hint
the developer to add missing intel_allocator_multiprocess_start|stop)
functions.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
---
 lib/intel_allocator.c            | 4 ++++
 lib/intel_allocator_msgchannel.c | 2 ++
 lib/intel_allocator_msgchannel.h | 1 +
 3 files changed, 7 insertions(+)

diff --git a/lib/intel_allocator.c b/lib/intel_allocator.c
index 340b888286..06803bf5e0 100644
--- a/lib/intel_allocator.c
+++ b/lib/intel_allocator.c
@@ -737,6 +737,10 @@ static int handle_request(struct alloc_req *req, struct alloc_resp *resp)
 		return 0;
 	}
 
+	igt_assert_f(channel->ready,
+		     "Allocator must be called in multiprocess mode, "
+		     "use intel_allocator_multiprocess_(start|stop)()\n");
+
 	ret = send_req_recv_resp(channel, req, resp);
 
 	if (ret < 0)
diff --git a/lib/intel_allocator_msgchannel.c b/lib/intel_allocator_msgchannel.c
index 172858d3df..cd0f0a5d26 100644
--- a/lib/intel_allocator_msgchannel.c
+++ b/lib/intel_allocator_msgchannel.c
@@ -75,6 +75,7 @@ static void msgqueue_init(struct msg_channel *channel)
 	msgdata->key = key;
 	msgdata->queue = queue;
 	channel->priv = msgdata;
+	channel->ready = true;
 }
 
 static void msgqueue_deinit(struct msg_channel *channel)
@@ -84,6 +85,7 @@ static void msgqueue_deinit(struct msg_channel *channel)
 	igt_debug("Deinit msgqueue\n");
 	msgctl(msgdata->queue, IPC_RMID, NULL);
 	free(channel->priv);
+	channel->ready = false;
 }
 
 static int msgqueue_send_req(struct msg_channel *channel,
diff --git a/lib/intel_allocator_msgchannel.h b/lib/intel_allocator_msgchannel.h
index ef129c3077..cefbf4ce33 100644
--- a/lib/intel_allocator_msgchannel.h
+++ b/lib/intel_allocator_msgchannel.h
@@ -140,6 +140,7 @@ struct alloc_resp {
 };
 
 struct msg_channel {
+	bool ready;
 	void *priv;
 	void (*init)(struct msg_channel *channel);
 	void (*deinit)(struct msg_channel *channel);
-- 
2.32.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [igt-dev] [PATCH i-g-t] lib/intel_allocator: Add flag signalling multiprocess readyness
@ 2022-05-25 11:23 Zbigniew Kempczyński
  0 siblings, 0 replies; 2+ messages in thread
From: Zbigniew Kempczyński @ 2022-05-25 11:23 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala

Currently when children processes try to communicate to not existing
allocator thread they got crash with vague SIGSEGV.

Adding readyness flag and detailed explanation in assert should hint
the developer to add missing intel_allocator_multiprocess_start|stop)
functions.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
---
 lib/intel_allocator.c            | 4 ++++
 lib/intel_allocator_msgchannel.c | 2 ++
 lib/intel_allocator_msgchannel.h | 1 +
 3 files changed, 7 insertions(+)

diff --git a/lib/intel_allocator.c b/lib/intel_allocator.c
index 340b888286..06803bf5e0 100644
--- a/lib/intel_allocator.c
+++ b/lib/intel_allocator.c
@@ -737,6 +737,10 @@ static int handle_request(struct alloc_req *req, struct alloc_resp *resp)
 		return 0;
 	}
 
+	igt_assert_f(channel->ready,
+		     "Allocator must be called in multiprocess mode, "
+		     "use intel_allocator_multiprocess_(start|stop)()\n");
+
 	ret = send_req_recv_resp(channel, req, resp);
 
 	if (ret < 0)
diff --git a/lib/intel_allocator_msgchannel.c b/lib/intel_allocator_msgchannel.c
index 172858d3df..cd0f0a5d26 100644
--- a/lib/intel_allocator_msgchannel.c
+++ b/lib/intel_allocator_msgchannel.c
@@ -75,6 +75,7 @@ static void msgqueue_init(struct msg_channel *channel)
 	msgdata->key = key;
 	msgdata->queue = queue;
 	channel->priv = msgdata;
+	channel->ready = true;
 }
 
 static void msgqueue_deinit(struct msg_channel *channel)
@@ -84,6 +85,7 @@ static void msgqueue_deinit(struct msg_channel *channel)
 	igt_debug("Deinit msgqueue\n");
 	msgctl(msgdata->queue, IPC_RMID, NULL);
 	free(channel->priv);
+	channel->ready = false;
 }
 
 static int msgqueue_send_req(struct msg_channel *channel,
diff --git a/lib/intel_allocator_msgchannel.h b/lib/intel_allocator_msgchannel.h
index ef129c3077..cefbf4ce33 100644
--- a/lib/intel_allocator_msgchannel.h
+++ b/lib/intel_allocator_msgchannel.h
@@ -140,6 +140,7 @@ struct alloc_resp {
 };
 
 struct msg_channel {
+	bool ready;
 	void *priv;
 	void (*init)(struct msg_channel *channel);
 	void (*deinit)(struct msg_channel *channel);
-- 
2.32.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-26  7:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26  7:28 [igt-dev] [PATCH i-g-t] lib/intel_allocator: Add flag signalling multiprocess readyness Zbigniew Kempczyński
  -- strict thread matches above, loose matches on Subject: below --
2022-05-25 11:23 Zbigniew Kempczyński

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.