From patchwork Thu Jul 27 11: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: 108827 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1893086qge; Thu, 27 Jul 2017 04:01:10 -0700 (PDT) X-Received: by 10.237.35.67 with SMTP id i3mr218824qtc.212.1501153270834; Thu, 27 Jul 2017 04:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501153270; cv=none; d=google.com; s=arc-20160816; b=Jr3xIo4RoZSrctS2+Dr7IAY4Zpr37G7HVTJpKhhbyYQR2nryyTbto0cSqwMvDKduTf CqBVsgCePMSpHPLO3zYHbbDzU0qVqj5MSe5kKJHbfdpXC1UPxGljACxHf2i+oPRuWOwS Vfg+/d9kMFFm9f7+xU2KlSvyP7ss5JHFd3XQPFS6acd88sQ4OfjuU9RCBw3JsGLmDS9w 5L1YWHcUDclZmhiNkUa21/nI8vGFTIxUefYOuesKspzwWWhL/jQjNVvZSt8UUAVoZqPh JP2CK1eMa8Fh/V3qcBSMcBigDorhVH9JeHw5SfUTYEmn1kdf01BjBG21nIIvginXSd+Y aI5A== 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=ff/Iw2H0h69GYDqauZliszYnpdEnM2o/DYpnIayd99o=; b=bbHjpNIuWYlohY7U5U/D8SPuZu2IIIJq0YiLdIHDBCPj4n3LMlgu/E5UQb25GM0Siz TV+n9rHXdY15wD0/+r/d+Gx8j6PP/eplzptDM6t8IkGSw0rZhwFZsEIbk6rlpssEYK+u Wv6TSwwpnI3vXfWzKlrPDCXHIfVdThAI0cH7hhR2jOe7w30uqn0IrZ8dQ8jnwBtPTdE9 uv6z+9ic9dsYn0u00P56Wtm0FiB0+zmb1/l+hbR02PKL+ZbyyLytrLFeUbSsTZWMac20 3eBV4WnACVyOgbJ6mZrQV+8NJYf8vBgbXSeQWSDe9xKYaaC6fMUM9AxH0VgyKYV7trra Ejxw== 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 5si14962057qkk.420.2017.07.27.04.01.10; Thu, 27 Jul 2017 04:01:10 -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 6D5EC65BBD; Thu, 27 Jul 2017 11:01:10 +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 E2BD9608D3; Thu, 27 Jul 2017 11:00:39 +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 ACDE9658CC; Thu, 27 Jul 2017 11:00:29 +0000 (UTC) Received: from forward1j.cmail.yandex.net (forward1j.cmail.yandex.net [5.255.227.19]) by lists.linaro.org (Postfix) with ESMTPS id C6B59644DD for ; Thu, 27 Jul 2017 11:00:27 +0000 (UTC) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::28]) by forward1j.cmail.yandex.net (Yandex) with ESMTP id 68F6820D9D for ; Thu, 27 Jul 2017 14:00:26 +0300 (MSK) Received: from smtp4o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4o.mail.yandex.net (Yandex) with ESMTP id E4C466C00DCF for ; Thu, 27 Jul 2017 14:00:25 +0300 (MSK) Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id iHb3ZfZbSP-0OFexuQr; Thu, 27 Jul 2017 14:00:24 +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: Thu, 27 Jul 2017 14:00:05 +0300 Message-Id: <1501153206-9210-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501153206-9210-1-git-send-email-odpbot@yandex.ru> References: <1501153206-9210-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 88 Subject: [lng-odp] [PATCH v2 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: a6955dcd7f0fe9643a901a2bc4ed4c9af8f92ab8 **/ 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; }