* [dpdk-stable] [PATCH] mem: fix alignment of requested virtual areas
@ 2018-07-16 14:57 Anatoly Burakov
2018-07-16 15:20 ` Yao, Lei A
2018-07-17 9:48 ` Stojaczyk, DariuszX
0 siblings, 2 replies; 4+ messages in thread
From: Anatoly Burakov @ 2018-07-16 14:57 UTC (permalink / raw)
To: dev; +Cc: thomas, lei.a.yao, dariuszx.stojaczyk, stable
The original code did not align any addresses that were requested as
page-aligned, but were different because addr_is_hint was set.
Below fix by Dariusz has introduced an issue where all unaligned addresses
were left as unaligned.
This patch is a partial revert of
commit 7fa7216ed48d ("mem: fix alignment of requested virtual areas")
and implements a proper fix for this issue, by asking for alignment in all
but the following two cases:
1) page size is equal to system page size, or
2) we got an aligned requested address, and will not accept a different one
This ensures that alignment is performed in all cases, except for those we
can guarantee that the address will not need alignment.
Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory")
Fixes: 7fa7216ed48d ("mem: fix alignment of requested virtual areas")
Cc: dariuszx.stojaczyk@intel.com
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/librte_eal/common/eal_common_memory.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 659cc08f6..fbfb1b055 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -66,14 +66,17 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
addr_is_hint = true;
}
- /* if requested address is not aligned by page size, or if requested
- * address is NULL, add page size to requested length as we may get an
- * address that's aligned by system page size, which can be smaller than
- * our requested page size. additionally, we shouldn't try to align if
- * system page size is the same as requested page size.
+ /* we don't need alignment of resulting pointer in the following cases:
+ *
+ * 1. page size is equal to system size
+ * 2. we have a requested address, and it is page-aligned, and we will
+ * be discarding the address if we get a different one.
+ *
+ * for all other cases, alignment is potentially necessary.
*/
no_align = (requested_addr != NULL &&
- ((uintptr_t)requested_addr & (page_sz - 1))) ||
+ requested_addr == RTE_PTR_ALIGN(requested_addr, page_sz) &&
+ !addr_is_hint) ||
page_sz == system_page_sz;
do {
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [PATCH] mem: fix alignment of requested virtual areas
2018-07-16 14:57 [dpdk-stable] [PATCH] mem: fix alignment of requested virtual areas Anatoly Burakov
@ 2018-07-16 15:20 ` Yao, Lei A
2018-07-17 9:48 ` Stojaczyk, DariuszX
1 sibling, 0 replies; 4+ messages in thread
From: Yao, Lei A @ 2018-07-16 15:20 UTC (permalink / raw)
To: Burakov, Anatoly, dev; +Cc: thomas, Stojaczyk, DariuszX, stable
> -----Original Message-----
> From: Burakov, Anatoly
> Sent: Monday, July 16, 2018 3:57 PM
> To: dev@dpdk.org
> Cc: thomas@monjalon.net; Yao, Lei A <lei.a.yao@intel.com>; Stojaczyk,
> DariuszX <dariuszx.stojaczyk@intel.com>; stable@dpdk.org
> Subject: [PATCH] mem: fix alignment of requested virtual areas
>
> The original code did not align any addresses that were requested as
> page-aligned, but were different because addr_is_hint was set.
>
> Below fix by Dariusz has introduced an issue where all unaligned addresses
> were left as unaligned.
>
> This patch is a partial revert of
> commit 7fa7216ed48d ("mem: fix alignment of requested virtual areas")
>
> and implements a proper fix for this issue, by asking for alignment in all
> but the following two cases:
>
> 1) page size is equal to system page size, or
> 2) we got an aligned requested address, and will not accept a different one
>
> This ensures that alignment is performed in all cases, except for those we
> can guarantee that the address will not need alignment.
>
> Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory")
> Fixes: 7fa7216ed48d ("mem: fix alignment of requested virtual areas")
> Cc: dariuszx.stojaczyk@intel.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Tested-by: Lei Yao<lei.a.yao@intel.com>
This patch is passed with following two multi process test
1. quota_watermark sample test( qw as primary, qwctl as secondary)
2. Testpmd with NIC and vdev(primary)+ dpdk-procinfo(secondary)
> ---
> lib/librte_eal/common/eal_common_memory.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/lib/librte_eal/common/eal_common_memory.c
> b/lib/librte_eal/common/eal_common_memory.c
> index 659cc08f6..fbfb1b055 100644
> --- a/lib/librte_eal/common/eal_common_memory.c
> +++ b/lib/librte_eal/common/eal_common_memory.c
> @@ -66,14 +66,17 @@ eal_get_virtual_area(void *requested_addr, size_t
> *size,
> addr_is_hint = true;
> }
>
> - /* if requested address is not aligned by page size, or if requested
> - * address is NULL, add page size to requested length as we may get
> an
> - * address that's aligned by system page size, which can be smaller
> than
> - * our requested page size. additionally, we shouldn't try to align if
> - * system page size is the same as requested page size.
> + /* we don't need alignment of resulting pointer in the following
> cases:
> + *
> + * 1. page size is equal to system size
> + * 2. we have a requested address, and it is page-aligned, and we will
> + * be discarding the address if we get a different one.
> + *
> + * for all other cases, alignment is potentially necessary.
> */
> no_align = (requested_addr != NULL &&
> - ((uintptr_t)requested_addr & (page_sz - 1))) ||
> + requested_addr == RTE_PTR_ALIGN(requested_addr,
> page_sz) &&
> + !addr_is_hint) ||
> page_sz == system_page_sz;
>
> do {
> --
> 2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [PATCH] mem: fix alignment of requested virtual areas
2018-07-16 14:57 [dpdk-stable] [PATCH] mem: fix alignment of requested virtual areas Anatoly Burakov
2018-07-16 15:20 ` Yao, Lei A
@ 2018-07-17 9:48 ` Stojaczyk, DariuszX
2018-07-18 21:23 ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
1 sibling, 1 reply; 4+ messages in thread
From: Stojaczyk, DariuszX @ 2018-07-17 9:48 UTC (permalink / raw)
To: Burakov, Anatoly, dev; +Cc: thomas, Yao, Lei A, stable
> -----Original Message-----
> From: Burakov, Anatoly
> Sent: Monday, July 16, 2018 4:57 PM
> To: dev@dpdk.org
> Cc: thomas@monjalon.net; Yao, Lei A <lei.a.yao@intel.com>; Stojaczyk, DariuszX
> <dariuszx.stojaczyk@intel.com>; stable@dpdk.org
> Subject: [PATCH] mem: fix alignment of requested virtual areas
>
> The original code did not align any addresses that were requested as
> page-aligned, but were different because addr_is_hint was set.
>
> Below fix by Dariusz has introduced an issue where all unaligned addresses
> were left as unaligned.
>
> This patch is a partial revert of
> commit 7fa7216ed48d ("mem: fix alignment of requested virtual areas")
>
> and implements a proper fix for this issue, by asking for alignment in all
> but the following two cases:
>
> 1) page size is equal to system page size, or
> 2) we got an aligned requested address, and will not accept a different one
>
> This ensures that alignment is performed in all cases, except for those we
> can guarantee that the address will not need alignment.
>
> Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory")
> Fixes: 7fa7216ed48d ("mem: fix alignment of requested virtual areas")
> Cc: dariuszx.stojaczyk@intel.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
> ---
> lib/librte_eal/common/eal_common_memory.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/lib/librte_eal/common/eal_common_memory.c
> b/lib/librte_eal/common/eal_common_memory.c
> index 659cc08f6..fbfb1b055 100644
> --- a/lib/librte_eal/common/eal_common_memory.c
> +++ b/lib/librte_eal/common/eal_common_memory.c
> @@ -66,14 +66,17 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
> addr_is_hint = true;
> }
>
> - /* if requested address is not aligned by page size, or if requested
> - * address is NULL, add page size to requested length as we may get an
> - * address that's aligned by system page size, which can be smaller than
> - * our requested page size. additionally, we shouldn't try to align if
> - * system page size is the same as requested page size.
> + /* we don't need alignment of resulting pointer in the following cases:
> + *
> + * 1. page size is equal to system size
> + * 2. we have a requested address, and it is page-aligned, and we will
> + * be discarding the address if we get a different one.
> + *
> + * for all other cases, alignment is potentially necessary.
> */
> no_align = (requested_addr != NULL &&
> - ((uintptr_t)requested_addr & (page_sz - 1))) ||
> + requested_addr == RTE_PTR_ALIGN(requested_addr, page_sz)
> &&
> + !addr_is_hint) ||
> page_sz == system_page_sz;
>
> do {
> --
> 2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] mem: fix alignment of requested virtual areas
2018-07-17 9:48 ` Stojaczyk, DariuszX
@ 2018-07-18 21:23 ` Thomas Monjalon
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2018-07-18 21:23 UTC (permalink / raw)
To: Burakov, Anatoly; +Cc: dev, Stojaczyk, DariuszX, Yao, Lei A, stable
17/07/2018 11:48, Stojaczyk, DariuszX:
> From: Burakov, Anatoly
> >
> > The original code did not align any addresses that were requested as
> > page-aligned, but were different because addr_is_hint was set.
> >
> > Below fix by Dariusz has introduced an issue where all unaligned addresses
> > were left as unaligned.
> >
> > This patch is a partial revert of
> > commit 7fa7216ed48d ("mem: fix alignment of requested virtual areas")
> >
> > and implements a proper fix for this issue, by asking for alignment in all
> > but the following two cases:
> >
> > 1) page size is equal to system page size, or
> > 2) we got an aligned requested address, and will not accept a different one
> >
> > This ensures that alignment is performed in all cases, except for those we
> > can guarantee that the address will not need alignment.
> >
> > Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory")
> > Fixes: 7fa7216ed48d ("mem: fix alignment of requested virtual areas")
> > Cc: dariuszx.stojaczyk@intel.com
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>
> Acked-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-18 21:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-16 14:57 [dpdk-stable] [PATCH] mem: fix alignment of requested virtual areas Anatoly Burakov
2018-07-16 15:20 ` Yao, Lei A
2018-07-17 9:48 ` Stojaczyk, DariuszX
2018-07-18 21:23 ` [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).