From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 0A8C44C8E for ; Sat, 10 Mar 2018 16:42:14 +0100 (CET) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id E012E14005C; Sat, 10 Mar 2018 15:42:12 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Sat, 10 Mar 2018 07:42:10 -0800 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25 via Frontend Transport; Sat, 10 Mar 2018 07:42:10 -0800 Received: from uklogin.uk.solarflarecom.com (uklogin.uk.solarflarecom.com [10.17.10.10]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id w2AFg86Z017332; Sat, 10 Mar 2018 15:42:08 GMT Received: from uklogin.uk.solarflarecom.com (localhost.localdomain [127.0.0.1]) by uklogin.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id w2AFdxbk016447; Sat, 10 Mar 2018 15:42:08 GMT From: Andrew Rybchenko To: CC: Olivier MATZ Date: Sat, 10 Mar 2018 15:39:37 +0000 Message-ID: <1520696382-16400-5-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1520696382-16400-1-git-send-email-arybchenko@solarflare.com> References: <1516713372-10572-1-git-send-email-arybchenko@solarflare.com> <1520696382-16400-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-MDID: 1520696533-vIwa2gJASsAI Subject: [dpdk-dev] [PATCH v1 4/9] mempool: deprecate xmem functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Mar 2018 15:42:14 -0000 Move rte_mempool_xmem_size() code to internal helper function since it is required in two places: deprecated rte_mempool_xmem_size() and non-deprecated rte_mempool_op_calc_mem_size_deafult(). Signed-off-by: Andrew Rybchenko --- RFCv2 -> v1: - advertise deprecation in release notes - factor out default memory size calculation into non-deprecated internal function to avoid usage of deprecated function internally - remove test for deprecated functions to address build issue because of usage of deprecated functions (it is easy to allow usage of deprecated function in Makefile, but very complicated in meson) doc/guides/rel_notes/deprecation.rst | 7 ------- doc/guides/rel_notes/release_18_05.rst | 10 +++++++++ lib/librte_mempool/rte_mempool.c | 19 ++++++++++++++--- lib/librte_mempool/rte_mempool.h | 25 ++++++++++++++++++++++ lib/librte_mempool/rte_mempool_ops_default.c | 4 ++-- test/test/test_mempool.c | 31 ---------------------------- 6 files changed, 53 insertions(+), 43 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 4deed9a..473330d 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -60,13 +60,6 @@ Deprecation Notices - ``rte_eal_mbuf_default_mempool_ops`` * mempool: several API and ABI changes are planned in v18.05. - The following functions, introduced for Xen, which is not supported - anymore since v17.11, are hard to use, not used anywhere else in DPDK. - Therefore they will be deprecated in v18.05 and removed in v18.08: - - - ``rte_mempool_xmem_create`` - - ``rte_mempool_xmem_size`` - - ``rte_mempool_xmem_usage`` The following changes are planned: diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index c50f26c..0244f91 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -74,6 +74,16 @@ API Changes Now the new driver callbacks ``calc_mem_size`` and ``populate`` may be used to achieve it without specific knowledge in the generic code. +* **Deprecated mempool xmem functions.** + + The following functions, introduced for Xen, which is not supported + anymore since v17.11, are hard to use, not used anywhere else in DPDK. + Therefore they were deprecated in v18.05 and will be removed in v18.08: + + - ``rte_mempool_xmem_create`` + - ``rte_mempool_xmem_size`` + - ``rte_mempool_xmem_usage`` + ABI Changes ----------- diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index fdcda45..b57ba2a 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -204,11 +204,13 @@ rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags, /* - * Calculate maximum amount of memory required to store given number of objects. + * Internal function to calculate required memory chunk size shared + * by default implementation of the corresponding callback and + * deprecated external function. */ size_t -rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift, - __rte_unused unsigned int flags) +rte_mempool_calc_mem_size_helper(uint32_t elt_num, size_t total_elt_sz, + uint32_t pg_shift) { size_t obj_per_page, pg_num, pg_sz; @@ -228,6 +230,17 @@ rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift, } /* + * Calculate maximum amount of memory required to store given number of objects. + */ +size_t +rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift, + __rte_unused unsigned int flags) +{ + return rte_mempool_calc_mem_size_helper(elt_num, total_elt_sz, + pg_shift); +} + +/* * Calculate how much memory would be actually required with the * given memory footprint to store required number of elements. */ diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index cd3b229..ebfc95c 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -420,6 +420,28 @@ ssize_t rte_mempool_op_calc_mem_size_default(const struct rte_mempool *mp, size_t *min_chunk_size, size_t *align); /** + * @internal Helper function to calculate memory size required to store + * specified number of objects in assumption that the memory buffer will + * be aligned at page boundary. + * + * Note that if object size is bigger than page size, then it assumes + * that pages are grouped in subsets of physically continuous pages big + * enough to store at least one object. + * + * @param elt_num + * Number of elements. + * @param total_elt_sz + * The size of each element, including header and trailer, as returned + * by rte_mempool_calc_obj_size(). + * @param pg_shift + * LOG2 of the physical pages size. If set to 0, ignore page boundaries. + * @return + * Required memory size aligned at page boundary. + */ +size_t rte_mempool_calc_mem_size_helper(uint32_t elt_num, size_t total_elt_sz, + uint32_t pg_shift); + +/** * Function to be called for each populated object. * * @param[in] mp @@ -905,6 +927,7 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size, * The pointer to the new allocated mempool, on success. NULL on error * with rte_errno set appropriately. See rte_mempool_create() for details. */ +__rte_deprecated struct rte_mempool * rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size, unsigned cache_size, unsigned private_data_size, @@ -1667,6 +1690,7 @@ uint32_t rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags, * @return * Required memory size aligned at page boundary. */ +__rte_deprecated size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift, unsigned int flags); @@ -1698,6 +1722,7 @@ size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, * buffer is too small, return a negative value whose absolute value * is the actual number of elements that can be stored in that buffer. */ +__rte_deprecated ssize_t rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num, size_t total_elt_sz, const rte_iova_t iova[], uint32_t pg_num, uint32_t pg_shift, unsigned int flags); diff --git a/lib/librte_mempool/rte_mempool_ops_default.c b/lib/librte_mempool/rte_mempool_ops_default.c index 3defc15..fd63ca1 100644 --- a/lib/librte_mempool/rte_mempool_ops_default.c +++ b/lib/librte_mempool/rte_mempool_ops_default.c @@ -16,8 +16,8 @@ rte_mempool_op_calc_mem_size_default(const struct rte_mempool *mp, total_elt_sz = mp->header_size + mp->elt_size + mp->trailer_size; - mem_size = rte_mempool_xmem_size(obj_num, total_elt_sz, pg_shift, - mp->flags); + mem_size = rte_mempool_calc_mem_size_helper(obj_num, total_elt_sz, + pg_shift); *min_chunk_size = RTE_MAX((size_t)1 << pg_shift, total_elt_sz); diff --git a/test/test/test_mempool.c b/test/test/test_mempool.c index 63f921e..8d29af2 100644 --- a/test/test/test_mempool.c +++ b/test/test/test_mempool.c @@ -444,34 +444,6 @@ test_mempool_same_name_twice_creation(void) return 0; } -/* - * Basic test for mempool_xmem functions. - */ -static int -test_mempool_xmem_misc(void) -{ - uint32_t elt_num, total_size; - size_t sz; - ssize_t usz; - - elt_num = MAX_KEEP; - total_size = rte_mempool_calc_obj_size(MEMPOOL_ELT_SIZE, 0, NULL); - sz = rte_mempool_xmem_size(elt_num, total_size, MEMPOOL_PG_SHIFT_MAX, - 0); - - usz = rte_mempool_xmem_usage(NULL, elt_num, total_size, 0, 1, - MEMPOOL_PG_SHIFT_MAX, 0); - - if (sz != (size_t)usz) { - printf("failure @ %s: rte_mempool_xmem_usage(%u, %u) " - "returns: %#zx, while expected: %#zx;\n", - __func__, elt_num, total_size, sz, (size_t)usz); - return -1; - } - - return 0; -} - static void walk_cb(struct rte_mempool *mp, void *userdata __rte_unused) { @@ -596,9 +568,6 @@ test_mempool(void) if (test_mempool_same_name_twice_creation() < 0) goto err; - if (test_mempool_xmem_misc() < 0) - goto err; - /* test the stack handler */ if (test_mempool_basic(mp_stack, 1) < 0) goto err; -- 2.7.4