From patchwork Fri Feb 2 10:00:10 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: 126623 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp484960ljc; Fri, 2 Feb 2018 02:02:54 -0800 (PST) X-Google-Smtp-Source: AH8x227Ov9cHXJUNu7SBlgtLwPF8QO1J1mgpXLvnzKOvG6T/9US64EUmA9k+MvAeliqZozzEmzBb X-Received: by 10.55.170.150 with SMTP id t144mr24065077qke.339.1517565774579; Fri, 02 Feb 2018 02:02:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517565774; cv=none; d=google.com; s=arc-20160816; b=Mkn8TrqzMF3yPj4+s6BNIfvYpKCdO6uNq9pba+ldCx+JyvOx2G1k9lUfQ4VxgovDHI WM2Rwa5jmky++uVqSDgo0AOBEVoBerpQmO7gJ/69mKKeVmi06SayQjxRC82sBEjge/VZ 7NlS9kJ3Ox4/cBkvCtP/qO0U5QCDtS96coSOhvvgCk2G0vBYNzFO1y+hKiD/Rq+LryEL +vr2geOb3vI9fis31g1nHjtK6cH2owEf3vE94apZF/EJJ5yMzzgCg6xsXNTQCRIDatsp y130m7x1YuRkCoLfG8GdFnFCo+aiOcjj2BdXh4Mk8nsW1DTq3zg3P/Gh6JFsdUdRZuyN zK+g== 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=MMCS9TlrIoXP7xXY7N8n0rvkrZkQPW/lSdSP2hxlcFc=; b=jxRPUWPjToipzP1qGqxQK3sNWXntwWjcv/LKar/U35mfZqoTWrXIe5NjUN3KWjCIo6 h7KjiqUcFr1d7YGQpWhIN4zpZS7UED/ntPb5WUTjv30f2BTdGECfc6DVJULZSP8EgFIZ f0LOIS4QsNA+INEh1jWgKkxIJEa9h73pQS30MzhWG/7jkiK9W2Y+iCMCtjph301NVV+k 3RTNfYiYLq9YYgXP4Hyi6flOWaPJFfOGi4lG2Swk2oX5a1oQ2NeoFs0VWUWt2xJN7SSJ ZJ82Nevxo3t0jawMZtxv/9AUyrGsiP+Zzc9TrbVxc9u/JQFy9TtJKm8ttiD0vsga3mGh t4kQ== 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 j68si1844974qka.214.2018.02.02.02.02.54; Fri, 02 Feb 2018 02:02:54 -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 40E40617CB; Fri, 2 Feb 2018 10:02:54 +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 64B2D617A6; Fri, 2 Feb 2018 10:00:37 +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 2481C617A2; Fri, 2 Feb 2018 10:00:28 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 2F069607C9 for ; Fri, 2 Feb 2018 10:00:16 +0000 (UTC) Received: from mxback7j.mail.yandex.net (mxback7j.mail.yandex.net [IPv6:2a02:6b8:0:1619::110]) by forward103j.mail.yandex.net (Yandex) with ESMTP id C501334C3E78 for ; Fri, 2 Feb 2018 13:00:13 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback7j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 9g1LSSIZdP-0DJS0nnE; Fri, 02 Feb 2018 13:00:13 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id opjCzdDZJW-0DjqdphH; Fri, 02 Feb 2018 13:00:13 +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: Fri, 2 Feb 2018 13:00:10 +0300 Message-Id: <1517565612-17887-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517565612-17887-1-git-send-email-odpbot@yandex.ru> References: <1517565612-17887-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 446 Subject: [lng-odp] [PATCH API-NEXT v2 1/3] validation: shm: test capa and maximum reservation 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 Added test which uses capability API, and tries to reserve and use maximum sized block. 100 MB shm memory is assumed to be available to ODP validation tests. 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: 3ceb1d8923dfe4b778ca652825396e422766c012 **/ test/validation/api/shmem/shmem.c | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/test/validation/api/shmem/shmem.c b/test/validation/api/shmem/shmem.c index bda07011c..74eaa32d5 100644 --- a/test/validation/api/shmem/shmem.c +++ b/test/validation/api/shmem/shmem.c @@ -22,6 +22,8 @@ #define STRESS_SIZE 32 /* power of 2 and <=256 */ #define STRESS_RANDOM_SZ 5 #define STRESS_ITERATION 5000 +#define MAX_SIZE_TESTED (100 * 1000000UL) +#define MAX_ALIGN_TESTED (1024 * 1024) typedef enum { STRESS_FREE, /* entry is free and can be allocated */ @@ -212,6 +214,57 @@ void shmem_test_basic(void) CU_ASSERT(0 == odp_shm_free(shm)); } +/* + * maximum size reservation + */ +static void shmem_test_max_reserve(void) +{ + odp_shm_capability_t capa; + odp_shm_t shm; + uint64_t size, align; + uint8_t *data; + uint64_t i; + + memset(&capa, 0, sizeof(odp_shm_capability_t)); + CU_ASSERT_FATAL(odp_shm_capability(&capa) == 0); + + CU_ASSERT(capa.max_blocks > 0); + + size = capa.max_size; + align = capa.max_align; + + /* Assuming that system has at least MAX_SIZE_TESTED bytes available */ + if (capa.max_size == 0 || capa.max_size > MAX_SIZE_TESTED) + size = MAX_SIZE_TESTED; + + if (capa.max_align == 0 || capa.max_align > MAX_ALIGN_TESTED) + align = MAX_ALIGN_TESTED; + + printf("\n size: %" PRIu64 "\n", size); + printf(" align: %" PRIu64 "\n", align); + + shm = odp_shm_reserve("test_max_reserve", size, align, 0); + CU_ASSERT(shm != ODP_SHM_INVALID); + + data = odp_shm_addr(shm); + CU_ASSERT(data != NULL); + + if (data) { + memset(data, 0xde, size); + for (i = 0; i < size; i++) { + if (data[i] != 0xde) { + printf(" data error i:%" PRIu64 ", data %x" + "\n", i, data[i]); + CU_FAIL("Data error"); + break; + } + } + } + + if (shm != ODP_SHM_INVALID) + CU_ASSERT(odp_shm_free(shm) == 0); +} + /* * thread part for the shmem_test_reserve_after_fork */ @@ -769,6 +822,7 @@ void shmem_test_stress(void) odp_testinfo_t shmem_suite[] = { ODP_TEST_INFO(shmem_test_basic), + ODP_TEST_INFO(shmem_test_max_reserve), ODP_TEST_INFO(shmem_test_reserve_after_fork), ODP_TEST_INFO(shmem_test_singleva_after_fork), ODP_TEST_INFO(shmem_test_stress), From patchwork Fri Feb 2 10:00:11 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: 126622 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp483989ljc; Fri, 2 Feb 2018 02:01:37 -0800 (PST) X-Google-Smtp-Source: AH8x226fLUG+pmk7EAbeoDVquAOc871EeO+J9N2DLj22AQfZvvFIl2NsKTe+8wuayf6aryw1C/b0 X-Received: by 10.200.36.67 with SMTP id d3mr61372950qtd.329.1517565697201; Fri, 02 Feb 2018 02:01:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517565697; cv=none; d=google.com; s=arc-20160816; b=bJ0/RuBbFVOefXdvsNlSRHlqXnsBWjSzNoc42SUWVmFlrj/U0utNjF797/kcMOjmaj bXUd83iCLIWUUeba+D7a6svJvkxF46193Ut7r7z7rR2xuZVy/9/EG1lyLSBfViYChqo7 YD/xDyMxnwC06stw2/AcL/FPOTaQur51+vot7WGvL3b5ofp3DJ6CqhziNwc1z/0gykIn LH2AKsHtEvd8XbG2Ti3QKVJ6K3hABUGMzyiexhS0EJVQfWXpjq4+PAtuanf1J4DRFr8q IehOk7zjlP5JPZKMwaW6LNnrRFGo957l7O6Hhe1IZPz6zo5vTVjk9OVWAKCNcNDV21vZ 37Eg== 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=FCb9gc3rLhn/vMMZM14mdr+xRqoLFdtpHY/fxE1TiXc=; b=aAft7kgkCQ8FXMHBPp38APExba873wRki0OO6iMs8zbC29gj2yNTj6dbwqU/djikD9 WWg47m1WwVfr13mAwMjsFVDB7EyXAETw36xj8t4qXd7GgehdiXpZzQ7kPGw/vffDY9nV wNKJHLKn3w5z+y6ylGiAg+w0loY1qs57zis62VvLc7dr/0xHXymd4vx+dt34KgGGo3MV JdRslaLvaf0f+erezUipaufR4SEY5bqhN7U7ls/uk1PSbILwe8IzJ43onBMyUiS427pX GnJ0YKAwDnwln1QKJDLRba+8XEXRXtz5NKI2kMHlx2Kza+DzUaZ0a+9geNxm0I+dS+w3 myQA== 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 d6si1340011qtf.459.2018.02.02.02.01.36; Fri, 02 Feb 2018 02:01:37 -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 C845761798; Fri, 2 Feb 2018 10:01:36 +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_H2 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 0F39A6179E; Fri, 2 Feb 2018 10:00:31 +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 21D24610B9; Fri, 2 Feb 2018 10:00:23 +0000 (UTC) Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [37.140.190.183]) by lists.linaro.org (Postfix) with ESMTPS id 43BA1606B5 for ; Fri, 2 Feb 2018 10:00:20 +0000 (UTC) Received: from mxback4g.mail.yandex.net (mxback4g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:165]) by forward105o.mail.yandex.net (Yandex) with ESMTP id 6A8D14442A92 for ; Fri, 2 Feb 2018 13:00:14 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback4g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id oXpe1FTbz4-0EZq2lvr; Fri, 02 Feb 2018 13:00:14 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id opjCzdDZJW-0Dj0cENH; Fri, 02 Feb 2018 13:00:13 +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: Fri, 2 Feb 2018 13:00:11 +0300 Message-Id: <1517565612-17887-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517565612-17887-1-git-send-email-odpbot@yandex.ru> References: <1517565612-17887-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 446 Subject: [lng-odp] [PATCH API-NEXT v2 2/3] api: init: add shm memory size parameter 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 Application memory usage may vary a lot. Implementation may need to pre-allocate memory or address space already at init time to be able to guarantee e.g. the same VA address space for all threads. Total SHM memory usage information is needed at global init time, as implementation likely uses the same shared memory for its own global memory allocations. 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: 3ceb1d8923dfe4b778ca652825396e422766c012 **/ include/odp/api/spec/init.h | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/include/odp/api/spec/init.h b/include/odp/api/spec/init.h index 21734db2a..ee33e7cd4 100644 --- a/include/odp/api/spec/init.h +++ b/include/odp/api/spec/init.h @@ -107,23 +107,29 @@ typedef int (*odp_log_func_t)(odp_log_level_t level, const char *fmt, ...); typedef void (*odp_abort_func_t)(void) ODP_NORETURN; /** - * ODP initialization data + * Global initialization parameters * - * Data that is required to initialize the ODP API with the - * application specific data such as specifying a logging callback, the log - * level etc. + * These parameters may be used at global initialization time to configure and + * optimize ODP implementation to match the intended usage. Application + * specifies maximum resource usage. Implementation may round up resource + * reservations as needed. Initialization function returns a failure if resource + * requirements are too high. Init parameters may be used also to override + * logging and abort functions. * - * @note It is expected that all unassigned members are zero + * Use odp_init_param_init() to initialize the parameters into their default + * values. Unused parameters are left to default values. */ typedef struct odp_init_t { /** Maximum number of worker threads the user will run concurrently. Valid range is from 0 to platform specific maximum. Set both num_worker and num_control to zero for default number of threads. */ int num_worker; + /** Maximum number of control threads the user will run concurrently. Valid range is from 0 to platform specific maximum. Set both num_worker and num_control to zero for default number of threads. */ int num_control; + /** Pointer to bit mask mapping CPUs available to this ODP instance for running worker threads. Initialize to a NULL pointer to use default CPU mapping. @@ -139,6 +145,7 @@ typedef struct odp_init_t { worker masks */ const odp_cpumask_t *worker_cpus; + /** Pointer to bit mask mapping CPUs available to this ODP instance for running control threads. Initialize to a NULL pointer to use default CPU mapping. @@ -150,10 +157,13 @@ typedef struct odp_init_t { worker and control masks do not overlap. */ const odp_cpumask_t *control_cpus; + /** Replacement for the default log fn */ odp_log_func_t log_fn; + /** Replacement for the default abort fn */ odp_abort_func_t abort_fn; + /** Unused features. These are hints to the ODP implementation that * the application will not use any APIs associated with these * features. Implementations may use this information to provide @@ -161,6 +171,16 @@ typedef struct odp_init_t { * that a feature will not be used and it is used anyway. */ odp_feature_t not_used; + + /** Shared memory parameters */ + struct { + /** Maximum memory usage in bytes. This is the maximum + * amount of shared memory that application will reserve + * concurrently. Use 0 when not set. Default value is 0. + */ + uint64_t max_memory; + } shm; + } odp_init_t; /** @@ -189,7 +209,8 @@ void odp_init_param_init(odp_init_t *param); * system and outputs a handle for it. The handle is used in other calls * (e.g. odp_init_local()) as a reference to the instance. When user provides * configuration parameters, the platform may configure and optimize the - * instance to match user requirements. + * instance to match user requirements. A failure is returned if requirements + * cannot be met. * * Configuration parameters are divided into standard and platform specific * parts. Standard parameters are supported by any ODP platform, where as From patchwork Fri Feb 2 10:00:12 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: 126624 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp486222ljc; Fri, 2 Feb 2018 02:04:31 -0800 (PST) X-Google-Smtp-Source: AH8x224LX2Vxmv3p+qUowO/gZXPHTaWSzseBXPsYL6hnoKowV4FDk5983dhD4eNWXVAE12kr3oSs X-Received: by 10.200.30.141 with SMTP id c13mr23103734qtm.156.1517565871825; Fri, 02 Feb 2018 02:04:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517565871; cv=none; d=google.com; s=arc-20160816; b=B9eJ1XEzllQmbLuf1U0TtbTNh6B3AE3XJ2COzl0I4kyC6k0Hnj2hnBFzk2JuLzg/13 3B+JezsPSPMiCkBqzaow625vmX2CNBlzg7Gz4OoMufXO+5TPeAYUOhBVyVMqpK2dU+Au XCrgljciFnTzog6bhnpZ0Mfxg/Sv8GND6myB3SlFrpRT0doNKLtFVplHjEJMTLrKVE6C Kvf3oVq6a9RkHA56ZifkUZCHwGK61fOf5oYQVC/tJR4rz+2QLhLrLZ0EE1zwMPeCUYCQ a2Xtw1YdX1SFJuIFXCbie1DnAymQOnkZ6rgpYcG2aarRHncK9//s/QRTVVYeN84QsJWS z85w== 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=P16TcYWlGlwl/VlTZMSOO3fQe16+yGHZE3tsypqOW80=; b=rduZtM7vRRuiGNMJriyt2ISfjelTSqz6tOWFAJx0CVkgdfYLzMiKa1LYyeKhKZD/WT nEY5JOmGzVOtPZi8TiHF/N1kKCz9G5dk5EGDwJzUAldNRSqEmTuvwr8ps5ygUIiSll0M 2GaeyOIkcWGS22Suq+W/bwwFo58lUApXkLF7kXStnBEDWZlFjRfoObOvAShEXnM3diIc yrd9Rab1RAA1iXymi2DJx5SgAWkbDmK6Vi7a71QcyFxZ4v1ICPVtY2WfKlYtfBzpY8hT OEfIn6e3JVzPrObULBKYvD7gJt/LNl4r/ARRqFaOg0o5Jcm//DiXD6/JjQcmwIg5qlcO E9bw== 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 i1si1634708qke.483.2018.02.02.02.04.31; Fri, 02 Feb 2018 02:04:31 -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 7515361798; Fri, 2 Feb 2018 10:04:31 +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 3D14261798; Fri, 2 Feb 2018 10:01:41 +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 23D0C617C0; Fri, 2 Feb 2018 10:01:28 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id B226A61798 for ; Fri, 2 Feb 2018 10:00:25 +0000 (UTC) Received: from mxback2j.mail.yandex.net (mxback2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10b]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 243ED5603A89 for ; Fri, 2 Feb 2018 13:00:15 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id pqbin1CiHu-0F6SqdlJ; Fri, 02 Feb 2018 13:00:15 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id opjCzdDZJW-0EjeU1DH; Fri, 02 Feb 2018 13:00:14 +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: Fri, 2 Feb 2018 13:00:12 +0300 Message-Id: <1517565612-17887-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517565612-17887-1-git-send-email-odpbot@yandex.ru> References: <1517565612-17887-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 446 Subject: [lng-odp] [PATCH API-NEXT v2 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: 3ceb1d8923dfe4b778ca652825396e422766c012 **/ 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;