From patchwork Tue Jul 4 22:00:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107027 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp56430qge; Tue, 4 Jul 2017 15:00:53 -0700 (PDT) X-Received: by 10.55.109.199 with SMTP id i190mr52656103qkc.125.1499205653057; Tue, 04 Jul 2017 15:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499205653; cv=none; d=google.com; s=arc-20160816; b=qDC13Fb/LpEKebZdByMfVBC1be0L4FO46kcHkBtmUKvrEJrhL5EtjiZRtapJII1SXo cxHVkPiRUmEp5l3TPnxoqg3PM/QKWfZpv5NVo5qgqcvMBpoPA/QX478uFJU4U8kEwU5g Tr+t/MGkf1E6gHeG6q52YuZ4uSg9XOWtuq3NFydBU2G37caMPA8svQqZSJylfGsE+Cg1 q+FuYEST3CYRnxPyGUnruHJLSMNQZZx0M9PRsof8S7OGd2wTSGkRf43JGcba9w10Ms1w 8xZ2hqFOvhGRCphorfjZhYlGswnJZDGi1uQ49GxNZmn5DvrXxxY0M7VbvvOPgHxBXBpl cuSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=3vPOSqK5tyLAHxxCAE7psmXwxIHc6729fII9mLQxBl8=; b=SOSdI8rPqeH7r5/d+4vre7n3hjH7emEkIUQ2cGoqZ/Tk7rhf54Z2NC2fZTEM4wpzNN 9VDm+HwsJwx/Hnvde4R2Ma8bUnuCcPQZF5PptyFIdindfabMlJqF+LCaLxyhF6Z5z0FM /SR9H/Hk1XuoFqbMgGea0qVsY48g2OoQRDh/atrwqFRIqeFIiUHAzCZLra7Yw6dIvjLK KfVYEWMUwfI2o2UT9qDrB4EcVM9htHB4sOuZTlEHRvyheaDKKjvB3Jq23mrnRFdMYvwW HZkAiFFAwULtxpUa9kkjXIqoHPG55yq42P4lULTU8kTlpieId9ZuHirpO6iTnHz8caUC EdQQ== ARC-Authentication-Results: i=1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id w20si13117302qtw.257.2017.07.04.15.00.50; Tue, 04 Jul 2017 15:00:53 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id F0ECF607C8; Tue, 4 Jul 2017 22:00:49 +0000 (UTC) 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.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW 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 AB69D60C06; Tue, 4 Jul 2017 22:00:18 +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 53BF66071A; Tue, 4 Jul 2017 22:00:15 +0000 (UTC) Received: from forward3h.cmail.yandex.net (forward3h.cmail.yandex.net [87.250.230.18]) by lists.linaro.org (Postfix) with ESMTPS id CE3E16067C for ; Tue, 4 Jul 2017 22:00:13 +0000 (UTC) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [77.88.29.85]) by forward3h.cmail.yandex.net (Yandex) with ESMTP id 9E6AE210F4 for ; Wed, 5 Jul 2017 01:00:11 +0300 (MSK) Received: from smtp2p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2p.mail.yandex.net (Yandex) with ESMTP id 635AE1A8003E for ; Wed, 5 Jul 2017 01:00:10 +0300 (MSK) Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id b3wfOILtJj-0APGQxjI; Wed, 05 Jul 2017 01:00:10 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 5 Jul 2017 01:00:01 +0300 Message-Id: <1499205607-30786-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> References: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 67 Subject: [lng-odp] [PATCH v1 1/7] linux-gen: pktio: ipc fix send return code on tx 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Maxim Uvarov Return number on sent packets, but not succesuful return code. Signed-off-by: Maxim Uvarov --- /** Email created from pull request 67 (muvarov:master_ipc_fixes) ** https://github.com/Linaro/odp/pull/67 ** Patch: https://github.com/Linaro/odp/pull/67.patch ** Base sha: ceeab69f3af67701adb524c7b9757d19cefb1110 ** Merge commit sha: 6f88e14c89b861d66bb7043b22f9b299b1f73ddf **/ platform/linux-generic/pktio/ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index 06175e5a..1a2a37f2 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -609,7 +609,7 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, ODP_ABORT("Unexpected!\n"); } - return ret; + return len; } static int ipc_pktio_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, From patchwork Tue Jul 4 22:00:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107028 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp56816qge; Tue, 4 Jul 2017 15:01:19 -0700 (PDT) X-Received: by 10.55.102.203 with SMTP id a194mr49303361qkc.180.1499205679009; Tue, 04 Jul 2017 15:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499205679; cv=none; d=google.com; s=arc-20160816; b=pS3IvgwszS98rPV+2ycB3uRdj3LuTuBn744T9AvM1DnSTIw9d6puJLuu6oseDSn5uZ gx/92K51q7VOmwic+E88NAHKojU+dceTgnJNaiPHFdqb2HmvBIROtYwFqsuB4yqPuFed +8ov2S57TY1mBOPkcOxXP/FaXSyZY/VTS2szVVkd4T7vBIrB21bT2yAVXCuLagM3XIUP IyJMWpgo8+QLqO4iwIKpRoeEOAEue3aXTUyNvA7k2+Sn7mPGuvymyR+l8oxhUjHMC/4s oUqPcGEOZboYJRpI1aUAUKqDlhZGANDHTRrCIlWgO9GbrxxR4dWJeBVwzn/D8MD7BmfS 9aBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=eWmZ8GQvFFZauLHHwykN1M56jEC69xM6/EqouuzHY5I=; b=CdyCzsAfxezN9Nd8BnpHzdycJ69Unz84ZFJcdyGWHJAq/4/sPhojaUkyuLItoGgU/+ MxGiHClKn8XS3Q4400xUMZlOBLOF3qS4rRPDGhDzc9UZSFqtn2Gd8lXvUHMsTvofZXpJ aoRI0Ukm/oTLvj+v0MqlMu/b8Slzdd20PVBI9lkxG2Dq/7tbe2ff8G1g33PtYfhDHdfo FCa+jGHt7I3LvgmsdaPyfYWZo7kFMoMI7LqNEDIYwKRc3b1dupDVaIh2bHyBpCPF6MyP WjDA4hYH4z07G0M++rGBVW7zg9wTu28GT8dZJ0deGjwlRre4xpt8MT/MPqe+bkgLeUoW 0Gnw== ARC-Authentication-Results: i=1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id r88si18697518qki.306.2017.07.04.15.01.18; Tue, 04 Jul 2017 15:01:18 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id A8A4E60C0A; Tue, 4 Jul 2017 22:01:18 +0000 (UTC) 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.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW 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 0E1FA60C12; Tue, 4 Jul 2017 22:00:21 +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 4A9996071D; Tue, 4 Jul 2017 22:00:15 +0000 (UTC) Received: from forward4m.cmail.yandex.net (forward4m.cmail.yandex.net [5.255.216.22]) by lists.linaro.org (Postfix) with ESMTPS id 331746018A for ; Tue, 4 Jul 2017 22:00:14 +0000 (UTC) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:7]) by forward4m.cmail.yandex.net (Yandex) with ESMTP id C696320F6E for ; Wed, 5 Jul 2017 01:00:12 +0300 (MSK) Received: from smtp2p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2p.mail.yandex.net (Yandex) with ESMTP id 8CCF61A80054 for ; Wed, 5 Jul 2017 01:00:11 +0300 (MSK) Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id b3wfOILtJj-0BPGwnXi; Wed, 05 Jul 2017 01:00:11 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 5 Jul 2017 01:00:02 +0300 Message-Id: <1499205607-30786-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> References: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 67 Subject: [lng-odp] [PATCH v1 2/7] linux-gen: pktio: ipc fix error check 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Maxim Uvarov Code clean up, break before entering to for loop. Signed-off-by: Maxim Uvarov --- /** Email created from pull request 67 (muvarov:master_ipc_fixes) ** https://github.com/Linaro/odp/pull/67 ** Patch: https://github.com/Linaro/odp/pull/67.patch ** Base sha: ceeab69f3af67701adb524c7b9757d19cefb1110 ** Merge commit sha: 6f88e14c89b861d66bb7043b22f9b299b1f73ddf **/ platform/linux-generic/pktio/ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index 1a2a37f2..7a054962 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -401,7 +401,7 @@ static void _ipc_free_ring_packets(pktio_entry_t *pktio_entry, _ring_t *r) while (1) { ret = _ring_mc_dequeue_burst(r, rbuf_p, PKTIO_IPC_ENTRIES); - if (0 == ret) + if (ret <= 0) break; for (i = 0; i < ret; i++) { odp_packet_hdr_t *phdr; From patchwork Tue Jul 4 22:00:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107029 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp57328qge; Tue, 4 Jul 2017 15:01:54 -0700 (PDT) X-Received: by 10.55.40.140 with SMTP id o12mr48105717qko.50.1499205714578; Tue, 04 Jul 2017 15:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499205714; cv=none; d=google.com; s=arc-20160816; b=HOZfwUCINWm3nBfLT0x0P/2DVx7M4tXV9Jwk7Kh6WnK0UESH3pR6ZuBQx9qO/hkc+K zxXAOxTi3OfjxMq9wPwZgsf8j9Fi5KP0om/v5Bh+P/GY8wu3H8UxJ0qirQqJhGlxLdDo DnHHwnOXV84vIU0Ki2t4E11TuSeDwMY0e9a5RpABmMxBspVvkRXzLKCT00xssHTFUE6M YUBxUFBkR3et2F7IwyP8F7EN2JCX6ijqmOVGROVRdtVmBobl071KlJbGsEqKKkedqUuh JMx0bCrEMTQnTUrCighmwSt/jZkJFag9Xn+Wef74+kJkyNqX3kCSLxy4AR/V8jKhfS9t 3IwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=oVypHjVCeMkh7WHfMJ5A64W1b1qwt0hAdwoN0Ev35rc=; b=ncAyEeOfW40Qgo3Vq8S6QIf74TqSy3xoLlDjJRrbUDTrlHuuqpjPbjY0SFC1rix+r0 3uXjtf+KImaDu5wUwd4oza8Q8chSjCkXd+822ZKR4h09k66M7wgZUM1GVDNpMUkRWF6C GT17LCTIOZXQJeBJChuW+nX9pAI+WunIfNXxE1/wpOPm0UbbU6P7o8+FZBlMDyRG5tlC YtWrnUrzSzwkTmjcyFp/EyIPiCXIlpIJ+6UutwAs1SzKZZtNItVZ7W3wqdCV3mI3sZH0 /P+TyxJK6aevC+QiRiJet5yl26fggHfJm57UlYlyTwOJszyXpCkR76WsfWCUB7G/aw19 /JYg== ARC-Authentication-Results: i=1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id v82si18225926qka.338.2017.07.04.15.01.52; Tue, 04 Jul 2017 15:01:54 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id CB8D160C1E; Tue, 4 Jul 2017 22:01:52 +0000 (UTC) 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.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW 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 48A6E60C16; Tue, 4 Jul 2017 22:00:24 +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 7478960C06; Tue, 4 Jul 2017 22:00:17 +0000 (UTC) Received: from forward5o.cmail.yandex.net (forward5o.cmail.yandex.net [37.9.109.249]) by lists.linaro.org (Postfix) with ESMTPS id DEE106018A for ; Tue, 4 Jul 2017 22:00:15 +0000 (UTC) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:7]) by forward5o.cmail.yandex.net (Yandex) with ESMTP id 6080820BF0 for ; Wed, 5 Jul 2017 01:00:14 +0300 (MSK) Received: from smtp2p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2p.mail.yandex.net (Yandex) with ESMTP id 865171A8003E for ; Wed, 5 Jul 2017 01:00:13 +0300 (MSK) Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id b3wfOILtJj-0CPS5m9O; Wed, 05 Jul 2017 01:00:12 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 5 Jul 2017 01:00:03 +0300 Message-Id: <1499205607-30786-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> References: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 67 Subject: [lng-odp] [PATCH v1 3/7] linux-gen: pktio: ipc: rx: push back not processed packets 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Maxim Uvarov Signed-off-by: Maxim Uvarov --- /** Email created from pull request 67 (muvarov:master_ipc_fixes) ** https://github.com/Linaro/odp/pull/67 ** Patch: https://github.com/Linaro/odp/pull/67.patch ** Base sha: ceeab69f3af67701adb524c7b9757d19cefb1110 ** Merge commit sha: 6f88e14c89b861d66bb7043b22f9b299b1f73ddf **/ platform/linux-generic/pktio/ipc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index 7a054962..6b631098 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -498,12 +498,24 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, pkt_table[i] = pkt; } + /* put back to rx ring dequed but not processed packets*/ + if (pkts != i) { + r_p = pktio_entry->s.ipc.rx.recv; + ipcbufs_p = (void *)&offsets[i]; + pkts_ring = _ring_mp_enqueue_burst(r_p, ipcbufs_p, pkts - i); + if (pkts_ring != (pkts - i)) + ODP_ERR("bug to enqueue packets\n"); + } + + /*num of actually received packets*/ + pkts = i; + /* Now tell other process that we no longer need that buffers.*/ r_p = pktio_entry->s.ipc.rx.free; repeat: pkts_ring = _ring_mp_enqueue_burst(r_p, ipcbufs_p, pkts); - if (odp_unlikely(pkts < 0)) + if (odp_unlikely(pkts_ring < 0)) ODP_ABORT("ipc: odp_ring_mp_enqueue_bulk r_p fail\n"); if (odp_unlikely(pkts != pkts_ring)) { IPC_ODP_DBG("odp_ring_full: %d, odp_ring_count %d," From patchwork Tue Jul 4 22:00:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107030 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp57754qge; Tue, 4 Jul 2017 15:02:25 -0700 (PDT) X-Received: by 10.237.54.225 with SMTP id f88mr50123678qtb.240.1499205745063; Tue, 04 Jul 2017 15:02:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499205745; cv=none; d=google.com; s=arc-20160816; b=yM4SU9z1qBs/G79hpj94gsLUNRESm8XrQrOHv9MMKd5wlMQhfHY6KFAoLHxAtS6PTT a/1PxJh3Eh7y8rLAzFh2aJaeyuAc/+sHAJd02Hc4dPj2pbJ5IcTTcJGHFcss9IzHvu9V dE3a29eMXEK1a3YwLirtlzu845vq+mtOB1jw2XZ+qg2CSlNMcH+IMYx/azjQxwxOWP9Y IdDhdyJYlMCQOH2rH991TN6ImN2dpXk7wBjwaRkeT4q6F1JVRDJFGTLVjLmaGm4lAOHa Na/CDUY99KCWNOHu6XQQ4vfArQR8nntKrdTdpchOMGT09BcDF9NHcY6YU+nzT5R2XG4x exhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=Q8Iv4ut4e3igQ8498b+2OpzfgG3xYuAFpfad23SORNA=; b=c5TWW5a9N0zlsjVxFinyfRKcPSzVQm+HF2Nq2zQKP1EQVV9Dg7TiHjovklcR+jrN7A C8BNKi8Xff/sQ3+F5cJRS0Cn99gTDVO7aRRBaZx2cvKFh4E+Di7d5USUOIZ3ofdpZ1MB +90I8PXJXCcMjvBxDcEskBak7hw1Yjwe2XeKulGyO8CH1UFJBWFyLqAWZpkOw36SFXwU wyOaGri0xNWNL1E3KL10P64MU6CkIiz+fW+PyiMQPGGOm62Wlk07FWq4ZKbOUFqYHGud C9P3OKD5rJpoPfKw3p+CkB/oKRI++ILoP1lTut1n5Xx04XyoPOxkaDr67eV8//SvstQK 4OSA== ARC-Authentication-Results: i=1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k16si19345181qkk.171.2017.07.04.15.02.24; Tue, 04 Jul 2017 15:02:25 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 5BF2D60C13; Tue, 4 Jul 2017 22:02:24 +0000 (UTC) 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.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW 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 9198460C1B; Tue, 4 Jul 2017 22:00:30 +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 AFA2E60C1B; Tue, 4 Jul 2017 22:00:24 +0000 (UTC) Received: from forward2h.cmail.yandex.net (forward2h.cmail.yandex.net [87.250.230.17]) by lists.linaro.org (Postfix) with ESMTPS id 09F976067C for ; Tue, 4 Jul 2017 22:00:17 +0000 (UTC) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [77.88.29.85]) by forward2h.cmail.yandex.net (Yandex) with ESMTP id EB34B20BF6 for ; Wed, 5 Jul 2017 01:00:14 +0300 (MSK) Received: from smtp2p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2p.mail.yandex.net (Yandex) with ESMTP id AA2031A8003E for ; Wed, 5 Jul 2017 01:00:14 +0300 (MSK) Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id b3wfOILtJj-0DPq7guc; Wed, 05 Jul 2017 01:00:13 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 5 Jul 2017 01:00:04 +0300 Message-Id: <1499205607-30786-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> References: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 67 Subject: [lng-odp] [PATCH v1 4/7] linux-gen: ipc remove base_addr_offset 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Maxim Uvarov base_addr_offset is not used in this version, remove it. Signed-off-by: Maxim Uvarov --- /** Email created from pull request 67 (muvarov:master_ipc_fixes) ** https://github.com/Linaro/odp/pull/67 ** Patch: https://github.com/Linaro/odp/pull/67.patch ** Base sha: ceeab69f3af67701adb524c7b9757d19cefb1110 ** Merge commit sha: 6f88e14c89b861d66bb7043b22f9b299b1f73ddf **/ platform/linux-generic/include/odp_packet_io_ipc_internal.h | 8 -------- platform/linux-generic/pktio/ipc.c | 7 ++----- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_io_ipc_internal.h b/platform/linux-generic/include/odp_packet_io_ipc_internal.h index 7cd29488..9d8943a6 100644 --- a/platform/linux-generic/include/odp_packet_io_ipc_internal.h +++ b/platform/linux-generic/include/odp_packet_io_ipc_internal.h @@ -30,19 +30,11 @@ struct pktio_info { int num; /* size of packet/segment in remote pool */ uint32_t block_size; - /* offset from shared memory block start - * to pool *base_addr in remote process. - * (odp-linux pool specific) */ - size_t base_addr_offset; char pool_name[ODP_POOL_NAME_LEN]; /* 1 if master finished creation of all shared objects */ int init_done; } master; struct { - /* offset from shared memory block start - * to pool *base_addr in remote process. - * (odp-linux pool specific) */ - size_t base_addr_offset; void *base_addr; uint32_t block_size; char pool_name[ODP_POOL_NAME_LEN]; diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index 6b631098..54e42227 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -59,8 +59,7 @@ static int _ipc_master_start(pktio_entry_t *pktio_entry) pktio_entry->s.ipc.remote_pool_shm = shm; pktio_entry->s.ipc.pool_base = odp_shm_addr(shm); - pktio_entry->s.ipc.pool_mdata_base = (char *)odp_shm_addr(shm) + - pinfo->slave.base_addr_offset; + pktio_entry->s.ipc.pool_mdata_base = (char *)odp_shm_addr(shm); odp_atomic_store_u32(&pktio_entry->s.ipc.ready, 1); @@ -153,7 +152,6 @@ static int _ipc_init_master(pktio_entry_t *pktio_entry, } memcpy(pinfo->master.pool_name, pool_name, strlen(pool_name)); - pinfo->slave.base_addr_offset = 0; pinfo->slave.base_addr = 0; pinfo->slave.pid = 0; pinfo->slave.init_done = 0; @@ -297,8 +295,7 @@ static int _ipc_slave_start(pktio_entry_t *pktio_entry) shm = _ipc_map_remote_pool(pinfo->master.pool_name, pid); pktio_entry->s.ipc.remote_pool_shm = shm; - pktio_entry->s.ipc.pool_mdata_base = (char *)odp_shm_addr(shm) + - pinfo->master.base_addr_offset; + pktio_entry->s.ipc.pool_mdata_base = (char *)odp_shm_addr(shm); pktio_entry->s.ipc.pkt_size = pinfo->master.block_size; _ipc_export_pool(pinfo, pktio_entry->s.ipc.pool); From patchwork Tue Jul 4 22:00:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107032 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp58298qge; Tue, 4 Jul 2017 15:03:00 -0700 (PDT) X-Received: by 10.55.104.78 with SMTP id d75mr50966460qkc.147.1499205780035; Tue, 04 Jul 2017 15:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499205780; cv=none; d=google.com; s=arc-20160816; b=OtwkBSPGyvBvZia2EVs02EYCak4nxjPf3tc4E1+zSMoEHIyDMBjNgXoa6wUK8rZ59g 7Gk4cVVwxofHYlCpI1ZDoQRSkUPqccoT/dlL/cxwHuV5UVjMUSaOR1upJeHBc83tQ5uI ypRBYYrfAKHi6Zx/Kh7Vxd+Bnw4O9GwK4gMZ3Gvx6+wpHDtl0C3o4TZBdMwVtevfbY7m uZPBpmMI7nKcVotzoyLdQ0Dr8qj8PxTxzn988GA5oq1ViiAIHVxcXUpADe7o9qLqDtzt PY65vCnVrEOpE0X5+kNsyMF4kqu2Mk7CaToIn95iwJ3yVd5MzLt0T0F96VNvDwYsGXBd EXzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=8cbC8VcrVPDcgGL6hpT7FXLjxnlxnZF6dhNp7g/mUdE=; b=DsBvOLsCJ76iGbRZ9SdWvp33RVU43HedYX6eJpOMo86JPDBGL9oGf35sZfEWXY2TFf 2giO6YLuBhx0h/2pfd8Zkl+leu2n0c6X01SprGxP1NIBBQhMxj4mBBg6NeLGavroaHRA C0fZxgoTSIHDJdyu15SFK9ggcBqD68z4GmbEVYd3elPd6xGNNGfBagG1j3d4tr2JR6bJ PznnZ+4jBeXEW5hRP5sXs2eeU14nyiY52tagbEJwJh2WTQoqu2zG2lqpMNLaIjFPcO8a wuDv4Zae4F0tZocLGawZZwyMtqoFh0KK2fUx4Bdc2XKIzSnttf1GBYj59xCALtvqwSSq QVdA== ARC-Authentication-Results: i=1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id w27si19526094qtc.83.2017.07.04.15.02.59; Tue, 04 Jul 2017 15:03:00 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 9C6E460C10; Tue, 4 Jul 2017 22:02:59 +0000 (UTC) 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.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW 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 D43206018A; Tue, 4 Jul 2017 22:00:34 +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 4623660C1A; Tue, 4 Jul 2017 22:00:25 +0000 (UTC) Received: from forward3j.cmail.yandex.net (forward3j.cmail.yandex.net [5.255.227.21]) by lists.linaro.org (Postfix) with ESMTPS id 3CDF26071D for ; Tue, 4 Jul 2017 22:00:17 +0000 (UTC) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:7]) by forward3j.cmail.yandex.net (Yandex) with ESMTP id BE98120BCE for ; Wed, 5 Jul 2017 01:00:15 +0300 (MSK) Received: from smtp2p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2p.mail.yandex.net (Yandex) with ESMTP id 9DEF01A80054 for ; Wed, 5 Jul 2017 01:00:15 +0300 (MSK) Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id b3wfOILtJj-0EP4d3K2; Wed, 05 Jul 2017 01:00:15 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 5 Jul 2017 01:00:05 +0300 Message-Id: <1499205607-30786-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> References: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 67 Subject: [lng-odp] [PATCH v1 5/7] shm: use shm in /dev/shm instead of /tmp 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Maxim Uvarov /tmp might be mounted to tmpfs or not mounted. If it's disk then some writes are loss there. At least ipc test shows missing packets in shm ring on 4.10.0-rc8+ kernel. Which is more likely kernel bug. Signed-off-by: Maxim Uvarov --- /** Email created from pull request 67 (muvarov:master_ipc_fixes) ** https://github.com/Linaro/odp/pull/67 ** Patch: https://github.com/Linaro/odp/pull/67.patch ** Base sha: ceeab69f3af67701adb524c7b9757d19cefb1110 ** Merge commit sha: 6f88e14c89b861d66bb7043b22f9b299b1f73ddf **/ platform/linux-generic/_fdserver.c | 2 +- platform/linux-generic/_ishm.c | 18 ++++++++++-------- platform/linux-generic/odp_init.c | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/platform/linux-generic/_fdserver.c b/platform/linux-generic/_fdserver.c index 9aed7a9f..20d6e233 100644 --- a/platform/linux-generic/_fdserver.c +++ b/platform/linux-generic/_fdserver.c @@ -58,7 +58,7 @@ #include #define FDSERVER_SOCKPATH_MAXLEN 32 -#define FDSERVER_SOCKPATH_FORMAT "/tmp/odp-%d-fdserver" +#define FDSERVER_SOCKPATH_FORMAT "/dev/shm/odp-%d-fdserver" #define FDSERVER_BACKLOG 5 #ifndef MAP_ANONYMOUS diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c index c1efd7d2..c0623f18 100644 --- a/platform/linux-generic/_ishm.c +++ b/platform/linux-generic/_ishm.c @@ -92,12 +92,13 @@ * Linux underlying file name: /odp--ishm- * The part may be replaced by a sequence number if no specific * name is given at reserve time - * is either /tmp or the hugepagefs mount point for default size. + * is either /dev/shm or the hugepagefs mount point for default + * size. * (searched at init time) */ #define ISHM_FILENAME_MAXLEN (ISHM_NAME_MAXLEN + 64) #define ISHM_FILENAME_FORMAT "%s/odp-%d-ishm-%s" -#define ISHM_FILENAME_NORMAL_PAGE_DIR "/tmp" +#define ISHM_FILENAME_NORMAL_PAGE_DIR "/dev/shm" /* * when the memory is to be shared with an external entity (such as another @@ -105,7 +106,7 @@ * export file is created describing the exported memory: this defines the * location and the filename format of this description file */ -#define ISHM_EXPTNAME_FORMAT "/tmp/odp-%d-shm-%s" +#define ISHM_EXPTNAME_FORMAT "/dev/shm/odp-%d-shm-%s" /* * At worse case the virtual space gets so fragmented that there is @@ -117,7 +118,7 @@ /* * when a memory block is to be exported outside its ODP instance, - * an block 'attribute file' is created in /tmp/odp--shm-. + * an block 'attribute file' is created in /dev/shm/odp--shm-. * The information given in this file is according to the following: */ #define EXPORT_FILE_LINE1_FMT "ODP exported shm block info:" @@ -401,7 +402,7 @@ static void free_fragment(ishm_fragment_t *fragmnt) /* * Create file with size len. returns -1 on error - * Creates a file to /tmp/odp-- (for normal pages) + * Creates a file to /dev/shm/odp-- (for normal pages) * or /mnt/huge/odp-- (for huge pages) * Return the new file descriptor, or -1 on error. */ @@ -412,7 +413,8 @@ static int create_file(int block_index, huge_flag_t huge, uint64_t len, int fd; ishm_block_t *new_block; /* entry in the main block table */ char seq_string[ISHM_FILENAME_MAXLEN]; /* used to construct filename*/ - char filename[ISHM_FILENAME_MAXLEN];/* filename in /tmp/ or /mnt/huge */ + char filename[ISHM_FILENAME_MAXLEN]; /* filename in /dev/shm or + * /mnt/huge */ int oflag = O_RDWR | O_CREAT | O_TRUNC; /* flags for open */ FILE *export_file; @@ -530,7 +532,7 @@ static void *do_map(int block_index, uint64_t len, uint32_t align, new_block = &ishm_tbl->block[block_index]; /* - * Creates a file to /tmp/odp-- (for normal pages) + * Creates a file to /dev/shm/odp-- (for normal pages) * or /mnt/huge/odp-- (for huge pages) * unless a fd was already given */ @@ -761,7 +763,7 @@ static void procsync(void) * If ok, allocate a new shared memory block and map the * provided fd in it (if fd >=0 was given). * If no fd is provided, a shared memory file desc named - * /tmp/odp--ishm- is created and mapped. + * /dev/shm/odp--ishm- is created and mapped. * (the name is different for huge page file as they must be on hugepagefs) * The function returns the index of the newly created block in the * main block table (>=0) or -1 on error. diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 06c61435..b4abb181 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -19,7 +19,7 @@ #include #define _ODP_FILES_FMT "odp-%d-" -#define _ODP_TMPDIR "/tmp" +#define _ODP_TMPDIR "/dev/shm" struct odp_global_data_s odp_global_data; From patchwork Tue Jul 4 22:00:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107033 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp59284qge; Tue, 4 Jul 2017 15:04:15 -0700 (PDT) X-Received: by 10.55.221.220 with SMTP id u89mr48299388qku.236.1499205855604; Tue, 04 Jul 2017 15:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499205855; cv=none; d=google.com; s=arc-20160816; b=fPHhMOf7tDaSpkinNrq5Q0ESXnqHfvhYfS/TWFDNCx6wuiRRERtrnpCU+KPSdTf2g2 JIRykI+z9IU35dYKOfXoRYcMUEZDIjGMhrhmYncZg0UcRqfU+R6UMldC3xn3AAzovDS4 ybc6cXnhyL86HFW+5bxfRpsmvJWVxbmWw+FgcngQRTgthcjB8YhcWJGPoAIyd0sxuBZh 1RA6kGzW0S9A25vjM2j/Q2xEWOrzDclZFsHuVmPYuNFfSmlGb0Im/QisJsfCSq4qKiQl OvY5hmpaTj5/BGZLpm75uCiQCBVjY59Msq1Znd6yUeuTwGgaI6Bxdgw6s6pq5wOIPl5V woGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=+HI+qrZ4US7lPJl5yvVIcRq/B30EtUpOa6tpES665Ok=; b=VjDeI/P4jcpFhI5np6+qE06fEMfXtLadYfs+0a9dYpycfwBrKwI1bIYiaHi71ECjtu iHjxWuC55RtBTDa2GmCC/3Wubde5tcJGGWWwzAgQOSQftAiBGvMyodR8z40HEomgJ511 mDdVNoWOuLiNRxXVCMES5zIQP5awooQefuGAfEX01vxvTJgQR8Xud4wD3gXNMiJrzRLb rK6+oc6v1t9VdoDcvW9spCazrzMHGJYPAgMCSZPQbOjoDMiZDdBVJGUnSOHdLXVgIH32 /bd6Y4yvnO01FDoWkPZ1VD1G4kzdhY6szDpL+0oBmn6xxUKpOUU7+Cepe/HPobwYXEhH B//g== ARC-Authentication-Results: i=1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id o187si18034749qkf.157.2017.07.04.15.04.15; Tue, 04 Jul 2017 15:04:15 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 38E6160C13; Tue, 4 Jul 2017 22:04:15 +0000 (UTC) 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.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW 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 7030A60C0D; Tue, 4 Jul 2017 22:01:14 +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 0716660C0E; Tue, 4 Jul 2017 22:01:08 +0000 (UTC) Received: from forward2p.cmail.yandex.net (forward2p.cmail.yandex.net [77.88.31.17]) by lists.linaro.org (Postfix) with ESMTPS id 419AE60C0E for ; Tue, 4 Jul 2017 22:00:19 +0000 (UTC) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:7]) by forward2p.cmail.yandex.net (Yandex) with ESMTP id 2C33921802 for ; Wed, 5 Jul 2017 01:00:17 +0300 (MSK) Received: from smtp2p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2p.mail.yandex.net (Yandex) with ESMTP id C30201A8003E for ; Wed, 5 Jul 2017 01:00:16 +0300 (MSK) Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id b3wfOILtJj-0FPGCZtl; Wed, 05 Jul 2017 01:00:15 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 5 Jul 2017 01:00:06 +0300 Message-Id: <1499205607-30786-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> References: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 67 Subject: [lng-odp] [PATCH v1 6/7] shm: add uid to shm files 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Maxim Uvarov new processes can get some earliar pid numbers which processes can be already dead. Because of previous process can be from other user it can have different access right to that file. To avoid that place shm files to /dev/shm/uid/odp- files Signed-off-by: Maxim Uvarov --- /** Email created from pull request 67 (muvarov:master_ipc_fixes) ** https://github.com/Linaro/odp/pull/67 ** Patch: https://github.com/Linaro/odp/pull/67.patch ** Base sha: ceeab69f3af67701adb524c7b9757d19cefb1110 ** Merge commit sha: 6f88e14c89b861d66bb7043b22f9b299b1f73ddf **/ platform/linux-generic/_fdserver.c | 25 ++++++++++++++++---- platform/linux-generic/_ishm.c | 27 ++++++++++++++-------- platform/linux-generic/include/odp_internal.h | 2 ++ platform/linux-generic/odp_init.c | 12 +++++++++- .../validation/api/shmem/shmem_common.h | 2 +- .../validation/api/shmem/shmem_linux.c | 15 ++++++++---- .../validation/api/shmem/shmem_odp1.c | 2 +- 7 files changed, 62 insertions(+), 23 deletions(-) diff --git a/platform/linux-generic/_fdserver.c b/platform/linux-generic/_fdserver.c index 20d6e233..7ed5e7a6 100644 --- a/platform/linux-generic/_fdserver.c +++ b/platform/linux-generic/_fdserver.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -57,8 +58,9 @@ #include #include -#define FDSERVER_SOCKPATH_MAXLEN 32 -#define FDSERVER_SOCKPATH_FORMAT "/dev/shm/odp-%d-fdserver" +#define FDSERVER_SOCKPATH_MAXLEN 255 +#define FDSERVER_SOCK_FORMAT "/dev/shm/%s/odp-%d-fdserver" +#define FDSERVER_SOCKDIR_FORMAT "/dev/shm/%s" #define FDSERVER_BACKLOG 5 #ifndef MAP_ANONYMOUS @@ -238,7 +240,8 @@ static int get_socket(void) int len; /* construct the named socket path: */ - snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCKPATH_FORMAT, + snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCK_FORMAT, + odp_global_data.uid, odp_global_data.main_pid); s_sock = socket(AF_UNIX, SOCK_STREAM, 0); @@ -581,8 +584,14 @@ int _odp_fdserver_init_global(void) odp_spinlock_init(client_lock); + snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCKDIR_FORMAT, + odp_global_data.uid); + + mkdir(sockpath, 0744); + /* construct the server named socket path: */ - snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCKPATH_FORMAT, + snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCK_FORMAT, + odp_global_data.uid, odp_global_data.main_pid); /* create UNIX domain socket: */ @@ -663,11 +672,17 @@ int _odp_fdserver_term_global(void) wait(&status); /* construct the server named socket path: */ - snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCKPATH_FORMAT, + snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCK_FORMAT, + odp_global_data.uid, odp_global_data.main_pid); /* delete the UNIX domain socket: */ unlink(sockpath); + /* delete shm files directory */ + snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCKDIR_FORMAT, + odp_global_data.uid); + unlink(sockpath); + return 0; } diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c index c0623f18..6545bfce 100644 --- a/platform/linux-generic/_ishm.c +++ b/platform/linux-generic/_ishm.c @@ -86,7 +86,7 @@ * Maximum internal shared memory block name length in chars * probably taking the same number as SHM name size make sense at this stage */ -#define ISHM_NAME_MAXLEN 32 +#define ISHM_NAME_MAXLEN 128 /* * Linux underlying file name: /odp--ishm- @@ -106,7 +106,7 @@ * export file is created describing the exported memory: this defines the * location and the filename format of this description file */ -#define ISHM_EXPTNAME_FORMAT "/dev/shm/odp-%d-shm-%s" +#define ISHM_EXPTNAME_FORMAT "/dev/shm/%s/odp-%d-shm-%s" /* * At worse case the virtual space gets so fragmented that there is @@ -417,6 +417,7 @@ static int create_file(int block_index, huge_flag_t huge, uint64_t len, * /mnt/huge */ int oflag = O_RDWR | O_CREAT | O_TRUNC; /* flags for open */ FILE *export_file; + char dir[ISHM_FILENAME_MAXLEN]; new_block = &ishm_tbl->block[block_index]; name = new_block->name; @@ -431,17 +432,21 @@ static int create_file(int block_index, huge_flag_t huge, uint64_t len, return -1; if (huge == HUGE) - snprintf(filename, ISHM_FILENAME_MAXLEN, - ISHM_FILENAME_FORMAT, + snprintf(dir, ISHM_FILENAME_MAXLEN, "%s/%s", odp_global_data.hugepage_info.default_huge_page_dir, - odp_global_data.main_pid, - (name && name[0]) ? name : seq_string); + odp_global_data.uid); else - snprintf(filename, ISHM_FILENAME_MAXLEN, - ISHM_FILENAME_FORMAT, + snprintf(dir, ISHM_FILENAME_MAXLEN, "%s/%s", ISHM_FILENAME_NORMAL_PAGE_DIR, - odp_global_data.main_pid, - (name && name[0]) ? name : seq_string); + odp_global_data.uid); + + snprintf(filename, ISHM_FILENAME_MAXLEN, + ISHM_FILENAME_FORMAT, + dir, + odp_global_data.main_pid, + (name && name[0]) ? name : seq_string); + + mkdir(dir, 0744); fd = open(filename, oflag, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd < 0) { @@ -471,6 +476,7 @@ static int create_file(int block_index, huge_flag_t huge, uint64_t len, ISHM_FILENAME_MAXLEN - 1); snprintf(new_block->exptname, ISHM_FILENAME_MAXLEN, ISHM_EXPTNAME_FORMAT, + odp_global_data.uid, odp_global_data.main_pid, (name && name[0]) ? name : seq_string); export_file = fopen(new_block->exptname, "w"); @@ -949,6 +955,7 @@ int _odp_ishm_find_exported(const char *remote_name, pid_t external_odp_pid, /* try to read the block description file: */ snprintf(export_filename, ISHM_FILENAME_MAXLEN, ISHM_EXPTNAME_FORMAT, + odp_global_data.uid, external_odp_pid, remote_name); diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 8bae028d..7e6811f3 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -25,6 +25,7 @@ extern "C" { #include #define MAX_CPU_NUMBER 128 +#define UID_MAXLEN 30 typedef struct { uint64_t cpu_hz_max[MAX_CPU_NUMBER]; @@ -42,6 +43,7 @@ typedef struct { struct odp_global_data_s { pid_t main_pid; + char uid[UID_MAXLEN]; odp_log_func_t log_fn; odp_abort_func_t abort_fn; system_info_t system_info; diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index b4abb181..f62ccec0 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #define _ODP_FILES_FMT "odp-%d-" #define _ODP_TMPDIR "/dev/shm" @@ -28,13 +30,16 @@ static int cleanup_files(const char *dirpath, int odp_pid) { struct dirent *e; DIR *dir; + char userdir[PATH_MAX]; char prefix[PATH_MAX]; char *fullpath; int d_len = strlen(dirpath); int p_len; int f_len; - dir = opendir(dirpath); + snprintf(userdir, PATH_MAX, "%s/%s", dirpath, odp_global_data.uid); + + dir = opendir(userdir); if (!dir) { /* ok if the dir does not exist. no much to delete then! */ ODP_DBG("opendir failed for %s: %s\n", @@ -70,10 +75,15 @@ int odp_init_global(odp_instance_t *instance, const odp_platform_init_t *platform_params ODP_UNUSED) { char *hpdir; + uid_t uid; memset(&odp_global_data, 0, sizeof(struct odp_global_data_s)); odp_global_data.main_pid = getpid(); + uid = getuid(); + snprintf(odp_global_data.uid, UID_MAXLEN, "%d", + uid); + enum init_stage stage = NO_INIT; odp_global_data.log_fn = odp_override_log; odp_global_data.abort_fn = odp_override_abort; diff --git a/test/linux-generic/validation/api/shmem/shmem_common.h b/test/linux-generic/validation/api/shmem/shmem_common.h index 16227ecd..621e3431 100644 --- a/test/linux-generic/validation/api/shmem/shmem_common.h +++ b/test/linux-generic/validation/api/shmem/shmem_common.h @@ -8,7 +8,7 @@ #define _COMMON_TEST_SHMEM_H_ #define ODP_SHM_NAME "odp_linux_shared_mem" -#define FIFO_NAME_FMT "/tmp/shmem_test_fifo-%d" +#define FIFO_NAME_FMT "/dev/shm/%d/shmem_test_fifo-%d" #define ALIGN_SIZE (128) #define TEST_SHARE_FOO (0xf0f0f0f0) #define TEST_SHARE_BAR (0xf0f0f0f) diff --git a/test/linux-generic/validation/api/shmem/shmem_linux.c b/test/linux-generic/validation/api/shmem/shmem_linux.c index 2f4c7628..d5931447 100644 --- a/test/linux-generic/validation/api/shmem/shmem_linux.c +++ b/test/linux-generic/validation/api/shmem/shmem_linux.c @@ -8,7 +8,7 @@ * flag is visible under linux, and checks that memory created with the * ODP_SHM_EXPORT flag is visible by other ODP instances. * It therefore checks both that the link - * name under /tmp is correct, and also checks that the memory contents + * name under /dev/shm is correct, and also checks that the memory contents * is indeed shared. * we want: * -the odp test to run using C UNIT @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -77,12 +78,14 @@ #include #include #include +#include #include "shmem_linux.h" #include "shmem_common.h" #define ODP_APP1_NAME "shmem_odp1" /* name of the odp1 program, in this dir */ #define ODP_APP2_NAME "shmem_odp2" /* name of the odp2 program, in this dir */ -#define DEVNAME_FMT "/tmp/odp-%" PRIu64 "-shm-%s" /* odp--shm- */ +/* odp--shm- */ +#define DEVNAME_FMT "/dev/shm/%d/odp-%" PRIu64 "-shm-%s" #define MAX_FIFO_WAIT 30 /* Max time waiting for the fifo (sec) */ /* @@ -108,7 +111,8 @@ static int read_shmem_attribues(uint64_t ext_odp_pid, const char *blockname, char shm_attr_filename[PATH_MAX]; FILE *export_file; - sprintf(shm_attr_filename, DEVNAME_FMT, ext_odp_pid, blockname); + sprintf(shm_attr_filename, DEVNAME_FMT, getuid(), + ext_odp_pid, blockname); /* O_CREAT flag not given => failure if shm_attr_filename does not * already exist */ @@ -205,6 +209,7 @@ int main(int argc __attribute__((unused)), char *argv[]) int shm_fd; test_shared_linux_data_t *addr; int app2_status; + uid_t uid = getuid(); /* odp_app1 is in the same directory as this file: */ strncpy(prg_name, argv[0], PATH_MAX - 1); @@ -223,7 +228,7 @@ int main(int argc __attribute__((unused)), char *argv[]) /* wait max 30 sec for the fifo to be created by the ODP side. * Just die if time expire as there is no fifo to communicate * through... */ - sprintf(fifo_name, FIFO_NAME_FMT, odp_app1); + sprintf(fifo_name, FIFO_NAME_FMT, uid, odp_app1); for (nb_sec = 0; nb_sec < MAX_FIFO_WAIT; nb_sec++) { fifo_fd = open(fifo_name, O_WRONLY); if (fifo_fd >= 0) @@ -244,7 +249,7 @@ int main(int argc __attribute__((unused)), char *argv[]) &user_len, &user_flags, &align) != 0) test_failure(fifo_name, fifo_fd, odp_app1); - /* open the shm filename (which is either on /tmp or on hugetlbfs) + /* open the shm filename (which is either on /dev/shm/ or on hugetlbfs) * O_CREAT flag not given => failure if shm_devname does not already * exist */ shm_fd = open(shm_filename, O_RDONLY, diff --git a/test/linux-generic/validation/api/shmem/shmem_odp1.c b/test/linux-generic/validation/api/shmem/shmem_odp1.c index 3869c2e1..c402365a 100644 --- a/test/linux-generic/validation/api/shmem/shmem_odp1.c +++ b/test/linux-generic/validation/api/shmem/shmem_odp1.c @@ -41,7 +41,7 @@ void shmem_test_odp_shm_proc(void) /* open the fifo: this will indicate to linux process that it can * start the shmem lookups and check if it sees the data */ - sprintf(fifo_name, FIFO_NAME_FMT, getpid()); + sprintf(fifo_name, FIFO_NAME_FMT, getuid(), getpid()); CU_ASSERT_FATAL(mkfifo(fifo_name, 0666) == 0); /* read from the fifo: the linux process result: */ From patchwork Tue Jul 4 22:00:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 107034 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp60109qge; Tue, 4 Jul 2017 15:05:20 -0700 (PDT) X-Received: by 10.200.45.182 with SMTP id p51mr50423314qta.208.1499205919961; Tue, 04 Jul 2017 15:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499205919; cv=none; d=google.com; s=arc-20160816; b=tNd2vIRAiiXyszo9gedSczLfn+u6XsB63XsVttmGOHUVP1eLZUzmjo0iSUOk0IGUjG /9FJI4E9O12e9mTb1/wMsqjWKn6qy6b+GvIr+qsHBNTFuqYHbAvKcVnnZyrBFsVcWsLm DUkT9iMMCY+tVYhGqf3SeaaCF7WkRJMCI9M2Ml3R2aYEBlXZSiMWPhhEG/1RAzSjjqbO clq8KrVu5mDaKJ/64DuwVbwcf693cMakHWC1oHNv18VIoS4TJbECDo6823JRc/2UuuQV Pu+rYEJdgOVo1qIb0l+yZmo2Bw0VbagwN8XU2pMSlinyjy+Oo/IsuGDnS3he1L5GdsPj o4VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=OvCErNfO4qNeFVI2+FLvGslADqnh48T6EQcGrsDjaGQ=; b=HjyQCl8uYRg0dHJXwjFZf5fdpwab60WejT5tzw6tvx3MtfO/QxEbdFn6wWfBkoH6qE /SBiWqW8+7nXBclDvFpYMFqJ0pO3afq+llUf5ZKn7rRMQNjdM4l7obpLkOyDySgpBebD d9eBsV0q5h3l7YBtoB/2H8tFuB0u1/j1LsM6SSbtQB4Nc3dBdMRoeEcN5Njo0Qr06P1/ DAk5udV1aU1bK9WHtZXRWyezOLoyl5r+8JX1cNEtaaQ4Lu7qJo1sBa/Nzp+YvDenFfiF iNClsdqoCQ4lZUYxmD6PslVdtW1qcwvK46ReQ27YfQn+Il41sH964L+RK6G9+JNdUJad bwYw== ARC-Authentication-Results: i=1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a12si6786758qti.262.2017.07.04.15.05.19; Tue, 04 Jul 2017 15:05:19 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 9610760665; Tue, 4 Jul 2017 22:05:19 +0000 (UTC) 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.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW 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 C261D6074A; Tue, 4 Jul 2017 22:01:22 +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 972E160C2A; Tue, 4 Jul 2017 22:01:11 +0000 (UTC) Received: from forward5h.cmail.yandex.net (forward5h.cmail.yandex.net [87.250.230.20]) by lists.linaro.org (Postfix) with ESMTPS id C884A6071A for ; Tue, 4 Jul 2017 22:00:19 +0000 (UTC) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [77.88.29.85]) by forward5h.cmail.yandex.net (Yandex) with ESMTP id 6F526210F5 for ; Wed, 5 Jul 2017 01:00:18 +0300 (MSK) Received: from smtp2p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2p.mail.yandex.net (Yandex) with ESMTP id 4D03B1A8003E for ; Wed, 5 Jul 2017 01:00:17 +0300 (MSK) Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id b3wfOILtJj-0HPecAWW; Wed, 05 Jul 2017 01:00:17 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 5 Jul 2017 01:00:07 +0300 Message-Id: <1499205607-30786-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> References: <1499205607-30786-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 67 Subject: [lng-odp] [PATCH v1 7/7] linux-gen: shm: user can define place for shm files 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Maxim Uvarov Signed-off-by: Maxim Uvarov --- /** Email created from pull request 67 (muvarov:master_ipc_fixes) ** https://github.com/Linaro/odp/pull/67 ** Patch: https://github.com/Linaro/odp/pull/67.patch ** Base sha: ceeab69f3af67701adb524c7b9757d19cefb1110 ** Merge commit sha: 6f88e14c89b861d66bb7043b22f9b299b1f73ddf **/ platform/linux-generic/_ishm.c | 83 ++++++++++++++++++++-- platform/linux-generic/include/_ishm_internal.h | 1 + platform/linux-generic/include/odp_internal.h | 1 + platform/linux-generic/odp_init.c | 72 ++----------------- .../validation/api/shmem/shmem_common.h | 5 +- .../validation/api/shmem/shmem_linux.c | 8 ++- .../validation/api/shmem/shmem_odp1.c | 8 ++- .../validation/api/shmem/shmem_odp2.c | 4 +- 8 files changed, 102 insertions(+), 80 deletions(-) diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c index 6545bfce..cde2dbc3 100644 --- a/platform/linux-generic/_ishm.c +++ b/platform/linux-generic/_ishm.c @@ -71,6 +71,8 @@ #include #include #include +#include +#include /* * Maximum number of internal shared memory blocks. @@ -99,6 +101,7 @@ #define ISHM_FILENAME_MAXLEN (ISHM_NAME_MAXLEN + 64) #define ISHM_FILENAME_FORMAT "%s/odp-%d-ishm-%s" #define ISHM_FILENAME_NORMAL_PAGE_DIR "/dev/shm" +#define _ODP_FILES_FMT "odp-%d-" /* * when the memory is to be shared with an external entity (such as another @@ -106,7 +109,7 @@ * export file is created describing the exported memory: this defines the * location and the filename format of this description file */ -#define ISHM_EXPTNAME_FORMAT "/dev/shm/%s/odp-%d-shm-%s" +#define ISHM_EXPTNAME_FORMAT "%s/%s/odp-%d-shm-%s" /* * At worse case the virtual space gets so fragmented that there is @@ -437,7 +440,7 @@ static int create_file(int block_index, huge_flag_t huge, uint64_t len, odp_global_data.uid); else snprintf(dir, ISHM_FILENAME_MAXLEN, "%s/%s", - ISHM_FILENAME_NORMAL_PAGE_DIR, + odp_global_data.shm_dir, odp_global_data.uid); snprintf(filename, ISHM_FILENAME_MAXLEN, @@ -476,6 +479,7 @@ static int create_file(int block_index, huge_flag_t huge, uint64_t len, ISHM_FILENAME_MAXLEN - 1); snprintf(new_block->exptname, ISHM_FILENAME_MAXLEN, ISHM_EXPTNAME_FORMAT, + odp_global_data.shm_dir, odp_global_data.uid, odp_global_data.main_pid, (name && name[0]) ? name : seq_string); @@ -955,6 +959,7 @@ int _odp_ishm_find_exported(const char *remote_name, pid_t external_odp_pid, /* try to read the block description file: */ snprintf(export_filename, ISHM_FILENAME_MAXLEN, ISHM_EXPTNAME_FORMAT, + odp_global_data.shm_dir, odp_global_data.uid, external_odp_pid, remote_name); @@ -1383,22 +1388,86 @@ static int do_odp_ishm_init_local(void) return 0; } +/* remove all files staring with "odp-" from a directory "dir" */ +int _odp_ishm_cleanup_files(const char *dirpath) +{ + struct dirent *e; + DIR *dir; + char userdir[PATH_MAX]; + char prefix[PATH_MAX]; + char *fullpath; + int d_len = strlen(dirpath); + int p_len; + int f_len; + + snprintf(userdir, PATH_MAX, "%s/%s", dirpath, odp_global_data.uid); + + dir = opendir(userdir); + if (!dir) { + /* ok if the dir does not exist. no much to delete then! */ + ODP_DBG("opendir failed for %s: %s\n", + dirpath, strerror(errno)); + return 0; + } + snprintf(prefix, PATH_MAX, _ODP_FILES_FMT, odp_global_data.main_pid); + p_len = strlen(prefix); + while ((e = readdir(dir)) != NULL) { + if (strncmp(e->d_name, prefix, p_len) == 0) { + f_len = strlen(e->d_name); + fullpath = malloc(d_len + f_len + 2); + if (fullpath == NULL) { + closedir(dir); + return -1; + } + snprintf(fullpath, PATH_MAX, "%s/%s", + dirpath, e->d_name); + ODP_DBG("deleting obsolete file: %s\n", fullpath); + if (unlink(fullpath)) + ODP_ERR("unlink failed for %s: %s\n", + fullpath, strerror(errno)); + free(fullpath); + } + } + closedir(dir); + + return 0; +} + int _odp_ishm_init_global(void) { void *addr; void *spce_addr; int i; + uid_t uid; - if ((getpid() != odp_global_data.main_pid) || - (syscall(SYS_gettid) != getpid())) - ODP_ERR("odp_init_global() must be performed by the main " + odp_global_data.main_pid = getpid(); + odp_global_data.shm_dir = getenv("ODP_SHM_DIR"); + odp_global_data.shm_dir = + calloc(1, sizeof(ISHM_FILENAME_NORMAL_PAGE_DIR)); + sprintf(odp_global_data.shm_dir, "%s", ISHM_FILENAME_NORMAL_PAGE_DIR); + + ODP_DBG("ishm: using dir %s\n", odp_global_data.shm_dir); + + uid = getuid(); + snprintf(odp_global_data.uid, UID_MAXLEN, "%d", + uid); + + if ((syscall(SYS_gettid)) != odp_global_data.main_pid) { + ODP_ERR("ishm init must be performed by the main " "ODP process!\n."); + return -1; + } if (!odp_global_data.hugepage_info.default_huge_page_dir) ODP_DBG("NOTE: No support for huge pages\n"); - else + else { ODP_DBG("Huge pages mount point is: %s\n", odp_global_data.hugepage_info.default_huge_page_dir); + _odp_ishm_cleanup_files( + odp_global_data.hugepage_info.default_huge_page_dir); + } + + _odp_ishm_cleanup_files(odp_global_data.shm_dir); /* allocate space for the internal shared mem block table: */ addr = mmap(NULL, sizeof(ishm_table_t), @@ -1592,6 +1661,8 @@ int _odp_ishm_term_global(void) if (_odp_ishmphy_unbook_va()) ret |= -1; + free(odp_global_data.shm_dir); + return ret; } diff --git a/platform/linux-generic/include/_ishm_internal.h b/platform/linux-generic/include/_ishm_internal.h index c7c33077..005d6b55 100644 --- a/platform/linux-generic/include/_ishm_internal.h +++ b/platform/linux-generic/include/_ishm_internal.h @@ -44,6 +44,7 @@ int _odp_ishm_find_exported(const char *remote_name, void *_odp_ishm_address(int block_index); int _odp_ishm_info(int block_index, _odp_ishm_info_t *info); int _odp_ishm_status(const char *title); +int _odp_ishm_cleanup_files(const char *dirpath); #ifdef __cplusplus } diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 7e6811f3..dd3374b7 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -42,6 +42,7 @@ typedef struct { } hugepage_info_t; struct odp_global_data_s { + char *shm_dir; /*< directory for odp mmaped files */ pid_t main_pid; char uid[UID_MAXLEN]; odp_log_func_t log_fn; diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index f62ccec0..ab2d6fb0 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -20,70 +20,15 @@ #include #include -#define _ODP_FILES_FMT "odp-%d-" -#define _ODP_TMPDIR "/dev/shm" - struct odp_global_data_s odp_global_data; -/* remove all files staring with "odp-" from a directory "dir" */ -static int cleanup_files(const char *dirpath, int odp_pid) -{ - struct dirent *e; - DIR *dir; - char userdir[PATH_MAX]; - char prefix[PATH_MAX]; - char *fullpath; - int d_len = strlen(dirpath); - int p_len; - int f_len; - - snprintf(userdir, PATH_MAX, "%s/%s", dirpath, odp_global_data.uid); - - dir = opendir(userdir); - if (!dir) { - /* ok if the dir does not exist. no much to delete then! */ - ODP_DBG("opendir failed for %s: %s\n", - dirpath, strerror(errno)); - return 0; - } - snprintf(prefix, PATH_MAX, _ODP_FILES_FMT, odp_pid); - p_len = strlen(prefix); - while ((e = readdir(dir)) != NULL) { - if (strncmp(e->d_name, prefix, p_len) == 0) { - f_len = strlen(e->d_name); - fullpath = malloc(d_len + f_len + 2); - if (fullpath == NULL) { - closedir(dir); - return -1; - } - snprintf(fullpath, PATH_MAX, "%s/%s", - dirpath, e->d_name); - ODP_DBG("deleting obsolete file: %s\n", fullpath); - if (unlink(fullpath)) - ODP_ERR("unlink failed for %s: %s\n", - fullpath, strerror(errno)); - free(fullpath); - } - } - closedir(dir); - - return 0; -} - int odp_init_global(odp_instance_t *instance, const odp_init_t *params, const odp_platform_init_t *platform_params ODP_UNUSED) { - char *hpdir; - uid_t uid; - memset(&odp_global_data, 0, sizeof(struct odp_global_data_s)); odp_global_data.main_pid = getpid(); - uid = getuid(); - snprintf(odp_global_data.uid, UID_MAXLEN, "%d", - uid); - enum init_stage stage = NO_INIT; odp_global_data.log_fn = odp_override_log; odp_global_data.abort_fn = odp_override_abort; @@ -95,8 +40,6 @@ int odp_init_global(odp_instance_t *instance, odp_global_data.abort_fn = params->abort_fn; } - cleanup_files(_ODP_TMPDIR, odp_global_data.main_pid); - if (odp_cpumask_init_global(params)) { ODP_ERR("ODP cpumask init failed.\n"); goto init_failed; @@ -113,23 +56,20 @@ int odp_init_global(odp_instance_t *instance, ODP_ERR("ODP system_info init failed.\n"); goto init_failed; } - hpdir = odp_global_data.hugepage_info.default_huge_page_dir; - /* cleanup obsolete huge page files, if any */ - if (hpdir) - cleanup_files(hpdir, odp_global_data.main_pid); stage = SYSINFO_INIT; + if (_odp_ishm_init_global()) { + ODP_ERR("ODP ishm init failed.\n"); + goto init_failed; + } + stage = ISHM_INIT; + if (_odp_fdserver_init_global()) { ODP_ERR("ODP fdserver init failed.\n"); goto init_failed; } stage = FDSERVER_INIT; - if (_odp_ishm_init_global()) { - ODP_ERR("ODP ishm init failed.\n"); - goto init_failed; - } - stage = ISHM_INIT; if (odp_thread_init_global()) { ODP_ERR("ODP thread init failed.\n"); diff --git a/test/linux-generic/validation/api/shmem/shmem_common.h b/test/linux-generic/validation/api/shmem/shmem_common.h index 621e3431..e6c04d81 100644 --- a/test/linux-generic/validation/api/shmem/shmem_common.h +++ b/test/linux-generic/validation/api/shmem/shmem_common.h @@ -7,8 +7,9 @@ #ifndef _COMMON_TEST_SHMEM_H_ #define _COMMON_TEST_SHMEM_H_ -#define ODP_SHM_NAME "odp_linux_shared_mem" -#define FIFO_NAME_FMT "/dev/shm/%d/shmem_test_fifo-%d" +#define SHM_NAME "odp_linux_shared_mem" +#define DEFAULT_SHM_DIR "/dev/shm" +#define FIFO_NAME_FMT "/%s/%d/shmem_test_fifo-%d" #define ALIGN_SIZE (128) #define TEST_SHARE_FOO (0xf0f0f0f0) #define TEST_SHARE_BAR (0xf0f0f0f) diff --git a/test/linux-generic/validation/api/shmem/shmem_linux.c b/test/linux-generic/validation/api/shmem/shmem_linux.c index d5931447..e7e699e7 100644 --- a/test/linux-generic/validation/api/shmem/shmem_linux.c +++ b/test/linux-generic/validation/api/shmem/shmem_linux.c @@ -79,6 +79,7 @@ #include #include #include +#include #include "shmem_linux.h" #include "shmem_common.h" @@ -210,6 +211,7 @@ int main(int argc __attribute__((unused)), char *argv[]) test_shared_linux_data_t *addr; int app2_status; uid_t uid = getuid(); + char *shm_dir = getenv("ODP_SHM_DIR"); /* odp_app1 is in the same directory as this file: */ strncpy(prg_name, argv[0], PATH_MAX - 1); @@ -228,7 +230,9 @@ int main(int argc __attribute__((unused)), char *argv[]) /* wait max 30 sec for the fifo to be created by the ODP side. * Just die if time expire as there is no fifo to communicate * through... */ - sprintf(fifo_name, FIFO_NAME_FMT, uid, odp_app1); + sprintf(fifo_name, FIFO_NAME_FMT, + shm_dir ? shm_dir : DEFAULT_SHM_DIR, + uid, odp_app1); for (nb_sec = 0; nb_sec < MAX_FIFO_WAIT; nb_sec++) { fifo_fd = open(fifo_name, O_WRONLY); if (fifo_fd >= 0) @@ -244,7 +248,7 @@ int main(int argc __attribute__((unused)), char *argv[]) * check to see if linux can see the created shared memory: */ /* read the shared memory attributes (includes the shm filename): */ - if (read_shmem_attribues(odp_app1, ODP_SHM_NAME, + if (read_shmem_attribues(odp_app1, SHM_NAME, shm_filename, &len, &flags, &user_len, &user_flags, &align) != 0) test_failure(fifo_name, fifo_fd, odp_app1); diff --git a/test/linux-generic/validation/api/shmem/shmem_odp1.c b/test/linux-generic/validation/api/shmem/shmem_odp1.c index c402365a..26abc94b 100644 --- a/test/linux-generic/validation/api/shmem/shmem_odp1.c +++ b/test/linux-generic/validation/api/shmem/shmem_odp1.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "shmem_odp1.h" @@ -26,9 +27,10 @@ void shmem_test_odp_shm_proc(void) odp_shm_t shm; test_shared_data_t *test_shared_data; char test_result; + char *shm_dir = getenv("ODP_SHM_DIR"); /* reminder: ODP_SHM_PROC => export to linux, ODP_SHM_EXPORT=>to odp */ - shm = odp_shm_reserve(ODP_SHM_NAME, + shm = odp_shm_reserve(SHM_NAME, sizeof(test_shared_data_t), ALIGN_SIZE, ODP_SHM_PROC | ODP_SHM_EXPORT); CU_ASSERT_FATAL(ODP_SHM_INVALID != shm); @@ -41,7 +43,9 @@ void shmem_test_odp_shm_proc(void) /* open the fifo: this will indicate to linux process that it can * start the shmem lookups and check if it sees the data */ - sprintf(fifo_name, FIFO_NAME_FMT, getuid(), getpid()); + sprintf(fifo_name, FIFO_NAME_FMT, + shm_dir ? shm_dir : DEFAULT_SHM_DIR, + getuid(), getpid()); CU_ASSERT_FATAL(mkfifo(fifo_name, 0666) == 0); /* read from the fifo: the linux process result: */ diff --git a/test/linux-generic/validation/api/shmem/shmem_odp2.c b/test/linux-generic/validation/api/shmem/shmem_odp2.c index 7d8c682b..2a4b67d7 100644 --- a/test/linux-generic/validation/api/shmem/shmem_odp2.c +++ b/test/linux-generic/validation/api/shmem/shmem_odp2.c @@ -53,8 +53,8 @@ int main(int argc, char *argv[]) odp1 = (odp_instance_t)atoi(argv[1]); printf("shmem_odp2: trying to grab %s from pid %d\n", - ODP_SHM_NAME, (int)odp1); - shm = odp_shm_import(ODP_SHM_NAME, odp1, ODP_SHM_NAME); + SHM_NAME, (int)odp1); + shm = odp_shm_import(SHM_NAME, odp1, SHM_NAME); if (shm == ODP_SHM_INVALID) { fprintf(stderr, "error: odp_shm_lookup_external failed.\n"); return 1;