diff mbox

[API-NEXT,PATCHv3,2/2] linux-generic: pktio ipc: share pool only if it has prefix ipc

Message ID 1455694959-14305-3-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Feb. 17, 2016, 7:42 a.m. UTC
Make check usually works fine but if it runs several tests in
parallel and each test uses the same pool name which mapped
to /dev/shm/ file memory corruption can occur. This patch
isolates pool sharing in shm. Because shm flags are hidden
there is no other way to do it with not touching api.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 platform/linux-generic/odp_pool.c                   | 11 ++++++++---
 platform/linux-generic/test/pktio_ipc/pktio_ipc1.c  |  2 +-
 platform/linux-generic/test/pktio_ipc/pktio_ipc2.c  |  2 +-
 platform/linux-generic/test/pktio_ipc/pktio_ipc_run |  8 ++++----
 4 files changed, 14 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index 9eaa0c8..1ce1933 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -422,10 +422,15 @@  odp_pool_t odp_pool_create(const char *name,
 			   odp_pool_param_t *params)
 {
 #ifdef ODP_PKTIO_IPC
-	return _pool_create(name, params, ODP_SHM_PROC);
-#else
+	/* For now we do not change API to support IPC
+	 * pktio. But we need to say that pool should be
+	 * exported to shm. Use name prefix until there
+	 * will be not API for that.
+	 */
+	if (strncmp(name, "ipc_", 4) == 0)
+		return _pool_create(name, params, ODP_SHM_PROC);
+#endif
 	return _pool_create(name, params, 0);
-#endif
 }
 
 odp_pool_t odp_pool_lookup(const char *name)
diff --git a/platform/linux-generic/test/pktio_ipc/pktio_ipc1.c b/platform/linux-generic/test/pktio_ipc/pktio_ipc1.c
index cebcba5..01dec7a 100644
--- a/platform/linux-generic/test/pktio_ipc/pktio_ipc1.c
+++ b/platform/linux-generic/test/pktio_ipc/pktio_ipc1.c
@@ -302,7 +302,7 @@  int main(int argc, char *argv[])
 	params.pkt.num     = SHM_PKT_POOL_SIZE;
 	params.type        = ODP_POOL_PACKET;
 
-	pool = odp_pool_create("packet_pool1", &params);
+	pool = odp_pool_create("ipc_packet_pool1", &params);
 	if (pool == ODP_POOL_INVALID) {
 		EXAMPLE_ERR("Error: packet pool create failed.\n");
 		exit(EXIT_FAILURE);
diff --git a/platform/linux-generic/test/pktio_ipc/pktio_ipc2.c b/platform/linux-generic/test/pktio_ipc/pktio_ipc2.c
index 5579aad..83680d8 100644
--- a/platform/linux-generic/test/pktio_ipc/pktio_ipc2.c
+++ b/platform/linux-generic/test/pktio_ipc/pktio_ipc2.c
@@ -39,7 +39,7 @@  static int ipc_second_process(void)
 	params.pkt.num     = SHM_PKT_POOL_SIZE;
 	params.type        = ODP_POOL_PACKET;
 
-	pool = odp_pool_create("packet_pool2", &params);
+	pool = odp_pool_create("ipc_packet_pool2", &params);
 	if (pool == ODP_POOL_INVALID) {
 		EXAMPLE_ERR("Error: packet pool create failed.\n");
 		exit(EXIT_FAILURE);
diff --git a/platform/linux-generic/test/pktio_ipc/pktio_ipc_run b/platform/linux-generic/test/pktio_ipc/pktio_ipc_run
index 08a7457..f66e907 100755
--- a/platform/linux-generic/test/pktio_ipc/pktio_ipc_run
+++ b/platform/linux-generic/test/pktio_ipc/pktio_ipc_run
@@ -24,8 +24,8 @@  run()
 	#if test was interrupted with CTRL+c than files
 	#might remain in shm. Needed cleanely delete them.
 	rm -rf /dev/shm/ipc_pktio_* 2>&1 > /dev/null
-	rm -rf /dev/shm/packet_pool1 2>&1 > /dev/null
-	rm -rf /dev/shm/packet_pool2 2>&1 > /dev/null
+	rm -rf /dev/shm/ipc_packet_pool1 2>&1 > /dev/null
+	rm -rf /dev/shm/ipc_packet_pool2 2>&1 > /dev/null
 
 	echo "==== run pktio_ipc1 then pktio_ipc2 ===="
 	pktio_ipc1${EXEEXT} -t 30 &
@@ -40,8 +40,8 @@  run()
 	kill ${IPC_PID} 2>&1 > /dev/null
 	if [ $? -eq 0 ]; then
 		rm -rf /dev/shm/ipc_pktio_* 2>&1 > /dev/null
-		rm -rf /dev/shm/packet_pool1 2>&1 > /dev/null
-		rm -rf /dev/shm/packet_pool2 2>&1 > /dev/null
+		rm -rf /dev/shm/ipc_packet_pool1 2>&1 > /dev/null
+		rm -rf /dev/shm/ipc_packet_pool2 2>&1 > /dev/null
 	fi
 
 	if [ $ret -ne 0 ]; then