From patchwork Wed Jul 26 20:00:21 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: 108797 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1207786qge; Wed, 26 Jul 2017 13:02:30 -0700 (PDT) X-Received: by 10.55.48.18 with SMTP id w18mr3044823qkw.3.1501099350528; Wed, 26 Jul 2017 13:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501099350; cv=none; d=google.com; s=arc-20160816; b=PZrCuW3bUvo5omOJ5HqgBRn9lJwYieIwH1cAtp0FBaJgKeShDTmp4+Emd8XuAjr4RV F9aO+mXWFKA77v5EUYi9KRZiOS/6ipEf9oP7K+q0uqzleOkgX+BvQeTG+/yqkjw+CqaQ +A+fmRFNZZNHP4l+oaVnNBJOdq9Ht7LkDW5XC42v4bxBShUzv4REn++mpHm6Um+V9Ap3 Wb78CvXHxQPa5Kc7UPeUYnTUCpyUzUfKAzhvftLYMY/Q4nnnRpgdL/kreXWqh+g44NBN PPfw1arxNID9iyRmLLvjZfmQQWkUK37AAR0nEd+pPkCtVS/24WNWF3VlCcKIeMOky9LW D+xA== 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=hMLo9RUTPq71JC73XPBeUvwC+R24ZqCjU/NsdYbDLLo=; b=RsjpSKS1Z5O6Cq5cWRUht0mRr9bvy9KSVVN+eOTVW+s2bRcplfTfGy/NzKx4rzYNDt ML6vQhSfLXhLgcyeHPuTprkq8psQk6rybbom9x/TghJP6HXGhK1PTKOlb9Y9IFJdFIJt CkRtu8jeoWZp/OfSofzDpU51cczEWEjNP9Me78gfOIFXYkQqVghvVxuS4z7ATAlxZg4x WhvhRWSSp/DBtuAIPUl///oce86c8kG3jPQfAGIb+wD8st+nLhpN947Fq60AUNtJ6GIj iAVXI6dBC3PxYf5VXz1QlYq5CgjyWq/6JsQYjgB9Twhx+x8xkbz/Y10/JlzfToyVl+Da Bhgg== 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 e5si4918613qtd.124.2017.07.26.13.02.30; Wed, 26 Jul 2017 13:02:30 -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 27EF363E50; Wed, 26 Jul 2017 20:02:29 +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,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 7FB5264464; Wed, 26 Jul 2017 20: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 C131760AFA; Wed, 26 Jul 2017 20:01:02 +0000 (UTC) Received: from forward2p.cmail.yandex.net (forward2p.cmail.yandex.net [77.88.31.17]) by lists.linaro.org (Postfix) with ESMTPS id BB11960718 for ; Wed, 26 Jul 2017 20:00:40 +0000 (UTC) Received: from smtp2m.mail.yandex.net (smtp2m.mail.yandex.net [77.88.61.129]) by forward2p.cmail.yandex.net (Yandex) with ESMTP id 8E064213ED for ; Wed, 26 Jul 2017 23:00:38 +0300 (MSK) Received: from smtp2m.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2m.mail.yandex.net (Yandex) with ESMTP id 6E92A2300480 for ; Wed, 26 Jul 2017 23:00:37 +0300 (MSK) Received: by smtp2m.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id cM6u6gtpFh-0bZuXDu3; Wed, 26 Jul 2017 23:00:37 +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, 26 Jul 2017 23:00:21 +0300 Message-Id: <1501099222-4536-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501099222-4536-1-git-send-email-odpbot@yandex.ru> References: <1501099222-4536-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 88 Subject: [lng-odp] [PATCH v1 1/2] linux-gen: fdserver: fix fdserver work if ODP_SHM_DIR is exported 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 If ODP_SHM_DIR=/tmp is exported shmem test failed due to searching in wrong path. Signed-off-by: Maxim Uvarov --- /** Email created from pull request 88 (muvarov:master_fix_odp_shm_dir) ** https://github.com/Linaro/odp/pull/88 ** Patch: https://github.com/Linaro/odp/pull/88.patch ** Base sha: f4f7679d16917d9a7c1b2220e351fd27733ee96b ** Merge commit sha: 01a9f1c75c28adf8487b47e29bcd93d870f82ec6 **/ platform/linux-generic/_fdserver.c | 12 ++++++++--- platform/linux-generic/include/odp_internal.h | 2 +- platform/linux-generic/odp_init.c | 13 ++++++------ .../validation/api/shmem/shmem_common.h | 2 +- .../validation/api/shmem/shmem_linux.c | 23 ++++++++++++++++------ .../validation/api/shmem/shmem_odp1.c | 2 ++ .../validation/api/shmem/shmem_odp2.c | 1 + 7 files changed, 37 insertions(+), 18 deletions(-) diff --git a/platform/linux-generic/_fdserver.c b/platform/linux-generic/_fdserver.c index 7ed5e7a6..4f74c614 100644 --- a/platform/linux-generic/_fdserver.c +++ b/platform/linux-generic/_fdserver.c @@ -59,8 +59,9 @@ #include #define FDSERVER_SOCKPATH_MAXLEN 255 -#define FDSERVER_SOCK_FORMAT "/dev/shm/%s/odp-%d-fdserver" -#define FDSERVER_SOCKDIR_FORMAT "/dev/shm/%s" +#define FDSERVER_SOCK_FORMAT "%s/%s/odp-%d-fdserver" +#define FDSERVER_SOCKDIR_FORMAT "%s/%s" +#define FDSERVER_DEFAULT_DIR "/dev/shm" #define FDSERVER_BACKLOG 5 #ifndef MAP_ANONYMOUS @@ -241,6 +242,7 @@ static int get_socket(void) /* construct the named socket path: */ snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCK_FORMAT, + odp_global_data.shm_dir, odp_global_data.uid, odp_global_data.main_pid); @@ -585,12 +587,14 @@ int _odp_fdserver_init_global(void) odp_spinlock_init(client_lock); snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCKDIR_FORMAT, + odp_global_data.shm_dir, odp_global_data.uid); mkdir(sockpath, 0744); /* construct the server named socket path: */ snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCK_FORMAT, + odp_global_data.shm_dir, odp_global_data.uid, odp_global_data.main_pid); @@ -673,6 +677,7 @@ int _odp_fdserver_term_global(void) /* construct the server named socket path: */ snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCK_FORMAT, + odp_global_data.shm_dir, odp_global_data.uid, odp_global_data.main_pid); @@ -681,8 +686,9 @@ int _odp_fdserver_term_global(void) /* delete shm files directory */ snprintf(sockpath, FDSERVER_SOCKPATH_MAXLEN, FDSERVER_SOCKDIR_FORMAT, + odp_global_data.shm_dir, odp_global_data.uid); - unlink(sockpath); + rmdir(sockpath); return 0; } diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index ec17b199..355e25f7 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -60,8 +60,8 @@ enum init_stage { CPUMASK_INIT, TIME_INIT, SYSINFO_INIT, - FDSERVER_INIT, ISHM_INIT, + FDSERVER_INIT, THREAD_INIT, POOL_INIT, QUEUE_INIT, diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 35a285ea..7d029950 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -70,7 +70,6 @@ int odp_init_global(odp_instance_t *instance, } stage = FDSERVER_INIT; - if (odp_thread_init_global()) { ODP_ERR("ODP thread init failed.\n"); goto init_failed; @@ -224,16 +223,16 @@ int _odp_term_global(enum init_stage stage) } /* Fall through */ - case ISHM_INIT: - if (_odp_ishm_term_global()) { - ODP_ERR("ODP ishm term failed.\n"); + case FDSERVER_INIT: + if (_odp_fdserver_term_global()) { + ODP_ERR("ODP fdserver term failed.\n"); rc = -1; } /* Fall through */ - case FDSERVER_INIT: - if (_odp_fdserver_term_global()) { - ODP_ERR("ODP fdserver term failed.\n"); + case ISHM_INIT: + if (_odp_ishm_term_global()) { + ODP_ERR("ODP ishm term failed.\n"); rc = -1; } /* Fall through */ diff --git a/test/linux-generic/validation/api/shmem/shmem_common.h b/test/linux-generic/validation/api/shmem/shmem_common.h index e6c04d81..0a90297f 100644 --- a/test/linux-generic/validation/api/shmem/shmem_common.h +++ b/test/linux-generic/validation/api/shmem/shmem_common.h @@ -9,7 +9,7 @@ #define SHM_NAME "odp_linux_shared_mem" #define DEFAULT_SHM_DIR "/dev/shm" -#define FIFO_NAME_FMT "/%s/%d/shmem_test_fifo-%d" +#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 e7e699e7..fe11a7db 100644 --- a/test/linux-generic/validation/api/shmem/shmem_linux.c +++ b/test/linux-generic/validation/api/shmem/shmem_linux.c @@ -86,7 +86,8 @@ #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 */ /* odp--shm- */ -#define DEVNAME_FMT "/dev/shm/%d/odp-%" PRIu64 "-shm-%s" +#define DEVNAME_DEFAULT_DIR "/dev/shm" +#define DEVNAME_FMT "%s/%d/odp-%" PRIu64 "-shm-%s" #define MAX_FIFO_WAIT 30 /* Max time waiting for the fifo (sec) */ /* @@ -111,8 +112,11 @@ static int read_shmem_attribues(uint64_t ext_odp_pid, const char *blockname, { char shm_attr_filename[PATH_MAX]; FILE *export_file; + char *shm_dir = getenv("ODP_SHM_DIR"); - sprintf(shm_attr_filename, DEVNAME_FMT, getuid(), + sprintf(shm_attr_filename, DEVNAME_FMT, + shm_dir ? shm_dir : DEVNAME_DEFAULT_DIR, + getuid(), ext_odp_pid, blockname); /* O_CREAT flag not given => failure if shm_attr_filename does not @@ -250,16 +254,20 @@ int main(int argc __attribute__((unused)), char *argv[]) /* read the shared memory attributes (includes the shm filename): */ if (read_shmem_attribues(odp_app1, SHM_NAME, shm_filename, &len, &flags, - &user_len, &user_flags, &align) != 0) + &user_len, &user_flags, &align) != 0) { + printf("erorr read_shmem_attribues\n"); test_failure(fifo_name, fifo_fd, odp_app1); + } /* 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, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - if (shm_fd == -1) + if (shm_fd == -1) { + fprintf(stderr, "unable to open %s\n", shm_filename); test_failure(fifo_name, fifo_fd, odp_app1); /* no return */ + } /* linux ODP guarantees page size alignement. Larger alignment may * fail as 2 different processes will have fully unrelated @@ -269,13 +277,16 @@ int main(int argc __attribute__((unused)), char *argv[]) addr = mmap(NULL, size, PROT_READ, MAP_SHARED, shm_fd, 0); if (addr == MAP_FAILED) { - printf("shmem_linux: map failed!\n"); + fprintf(stderr, "shmem_linux: map failed!\n"); test_failure(fifo_name, fifo_fd, odp_app1); } /* check that we see what the ODP application wrote in the memory */ - if ((addr->foo != TEST_SHARE_FOO) || (addr->bar != TEST_SHARE_BAR)) + if ((addr->foo != TEST_SHARE_FOO) || (addr->bar != TEST_SHARE_BAR)) { + fprintf(stderr, "ERROR: addr->foo %x addr->bar %x\n", + addr->foo, addr->bar); test_failure(fifo_name, fifo_fd, odp_app1); /* no return */ + } /* odp_app2 is in the same directory as this file: */ strncpy(prg_name, argv[0], PATH_MAX - 1); diff --git a/test/linux-generic/validation/api/shmem/shmem_odp1.c b/test/linux-generic/validation/api/shmem/shmem_odp1.c index 26abc94b..0ced4554 100644 --- a/test/linux-generic/validation/api/shmem/shmem_odp1.c +++ b/test/linux-generic/validation/api/shmem/shmem_odp1.c @@ -29,6 +29,7 @@ void shmem_test_odp_shm_proc(void) char test_result; char *shm_dir = getenv("ODP_SHM_DIR"); + printf("start with pid %d\n", getpid()); /* reminder: ODP_SHM_PROC => export to linux, ODP_SHM_EXPORT=>to odp */ shm = odp_shm_reserve(SHM_NAME, sizeof(test_shared_data_t), @@ -55,6 +56,7 @@ void shmem_test_odp_shm_proc(void) printf("shmem_odp1: reading fifo: %s\n", fifo_name); CU_ASSERT(read(fd, &test_result, sizeof(char)) == 1); + printf("shmem_odp1: read fifo: %d\n", test_result); printf("shmem_odp1: closing fifo: %s\n", fifo_name); close(fd); CU_ASSERT_FATAL(test_result == TEST_SUCCESS); diff --git a/test/linux-generic/validation/api/shmem/shmem_odp2.c b/test/linux-generic/validation/api/shmem/shmem_odp2.c index 2a4b67d7..0144407b 100644 --- a/test/linux-generic/validation/api/shmem/shmem_odp2.c +++ b/test/linux-generic/validation/api/shmem/shmem_odp2.c @@ -99,5 +99,6 @@ int main(int argc, char *argv[]) return 1; } + printf("%s SUCSESS\n", __FILE__); return 0; }