From patchwork Wed Feb 17 06:40:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 62089 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2106108lbl; Tue, 16 Feb 2016 22:42:27 -0800 (PST) X-Received: by 10.55.71.66 with SMTP id u63mr32080249qka.67.1455691347379; Tue, 16 Feb 2016 22:42:27 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e13si44749750qka.120.2016.02.16.22.42.27; Tue, 16 Feb 2016 22:42:27 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id E4DCE615FD; Wed, 17 Feb 2016 06:42:26 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=A2K7VEFy; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 9FD7C66781; Wed, 17 Feb 2016 06:41:16 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id E41256193C; Wed, 17 Feb 2016 06:41:10 +0000 (UTC) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by lists.linaro.org (Postfix) with ESMTPS id 39F2A6193C for ; Wed, 17 Feb 2016 06:41:09 +0000 (UTC) Received: by mail-lb0-f182.google.com with SMTP id x4so3850546lbm.0 for ; Tue, 16 Feb 2016 22:41:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6+58JMXQBm4ywsZEhvlc0uYCKwvdiaUH6AIoFgZJYPc=; b=A2K7VEFyxDcQhtUjecxGA5A5HzZX8jmn4mznTqqSdmT2GbVkH6+t2b4uz2qZ3VGWqe X4+C7g/x8AMear64Ue8MlkM5Xg0ZXcyl9nAaPU1kAZwLD7HeN2kaR8D9ZofrO3I98NDE i15bHD5xKxPAdVsrZYQkJSwJxL+vi6fRzKIsU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6+58JMXQBm4ywsZEhvlc0uYCKwvdiaUH6AIoFgZJYPc=; b=YO+sZ09Sfuo/AZV9R3OtUZ6SDgQt860DJJoJzxIgNiOBYQTSLhvfhAMNtfjDx6Pj7j G67jlTlgvhPY5zBOFhWSovgN+680t8XU4tLuk7FI4yb1dueNugT37/Ps+idokixPn/IT N74ghbcRZYOLkSzfYEKtWwzOUSS1QtV9LFtY8jeWW4kjZ3T0weom0IJ6+BNDpc+FfDLM rY8tFSjb1dse1ZTagRQ67NQmIVuFCWlmRJFAP5e1bdMjEIlz3u8RrFpRwzLP17OSDQIm 9+iPqtU4yupS7VKfQ6B6hkRnc4T/9F3u/rfeWIhy9++kUUGQKcEr4/q1vUMf3hoK3DqY vezQ== X-Gm-Message-State: AG10YOSZzGFB2zY6mXO1Gt1hSKN9pHsDmziceCArF8wKCmE/oKYNR48R5jdaHqAFpLGUguA16JA= X-Received: by 10.112.67.1 with SMTP id j1mr9460512lbt.103.1455691268066; Tue, 16 Feb 2016 22:41:08 -0800 (PST) Received: from localhost.localdomain (ppp91-76-173-134.pppoe.mtu-net.ru. [91.76.173.134]) by smtp.gmail.com with ESMTPSA id n185sm4618350lfd.11.2016.02.16.22.41.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Feb 2016 22:41:07 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 17 Feb 2016 09:40:58 +0300 Message-Id: <1455691258-11567-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 In-Reply-To: <1455691258-11567-1-git-send-email-maxim.uvarov@linaro.org> References: <1455691258-11567-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 2/2] linux-generic: pktio ipc: share pool only if it has prefix ipc X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" 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 --- 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 --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", ¶ms); + pool = odp_pool_create("ipc_packet_pool1", ¶ms); 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", ¶ms); + pool = odp_pool_create("ipc_packet_pool2", ¶ms); 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