From patchwork Tue Dec 20 08:00:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 88554 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1577740qgi; Mon, 19 Dec 2016 23:02:02 -0800 (PST) X-Received: by 10.237.50.129 with SMTP id z1mr3462004qtd.158.1482217322522; Mon, 19 Dec 2016 23:02:02 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q37si1806544qte.225.2016.12.19.23.02.02; Mon, 19 Dec 2016 23:02:02 -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 332B262F18; Tue, 20 Dec 2016 07:02:02 +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 12B4B62ECB; Tue, 20 Dec 2016 07:00:54 +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 37FE262EBC; Tue, 20 Dec 2016 07:00:47 +0000 (UTC) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com [209.85.215.52]) by lists.linaro.org (Postfix) with ESMTPS id 950A162EBC for ; Tue, 20 Dec 2016 07:00:43 +0000 (UTC) Received: by mail-lf0-f52.google.com with SMTP id y21so69674703lfa.1 for ; Mon, 19 Dec 2016 23:00:43 -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=RzLR7y9ADOjtw0vYrw5ZM9w7SVt4h5hkhIFVl91Df6BPVeDWwyKSSM2roHEfXMWDXi C8wTD1gPe3rUvG3iYbs0x7IVu1OCsEJkNTwo7CpBLFylYb5na4vhVAJOuuZZ0umAilwB 1YQ9DvvcqxhM/FXY+XJwAH/KZYHw3lz4qCa1xJlYuFSHMpYLQHGdrKGa6A/KbBDnP37b 75fEr/WzzOGVtj9BYjpNz+NQTtH6Ngx8UXQXUKA+SV3QrtmH0IB0QSDBKFD8xKt3IGXW rJ8rzZADJ4Dy6Ccd195cQ8cYwj0jso4T0erzl9Osonw3x7PaT0aO7uSav746+ghy/Kdz sJNA== X-Gm-Message-State: AIkVDXKdLDZ7UKivbNoELJmaAQx3F/RO1LdPYcLfqmw4T5TlZTOwJlJ/T/yZYrtZuWz7uhcGgFo= X-Received: by 10.46.5.15 with SMTP id 15mr9211428ljf.64.1482217242401; Mon, 19 Dec 2016 23:00:42 -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 f42sm4438503lji.2.2016.12.19.23.00.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Dec 2016 23:00:41 -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: Tue, 20 Dec 2016 09:00:04 +0100 Message-Id: <1482220807-6139-3-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482220807-6139-1-git-send-email-christophe.milard@linaro.org> References: <1482220807-6139-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [RFC 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); + +/** * @} */