From patchwork Thu Feb 1 16:00:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 126545 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1838923ljc; Thu, 1 Feb 2018 08:02:18 -0800 (PST) X-Google-Smtp-Source: AH8x225JEombVWvrLUm6mIJEyNDWjO1d0XGiwhqMFkACrUYDrr0L+gh8TW+K9FsvCSBL/F8IRt4Y X-Received: by 10.55.170.150 with SMTP id t144mr19971730qke.339.1517500937979; Thu, 01 Feb 2018 08:02:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517500937; cv=none; d=google.com; s=arc-20160816; b=xs3i4oKLz71qTBJZeDrNBcaVNme12b0wp8IA7KLIMgX84fpm4Nf/1frG1joVqZZcKX whkzxvUwnxodlxogn3C00LYiReegPLT6lDILkURJm+VaZ+0u1Rd6JyMMccGXheaCT+3k WZwJ/DzF1eUNRvO6G3M+6qmmklU12J+i4q0n4dtoGE/LKgpVv58fxUzNxP2Yn01AlY6m 6cdmp9h9dMdamML3PhoiTd8C7DfDzuU20mQDKolmdSnxKwuRAnrhWKnn571q9SZFeZSf cnNrZd1Zw5nCHXpFdsK5fD5T+MHycRmahVH9N0MeXDj3bxhVSJbxP3Go+QU4gHwAgzOR Ec+w== 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=ykhF7JW4UiEcXIJCD3hrNUUTdndf3BoPfzKbKhl4daI=; b=az/1P/6PcD1RIKYHtMybMP8C2l59R4FzwrOx9Gggj5y/QV6KiaCPDPnYmpBE2Ksw+P czP7pEepzH4pjs29i4arwpSXk/IvXw195U3T8oVV7yh8DNNMyuDbJEcXeRU+B615z1j4 gwNDOVAobtS6th2cN60KY4eCfYt9qT/APYURvhpD7yEPS6oPiAIcvccBerr5WjBCLuEX hcIs0+VJ4adriEMDEXblN9Lmj4SSomU9gkwSDmKhywtKQSS5bktdWeBcypkjDZkXjhtT n3FzxTodnfkbsPN4eUDIVA83mm+gDdzRIy4dESNAMvSM7R5bjPRYpErX+UqAFCnWfKLd qpEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id d6si1141086qkj.34.2018.02.01.08.02.17; Thu, 01 Feb 2018 08:02:17 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 91109617D0; Thu, 1 Feb 2018 16:02:17 +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, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 6B263617AF; Thu, 1 Feb 2018 16:00:33 +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 EB156617A4; Thu, 1 Feb 2018 16:00:24 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id EB3C261522 for ; Thu, 1 Feb 2018 16:00:14 +0000 (UTC) Received: from mxback5g.mail.yandex.net (mxback5g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:166]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 784C52D829DB for ; Thu, 1 Feb 2018 19:00:13 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback5g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id TrHdMJEbDA-0DoS6Kl2; Thu, 01 Feb 2018 19:00:13 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id IQBTIJTeEr-0Cd4jhZQ; Thu, 01 Feb 2018 19:00:12 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 1 Feb 2018 19:00:09 +0300 Message-Id: <1517500809-452-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517500809-452-1-git-send-email-odpbot@yandex.ru> References: <1517500809-452-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 446 Subject: [lng-odp] [PATCH API-NEXT v1 3/3] linux-gen: shm: use global init max memory 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: Petri Savolainen Use global init parameter to allow application to use more than 512 MB of shared memory. Signed-off-by: Petri Savolainen --- /** Email created from pull request 446 (psavol:next-global-init-shm-size-2) ** https://github.com/Linaro/odp/pull/446 ** Patch: https://github.com/Linaro/odp/pull/446.patch ** Base sha: 5718327018debbb02aacb464493504c95fbe57a3 ** Merge commit sha: 5beffee2f03442764ec79a301dd6608c8e82c8b4 **/ platform/linux-generic/_ishm.c | 16 ++++++++++++---- platform/linux-generic/include/odp_internal.h | 4 +++- platform/linux-generic/odp_init.c | 2 +- platform/linux-generic/odp_shared_memory.c | 3 ++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c index 81d77edc0..ab112acea 100644 --- a/platform/linux-generic/_ishm.c +++ b/platform/linux-generic/_ishm.c @@ -258,7 +258,7 @@ static void *alloc_fragment(uintptr_t size, int block_index, intptr_t align, ishm_fragment_t *rem_fragmnt; uintptr_t border;/* possible start of new fragment (next alignement) */ intptr_t left; /* room remaining after, if the segment is allocated */ - uintptr_t remainder = ODP_CONFIG_ISHM_VA_PREALLOC_SZ; + uintptr_t remainder = odp_global_data.shm_max_memory; /* * search for the best bit, i.e. search for the unallocated fragment @@ -1436,7 +1436,7 @@ int _odp_ishm_cleanup_files(const char *dirpath) return 0; } -int _odp_ishm_init_global(void) +int _odp_ishm_init_global(const odp_init_t *init) { void *addr; void *spce_addr; @@ -1444,7 +1444,15 @@ int _odp_ishm_init_global(void) uid_t uid; char *hp_dir = odp_global_data.hugepage_info.default_huge_page_dir; uint64_t align; + uint64_t max_memory = ODP_CONFIG_ISHM_VA_PREALLOC_SZ; + uint64_t internal = ODP_CONFIG_ISHM_VA_PREALLOC_SZ / 8; + /* user requested memory size + some extra for internal use */ + if (init && init->shm.max_memory) + max_memory = init->shm.max_memory + internal; + + odp_global_data.shm_max_memory = max_memory; + odp_global_data.shm_max_size = max_memory - internal; odp_global_data.main_pid = getpid(); odp_global_data.shm_dir = getenv("ODP_SHM_DIR"); if (odp_global_data.shm_dir) { @@ -1507,7 +1515,7 @@ int _odp_ishm_init_global(void) *reserve the address space for _ODP_ISHM_SINGLE_VA reserved blocks, * only address space! */ - spce_addr = _odp_ishmphy_book_va(ODP_CONFIG_ISHM_VA_PREALLOC_SZ, align); + spce_addr = _odp_ishmphy_book_va(max_memory, align); if (!spce_addr) { ODP_ERR("unable to reserve virtual space\n."); goto init_glob_err3; @@ -1516,7 +1524,7 @@ int _odp_ishm_init_global(void) /* use the first fragment descriptor to describe to whole VA space: */ ishm_ftbl->fragment[0].block_index = -1; ishm_ftbl->fragment[0].start = spce_addr; - ishm_ftbl->fragment[0].len = ODP_CONFIG_ISHM_VA_PREALLOC_SZ; + ishm_ftbl->fragment[0].len = max_memory; ishm_ftbl->fragment[0].prev = NULL; ishm_ftbl->fragment[0].next = NULL; ishm_ftbl->used_fragmnts = &ishm_ftbl->fragment[0]; diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index a21e93c8b..444e1163b 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -44,6 +44,8 @@ typedef struct { struct odp_global_data_s { char *shm_dir; /*< directory for odp mmaped files */ int shm_dir_from_env; /*< overload default with env */ + uint64_t shm_max_memory; + uint64_t shm_max_size; pid_t main_pid; char uid[UID_MAXLEN]; odp_log_func_t log_fn; @@ -129,7 +131,7 @@ int _odp_int_name_tbl_term_global(void); int _odp_fdserver_init_global(void); int _odp_fdserver_term_global(void); -int _odp_ishm_init_global(void); +int _odp_ishm_init_global(const odp_init_t *init); int _odp_ishm_init_local(void); int _odp_ishm_term_global(void); int _odp_ishm_term_local(void); diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index be75a530b..a2d9d52ff 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -66,7 +66,7 @@ int odp_init_global(odp_instance_t *instance, } stage = SYSINFO_INIT; - if (_odp_ishm_init_global()) { + if (_odp_ishm_init_global(params)) { ODP_ERR("ODP ishm init failed.\n"); goto init_failed; } diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index c322c7eb0..c9b04dfdb 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -12,6 +12,7 @@ #include #include #include <_ishm_internal.h> +#include #include ODP_STATIC_ASSERT(ODP_CONFIG_SHM_BLOCKS >= ODP_CONFIG_POOLS, @@ -47,7 +48,7 @@ int odp_shm_capability(odp_shm_capability_t *capa) memset(capa, 0, sizeof(odp_shm_capability_t)); capa->max_blocks = ODP_CONFIG_SHM_BLOCKS; - capa->max_size = 0; + capa->max_size = odp_global_data.shm_max_size; capa->max_align = 0; return 0;