From patchwork Wed Dec 21 11:28:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 88716 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp2193483qgi; Wed, 21 Dec 2016 02:29:45 -0800 (PST) X-Received: by 10.200.50.209 with SMTP id a17mr3711563qtb.41.1482316185448; Wed, 21 Dec 2016 02:29:45 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q54si4863231qtq.113.2016.12.21.02.29.45; Wed, 21 Dec 2016 02:29:45 -0800 (PST) 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=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C291A635D3; Wed, 21 Dec 2016 10:29:26 +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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 38CDC635D4; Wed, 21 Dec 2016 10:28:51 +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 8DD0F635D8; Wed, 21 Dec 2016 10:28:46 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.linaro.org (Postfix) with ESMTPS id 296A2635D4 for ; Wed, 21 Dec 2016 10:28:45 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id t196so94836321lff.3 for ; Wed, 21 Dec 2016 02:28:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cyMeqWnkG8WA5lv2/20kSUaFVA8PkkkmhpswbxWlCHI=; b=QBKRnEe2KpV6H//0mwl/UUnlHXqwfyGylAagtqvB0j1sv5p/GG3D70OvHibJUgIy7D IEizaZcLLdbZVUSLIC7acN8Pphm3bX0XeLbMmZxNWNyqNdx6Aqdg9iYL1oZ2Tuhm2Rbt tWBd6c0vWxCKid30vW3gon1SM1Y7/PH+YqokMee0gFTF6P1Ney8aJNdGnOXhlMHxILTY AF8T8IUp8PJvXokox18ZD2yEje+QvecWKD/yWQgeYPb6ADuHNmSEAggqjmpYmgBlButR 3FqIzB0v61WhpUbBa143rcTnERkdhWUH6lSzOkxFYZF2G4EeJ+vACvMjLIC16wY7kFjI 68Rg== X-Gm-Message-State: AIkVDXJ6MFNDET/+ZFJ7YWxQnrjlK4GIH7EHzVgtsIGtD0Ww93PzpJvrSY44bsEMODgy8YJmIRs= X-Received: by 10.46.70.26 with SMTP id t26mr1939147lja.33.1482316123976; Wed, 21 Dec 2016 02:28:43 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id u204sm5532775lja.5.2016.12.21.02.28.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Dec 2016 02:28:43 -0800 (PST) From: Christophe Milard To: francois.ozog@linaro.org, forrest.shi@linaro.org, mike.holmes@linaro.org, yi.he@linaro.org, bill.fischofer@linaro.org, lng-odp@lists.linaro.org Date: Wed, 21 Dec 2016 12:28:19 +0100 Message-Id: <1482319702-5766-3-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482319702-5766-1-git-send-email-christophe.milard@linaro.org> References: <1482319702-5766-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCH 2/5] drv: adding odpdrv_shm_sreserve and odpdrv_shm_sfree() 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" The two functions are meant to be used fo small amount of memory allocation. They are quicker, lighter and have a smaller granularity than the odpdrv_shm_reserve() / odpdrv_shm_free_*() sets of function, but also lacks some of their functionality (lookup, export, flags). Signed-off-by: Christophe Milard --- include/odp/drv/spec/shm.h | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/include/odp/drv/spec/shm.h b/include/odp/drv/spec/shm.h index ef64f5d..d2ccfe2 100644 --- a/include/odp/drv/spec/shm.h +++ b/include/odp/drv/spec/shm.h @@ -200,9 +200,11 @@ int odpdrv_shm_info(odpdrv_shm_t shm, odpdrv_shm_info_t *info); /** * Print all shared memory blocks and returns the number of allocated blocks. + * Also gives the status of the odpdrv_shm_sreserve() pool allocator. * This function is meant for debug. * @param title A string to be printed before the shared memory status - * @return The total number of allocated blocks + * @return The total number of allocated blocks (allocated with + * odpdrv_shm_reserve()). */ int odpdrv_shm_print_all(const char *title); @@ -220,6 +222,43 @@ int odpdrv_shm_print_all(const char *title); uint64_t odpdrv_shm_to_u64(odpdrv_shm_t hdl); /** + * Reserve a small contiguous block of shared memory + * odpdrv_shm_sreserve() is meant to reserve small amount of memory from + * a preallocated pool. The size of this pool is limited, so + * odpdrv_shm_sreserve() should be used for small allocations (e.g. less than + * a 1/2 page size). + * While odpdrv_shm_reserve() granularity is large (likely the page size), + * odpdrv_shm_sreserve() has a much smaller granularity, making it ideal for + * small allocations such as those done to populate a linked list. + * Addresses returned by odpdrv_shm_sreserve() are sharable between all ODP + * threads. Buffer allocated through odpdrv_shm_sreserve() are enonymous and + * can therefore not by looked up by name. Neither can they be exported + * to other ODP instances. + * Buffers allocated with this function should be release with + * odpdrv_shm_sfree(). + * + * @param[in] size Block size in bytes + * + * @return The address of the reserved block. + * @retval NULL on failure + */ +void *odpdrv_shm_sreserve(uint64_t size); + +/** + * Free a contiguous block of shared memory previously allocated with + * odpdrv_shm_reserve() + * + * Frees a previously reserved block of shared memory. + * @note Freeing memory that is in use will result in UNDEFINED behavior + * + * @param[in] addr address (as returned by odpdrv_shm_sreserve()). + * + * @retval 0 on success + * @retval <0 on failure + */ +int odpdrv_shm_sfree(void *addr); + +/** * @} */