patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] memory: make eal_get_virtual_area() aware of base-virtaddr alignment
@ 2018-06-15 12:24 Dariusz Stojaczyk
  2018-06-15 14:22 ` Burakov, Anatoly
  2018-06-15 15:13 ` [dpdk-stable] [PATCH v2] " Dariusz Stojaczyk
  0 siblings, 2 replies; 4+ messages in thread
From: Dariusz Stojaczyk @ 2018-06-15 12:24 UTC (permalink / raw)
  To: dev, Anatoly Burakov; +Cc: Dariusz Stojaczyk, stable

From: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>

Whenever a calculated base-virtaddr offset had to be
manually aligned to requested page_sz, we did not take
account of that alignment in incrementing the base-virtaddr
offset further. The next requested virtual area could print
a warning "hint [...] not respected!" and let the system
pick an address instead. As a result, this breaks secondary
process support on many system configurations.

Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory")
Cc: anatoly.burakov@intel.com
Cc: stable@dpdk.org

Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
---
 lib/librte_eal/common/eal_common_memory.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 4f0688f9d..7c8a316c2 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -34,7 +34,7 @@
 
 #define MEMSEG_LIST_FMT "memseg-%" PRIu64 "k-%i-%i"
 
-static uint64_t baseaddr_offset;
+static void *next_baseaddr;
 static uint64_t system_page_sz;
 
 void *
@@ -56,9 +56,11 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
 	allow_shrink = (flags & EAL_VIRTUAL_AREA_ALLOW_SHRINK) > 0;
 	unmap = (flags & EAL_VIRTUAL_AREA_UNMAP) > 0;
 
-	if (requested_addr == NULL && internal_config.base_virtaddr != 0) {
-		requested_addr = (void *) (internal_config.base_virtaddr +
-				(size_t)baseaddr_offset);
+	if (next_baseaddr == NULL && internal_config.base_virtaddr != 0)
+		next_baseaddr = (void *) internal_config.base_virtaddr;
+
+	if (requested_addr == NULL && next_baseaddr) {
+		requested_addr = next_baseaddr;
 		requested_addr = RTE_PTR_ALIGN(requested_addr, page_sz);
 		addr_is_hint = true;
 	}
@@ -116,6 +118,8 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
 		RTE_LOG(WARNING, EAL, "WARNING! Base virtual address hint (%p != %p) not respected!\n",
 			requested_addr, aligned_addr);
 		RTE_LOG(WARNING, EAL, "   This may cause issues with mapping memory into secondary processes\n");
+	} else {
+		next_baseaddr = RTE_PTR_ADD(aligned_addr, *size);
 	}
 
 	RTE_LOG(DEBUG, EAL, "Virtual area found at %p (size = 0x%zx)\n",
@@ -148,8 +152,6 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
 			munmap(aligned_end, after_len);
 	}
 
-	baseaddr_offset += *size;
-
 	return aligned_addr;
 }
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-stable] [PATCH] memory: make eal_get_virtual_area() aware of base-virtaddr alignment
  2018-06-15 12:24 [dpdk-stable] [PATCH] memory: make eal_get_virtual_area() aware of base-virtaddr alignment Dariusz Stojaczyk
@ 2018-06-15 14:22 ` Burakov, Anatoly
  2018-06-15 15:13 ` [dpdk-stable] [PATCH v2] " Dariusz Stojaczyk
  1 sibling, 0 replies; 4+ messages in thread
From: Burakov, Anatoly @ 2018-06-15 14:22 UTC (permalink / raw)
  To: Dariusz Stojaczyk, dev; +Cc: Dariusz Stojaczyk, stable

On 15-Jun-18 1:24 PM, Dariusz Stojaczyk wrote:
> From: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
> 
> Whenever a calculated base-virtaddr offset had to be
> manually aligned to requested page_sz, we did not take
> account of that alignment in incrementing the base-virtaddr
> offset further. The next requested virtual area could print
> a warning "hint [...] not respected!" and let the system
> pick an address instead. As a result, this breaks secondary
> process support on many system configurations.
> 
> Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory")
> Cc: anatoly.burakov@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-stable] [PATCH v2] memory: make eal_get_virtual_area() aware of base-virtaddr alignment
  2018-06-15 12:24 [dpdk-stable] [PATCH] memory: make eal_get_virtual_area() aware of base-virtaddr alignment Dariusz Stojaczyk
  2018-06-15 14:22 ` Burakov, Anatoly
@ 2018-06-15 15:13 ` Dariusz Stojaczyk
  2018-07-12 22:01   ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
  1 sibling, 1 reply; 4+ messages in thread
