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 509E7D4A0 for ; Mon, 16 Apr 2018 15:25:01 +0200 (CEST) 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-us4.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id 3605B140154; Mon, 16 Apr 2018 13:25:00 +0000 (UTC) Received: from sfocexch01r.SolarFlarecom.com (10.20.40.34) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Mon, 16 Apr 2018 06:24:56 -0700 Received: from ocex03.SolarFlarecom.com (10.20.40.36) by sfocexch01r.SolarFlarecom.com (10.20.40.34) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Mon, 16 Apr 2018 06:24:47 -0700 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; Mon, 16 Apr 2018 06:24:46 -0700 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 w3GDOjq7012285; Mon, 16 Apr 2018 14:24:45 +0100 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 w3GDOiRV017332; Mon, 16 Apr 2018 14:24:45 +0100 From: Andrew Rybchenko To: CC: Olivier MATZ , Thomas Monjalon Date: Mon, 16 Apr 2018 14:24:36 +0100 Message-ID: <1523885080-17168-8-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1523885080-17168-1-git-send-email-arybchenko@solarflare.com> References: <1511539591-20966-1-git-send-email-arybchenko@solarflare.com> <1523885080-17168-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-MDID: 1523885100-T-HKHAkDkd2y Subject: [dpdk-dev] [PATCH v4 07/11] 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: Mon, 16 Apr 2018 13:25:01 -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_default(). Suggested-by: Olivier Matz Signed-off-by: Andrew Rybchenko Acked-by: Olivier Matz --- v2 -> v3: - none v1 -> v2: - deprecate rte_mempool_populate_iova_tab() - add -Wno-deprecated-declarations to fix build errors because of rte_mempool_populate_iova_tab() deprecation - add @deprecated to deprecated functions description 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 | 11 ++++++++++ lib/librte_mempool/Makefile | 3 +++ lib/librte_mempool/meson.build | 12 +++++++++++ lib/librte_mempool/rte_mempool.c | 19 ++++++++++++++--- lib/librte_mempool/rte_mempool.h | 30 +++++++++++++++++++++++++++ lib/librte_mempool/rte_mempool_ops_default.c | 4 ++-- test/test/test_mempool.c | 31 ---------------------------- 8 files changed, 74 insertions(+), 43 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 99a0b01..8d1b362 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -48,13 +48,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 f481eea..3869d04 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -181,6 +181,17 @@ 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`` + - ``rte_mempool_populate_iova_tab`` + ABI Changes ----------- diff --git a/lib/librte_mempool/Makefile b/lib/librte_mempool/Makefile index 421e2a7..7f19f00 100644 --- a/lib/librte_mempool/Makefile +++ b/lib/librte_mempool/Makefile @@ -7,6 +7,9 @@ include $(RTE_SDK)/mk/rte.vars.mk LIB = librte_mempool.a CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 +# Allow deprecated symbol to use deprecated rte_mempool_populate_iova_tab() +# from earlier deprecated rte_mempool_populate_phys_tab() +CFLAGS += -Wno-deprecated-declarations LDLIBS += -lrte_eal -lrte_ring EXPORT_MAP := rte_mempool_version.map diff --git a/lib/librte_mempool/meson.build b/lib/librte_mempool/meson.build index 6181ad8..baf2d24 100644 --- a/lib/librte_mempool/meson.build +++ b/lib/librte_mempool/meson.build @@ -1,6 +1,18 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +extra_flags = [] + +# Allow deprecated symbol to use deprecated rte_mempool_populate_iova_tab() +# from earlier deprecated rte_mempool_populate_phys_tab() +extra_flags += '-Wno-deprecated-declarations' + +foreach flag: extra_flags + if cc.has_argument(flag) + cflags += flag + endif +endforeach + version = 4 sources = files('rte_mempool.c', 'rte_mempool_ops.c', 'rte_mempool_ops_default.c') diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 5c75c16..c63c363 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -227,11 +227,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; @@ -251,6 +253,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 0b83d5e..9107f5a 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -427,6 +427,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 @@ -855,6 +877,7 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size, int socket_id, unsigned flags); /** + * @deprecated * Create a new mempool named *name* in memory. * * The pool contains n elements of elt_size. Its size is set to n. @@ -912,6 +935,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, @@ -1008,6 +1032,7 @@ int rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr, void *opaque); /** + * @deprecated * Add physical memory for objects in the pool at init * * Add a virtually contiguous memory chunk in the pool where objects can @@ -1033,6 +1058,7 @@ int rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr, * On error, the chunks are not added in the memory list of the * mempool and a negative errno is returned. */ +__rte_deprecated int rte_mempool_populate_iova_tab(struct rte_mempool *mp, char *vaddr, const rte_iova_t iova[], uint32_t pg_num, uint32_t pg_shift, rte_mempool_memchunk_free_cb_t *free_cb, void *opaque); @@ -1652,6 +1678,7 @@ uint32_t rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags, struct rte_mempool_objsz *sz); /** + * @deprecated * Get the size of memory required to store mempool elements. * * Calculate the maximum amount of memory required to store given number @@ -1674,10 +1701,12 @@ 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); /** + * @deprecated * Get the size of memory required to store mempool elements. * * Calculate how much memory would be actually required with the given @@ -1705,6 +1734,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