[dpdk-stable] patch 'mem: fix freeing segments in --huge-unlink mode' has been queued to stable release 20.11.2

Xueming Li xuemingl at nvidia.com
Mon May 10 18:01:17 CEST 2021


Hi,

FYI, your patch has been queued to stable release 20.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/12/21. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/e0a41b8c471b32fc855bcd016d97bbb935fd36b0

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From e0a41b8c471b32fc855bcd016d97bbb935fd36b0 Mon Sep 17 00:00:00 2001
From: Roy Shterman <roy.shterman at vastdata.com>
Date: Mon, 22 Feb 2021 12:41:31 +0200
Subject: [PATCH] mem: fix freeing segments in --huge-unlink mode
Cc: Luca Boccassi <bluca at debian.org>

[ upstream commit edf20bd8a55192616e4a0f26c346b55ddbac1d81 ]

When using huge_unlink we unlink the segment right
after allocation. Although we unlink the file we keep
the fd in fd_list so file still exist just the path deleted.
When freeing the hugepage we need to close the fd and assign
it with (-1) in fd_list for the page to be released.

The current flow fails rte_malloc in the following flow when working
with --huge-unlink option:
1. alloc_seg() for segment A -
    We allocate a segment, unlink the path to the segment
    and keep the file descriptor in fd_list.
2. free_seg() for segment A -
    We clear the segment metadata and return - without closing fd
    or assigning (-1) in fd list.
3. alloc_seg() for segment A again -
    We find segment A as available, try to allocate it,
    find the old fd in fd_list try to unlink it
    as part of alloc_seg() but failed because path doesn't exist.

The impact of such error is falsely failing rte_malloc()
although we have hugepages available.

Fixes: d435aad37da7 ("mem: support --huge-unlink mode")

Signed-off-by: Roy Shterman <roy.shterman at vastdata.com>
Acked-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
 lib/librte_eal/linux/eal_memalloc.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/lib/librte_eal/linux/eal_memalloc.c b/lib/librte_eal/linux/eal_memalloc.c
index 6dc1b2baec..c590d60430 100644
--- a/lib/librte_eal/linux/eal_memalloc.c
+++ b/lib/librte_eal/linux/eal_memalloc.c
@@ -709,7 +709,6 @@ free_seg(struct rte_memseg *ms, struct hugepage_info *hi,
 	uint64_t map_offset;
 	char path[PATH_MAX];
 	int fd, ret = 0;
-	bool exit_early;
 	const struct internal_config *internal_conf =
 		eal_get_internal_configuration();
 
@@ -725,17 +724,8 @@ free_seg(struct rte_memseg *ms, struct hugepage_info *hi,
 
 	eal_mem_set_dump(ms->addr, ms->len, false);
 
-	exit_early = false;
-
 	/* if we're using anonymous hugepages, nothing to be done */
-	if (internal_conf->in_memory && !memfd_create_supported)
-		exit_early = true;
-
-	/* if we've already unlinked the page, nothing needs to be done */
-	if (!internal_conf->in_memory && internal_conf->hugepage_unlink)
-		exit_early = true;
-
-	if (exit_early) {
+	if (internal_conf->in_memory && !memfd_create_supported) {
 		memset(ms, 0, sizeof(*ms));
 		return 0;
 	}
@@ -761,7 +751,7 @@ free_seg(struct rte_memseg *ms, struct hugepage_info *hi,
 		/* if we're able to take out a write lock, we're the last one
 		 * holding onto this page.
 		 */
-		if (!internal_conf->in_memory) {
+		if (!internal_conf->in_memory && !internal_conf->hugepage_unlink) {
 			ret = lock(fd, LOCK_EX);
 			if (ret >= 0) {
 				/* no one else is using this page */
-- 
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-05-10 23:59:29.914004700 +0800
+++ 0129-mem-fix-freeing-segments-in-huge-unlink-mode.patch	2021-05-10 23:59:26.530000000 +0800
@@ -1 +1 @@
-From edf20bd8a55192616e4a0f26c346b55ddbac1d81 Mon Sep 17 00:00:00 2001
+From e0a41b8c471b32fc855bcd016d97bbb935fd36b0 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Luca Boccassi <bluca at debian.org>
+
+[ upstream commit edf20bd8a55192616e4a0f26c346b55ddbac1d81 ]
@@ -29 +31,0 @@
-Cc: stable at dpdk.org
@@ -38 +40 @@
-index 00e2662c15..0ec8542283 100644
+index 6dc1b2baec..c590d60430 100644


More information about the stable mailing list