From: Dariusz Stojaczyk @ 2018-06-15 15:13 UTC (permalink / raw)
  To: dev, Anatoly Burakov; +Cc: Dariusz Stojaczyk, stable

From: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>

Whenever a calculated base-virtaddr offset had to be
manually aligned to requested page_sz, we did not take
account of that alignment in incrementing the base-virtaddr
offset further. The next requested virtual area could print
a warning "hint [...] not respected!" and let the system
pick an address instead. As a result, this breaks secondary
process support on many system configurations.

Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory")
Cc: anatoly.burakov@intel.com
Cc: stable@dpdk.org

Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
Changes from v1:
 * do not increment next_baseaddr if its currently NULL.
   Otherwise this patch breaks applications without base-virtaddr specified
 * switched to explicit `!= NULL` comparisons

 lib/librte_eal/common/eal_common_memory.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 4f0688f9d..2413ce1e7 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -34,7 +34,7 @@
 
 #define MEMSEG_LIST_FMT "memseg-%" PRIu64 "k-%i-%i"
 
-static uint64_t baseaddr_offset;
+static void *next_baseaddr;
 static uint64_t system_page_sz;
 
 void *
@@ -56,9 +56,11 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
 	allow_shrink = (flags & EAL_VIRTUAL_AREA_ALLOW_SHRINK) > 0;
 	unmap = (flags & EAL_VIRTUAL_AREA_UNMAP) > 0;
 
-	if (requested_addr == NULL && internal_config.base_virtaddr != 0) {
-		requested_addr = (void *) (internal_config.base_virtaddr +
-				(size_t)baseaddr_offset);
+	if (next_baseaddr == NULL && internal_config.base_virtaddr != 0)
+		next_baseaddr = (void *) internal_config.base_virtaddr;
+
+	if (requested_addr == NULL && next_baseaddr != NULL) {
+		requested_addr = next_baseaddr;
 		requested_addr = RTE_PTR_ALIGN(requested_addr, page_sz);
 		addr_is_hint = true;
 	}
@@ -116,6 +118,8 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
 		RTE_LOG(WARNING, EAL, "WARNING! Base virtual address hint (%p != %p) not respected!\n",
 			requested_addr, aligned_addr);
 		RTE_LOG(WARNING, EAL, "   This may cause issues with mapping memory into secondary processes\n");
+	} else if (next_baseaddr != NULL) {
+		next_baseaddr = RTE_PTR_ADD(aligned_addr, *size);
 	}
 
 	RTE_LOG(DEBUG, EAL, "Virtual area found at %p (size = 0x%zx)\n",
@@ -148,8 +152,6 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
 			munmap(aligned_end, after_len);
 	}
 
-	baseaddr_offset += *size;
-
 	return aligned_addr;
 }
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH v2] memory: make eal_get_virtual_area() aware of base-virtaddr alignment
  2018-06-15 15:13 ` [dpdk-stable] [PATCH v2] " Dariusz Stojaczyk
@ 2018-07-12 22:01   ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2018-07-12 22:01 UTC (permalink / raw)
  To: Dariusz Stojaczyk; +Cc: dev, Dariusz Stojaczyk, Anatoly Burakov, stable

15/06/2018 17:13, Dariusz Stojaczyk:
> From: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
> 
> Whenever a calculated base-virtaddr offset had to be
> manually aligned to requested page_sz, we did not take
> account of that alignment in incrementing the base-virtaddr
> offset further. The next requested virtual area could print
> a warning "hint [...] not respected!" and let the system
> pick an address instead. As a result, this breaks secondary
> process support on many system configurations.
> 
> Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory")
> Cc: anatoly.burakov@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-12 22:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-15 12:24 [dpdk-stable] [PATCH] memory: make eal_get_virtual_area() aware of base-virtaddr alignment Dariusz Stojaczyk
2018-06-15 14:22 ` Burakov, Anatoly
2018-06-15 15:13 ` [dpdk-stable] [PATCH v2] " Dariusz Stojaczyk
2018-07-12 22:01   ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).