From patchwork Thu Apr 23 17:47:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 47469 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 26A2520553 for ; Thu, 23 Apr 2015 17:48:17 +0000 (UTC) Received: by wicmx19 with SMTP id mx19sf21413373wic.3 for ; Thu, 23 Apr 2015 10:48:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=KjvM3ADR6ljfSNSDA7h8qwf9ikbKtTn7VdXRuHi7Qho=; b=aCfBNs0CizkqliOHTAfQYZwyTsxLoWjRvBWIvA7jSdgAjXhJUArtrf5NeVpXTHRJcA tsfsp5G4u63DmXKewZy7zxqsoP4oo3qoub6LImtFRuUX7/IAdWMKNMwuQyxp4Hua6nfH Kdz1RaEBTWDx8/3Ru6Sg3Y7Drm+j/RxVooCpJUgUUDwwPVUfTdtHP7Y/VuLDnYJ5jdqU rFrpZGSsFjbjdeTtw9V9+Ggkof/xJTp3b4c9PVW4lmUQrrC3tVnU56CIj9yRuHWVP1QV QSZMH3EICfMmQZP33QWRnaxVUuNlKG4+RUCqJSdbsk/KZekJJmkw4Svfi6oHZIjKVCVc caEQ== X-Gm-Message-State: ALoCoQlvRjHkueD9PmaajFfTfsK0EIXxfQpFbOofVGdjPsUnEt60AxLwOEBlWY+F+J3jwk00ixUB X-Received: by 10.152.88.73 with SMTP id be9mr1976234lab.2.1429811296404; Thu, 23 Apr 2015 10:48:16 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.104 with SMTP id j8ls322439laj.106.gmail; Thu, 23 Apr 2015 10:48:16 -0700 (PDT) X-Received: by 10.112.157.164 with SMTP id wn4mr3396876lbb.100.1429811296255; Thu, 23 Apr 2015 10:48:16 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id e9si6430087laa.104.2015.04.23.10.48.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 10:48:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbbuc2 with SMTP id uc2so18902847lbb.2 for ; Thu, 23 Apr 2015 10:48:16 -0700 (PDT) X-Received: by 10.152.9.66 with SMTP id x2mr3449832laa.36.1429811296155; Thu, 23 Apr 2015 10:48:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp718190lbt; Thu, 23 Apr 2015 10:48:15 -0700 (PDT) X-Received: by 10.55.26.29 with SMTP id a29mr7555530qka.0.1429811294929; Thu, 23 Apr 2015 10:48:14 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 66si8770837qgt.0.2015.04.23.10.48.13; Thu, 23 Apr 2015 10:48:14 -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; Received: by lists.linaro.org (Postfix, from userid 109) id 3DED361FE2; Thu, 23 Apr 2015 17:48:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id D71AF61FE5; Thu, 23 Apr 2015 17:47:43 +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 7803561FE7; Thu, 23 Apr 2015 17:47:39 +0000 (UTC) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com [209.85.215.44]) by lists.linaro.org (Postfix) with ESMTPS id BDE7561ECF for ; Thu, 23 Apr 2015 17:47:20 +0000 (UTC) Received: by lagv1 with SMTP id v1so18200322lag.3 for ; Thu, 23 Apr 2015 10:47:19 -0700 (PDT) X-Received: by 10.112.148.101 with SMTP id tr5mr1486566lbb.0.1429811239699; Thu, 23 Apr 2015 10:47:19 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-163-193.pppoe.mtu-net.ru. [91.76.163.193]) by mx.google.com with ESMTPSA id k2sm2010574lag.9.2015.04.23.10.47.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Apr 2015 10:47:18 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 23 Apr 2015 20:47:00 +0300 Message-Id: <1429811225-10239-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429811225-10239-1-git-send-email-maxim.uvarov@linaro.org> References: <1429811225-10239-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 2/7] api: ipc: shared memory add no create flag X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Flag is needed to map process one shm block to process two. Signed-off-by: Maxim Uvarov --- include/odp/api/shared_memory.h | 1 + platform/linux-generic/odp_shared_memory.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/odp/api/shared_memory.h b/include/odp/api/shared_memory.h index 5d851ce..63b04d0 100644 --- a/include/odp/api/shared_memory.h +++ b/include/odp/api/shared_memory.h @@ -49,6 +49,7 @@ extern "C" { /* Share level */ #define ODP_SHM_SW_ONLY 0x1 /**< Application SW only, no HW access */ #define ODP_SHM_PROC 0x2 /**< Share with external processes */ +#define ODP_SHM_PROC_NOCREAT 0x4 /** * Shared memory block info diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index ab48dda..549f497 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -189,7 +189,7 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, int fd = -1; int map_flag = MAP_SHARED; /* If already exists: O_EXCL: error, O_TRUNC: truncate to zero */ - int oflag = O_RDWR | O_CREAT | O_TRUNC; + int oflag = O_RDWR; uint64_t alloc_size; uint64_t page_sz, huge_sz; #ifdef MAP_HUGETLB @@ -207,7 +207,12 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, alloc_hp_size = (size + align + (huge_sz - 1)) & (-huge_sz); #endif - if (flags & ODP_SHM_PROC) { + if (flags & ODP_SHM_PROC) + oflag |= O_CREAT | O_TRUNC; + + if (flags & (ODP_SHM_PROC | ODP_SHM_PROC_NOCREAT)) { + need_huge_page = 0; + /* Creates a file to /dev/shm */ fd = shm_open(name, oflag, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);