DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] eal/windows: fix memory management macros usage
@ 2023-11-14 17:05 Gregory Etelson
  2023-11-14 17:46 ` Tyler Retzlaff
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Gregory Etelson @ 2023-11-14 17:05 UTC (permalink / raw)
  To: dev
  Cc: getelson, mkashani, thomas, stable, Dmitry Kozlyuk,
	Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam

Windows compilation with cross-mingw on Fedora 39 failed
because MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER were
already defined in the compiler environment:

eal_memory.c:77: error: "MEM_REPLACE_PLACEHOLDER" redefined
/usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5710: note:
this is the location of the previous definition

eal_memory.c:78: error: "MEM_RESERVE_PLACEHOLDER" redefined
/usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5715: note:
this is the location of the previous definition

The patch masks MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
macros if they were pre-defined by compiler.

The patch also masks MEM_COALESCE_PLACEHOLDERS and
MEM_PRESERVE_PLACEHOLDER to prevent similar errors.

Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")

Cc: stable@dpdk.org
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
 lib/eal/windows/eal_memory.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/eal/windows/eal_memory.c b/lib/eal/windows/eal_memory.c
index 215d768e2c..31410a41fd 100644
--- a/lib/eal/windows/eal_memory.c
+++ b/lib/eal/windows/eal_memory.c
@@ -72,10 +72,18 @@ static VirtualAlloc2_type VirtualAlloc2_ptr;
 
 #ifdef RTE_TOOLCHAIN_GCC
 
+#ifndef MEM_COALESCE_PLACEHOLDERS
 #define MEM_COALESCE_PLACEHOLDERS 0x00000001
+#endif
+#ifndef MEM_PRESERVE_PLACEHOLDER
 #define MEM_PRESERVE_PLACEHOLDER  0x00000002
+#endif
+#ifndef MEM_REPLACE_PLACEHOLDER
 #define MEM_REPLACE_PLACEHOLDER   0x00004000
+#endif
+#ifndef MEM_RESERVE_PLACEHOLDER
 #define MEM_RESERVE_PLACEHOLDER   0x00040000
+#endif
 
 int
 eal_mem_win32api_init(void)
-- 
2.39.2


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

* Re: [PATCH] eal/windows: fix memory management macros usage
  2023-11-14 17:05 [PATCH] eal/windows: fix memory management macros usage Gregory Etelson
@ 2023-11-14 17:46 ` Tyler Retzlaff
  2023-11-14 18:16   ` Etelson, Gregory
  2023-11-14 19:19 ` Dmitry Kozlyuk
  2023-11-22 16:56 ` David Marchand
  2 siblings, 1 reply; 9+ messages in thread
From: Tyler Retzlaff @ 2023-11-14 17:46 UTC (permalink / raw)
  To: Gregory Etelson
  Cc: dev, mkashani, thomas, stable, Dmitry Kozlyuk,
	Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam

On Tue, Nov 14, 2023 at 07:05:29PM +0200, Gregory Etelson wrote:
> Windows compilation with cross-mingw on Fedora 39 failed
> because MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER were
> already defined in the compiler environment:
> 
> eal_memory.c:77: error: "MEM_REPLACE_PLACEHOLDER" redefined
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5710: note:
> this is the location of the previous definition
> 
> eal_memory.c:78: error: "MEM_RESERVE_PLACEHOLDER" redefined
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5715: note:
> this is the location of the previous definition
> 
> The patch masks MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
> macros if they were pre-defined by compiler.
> 
> The patch also masks MEM_COALESCE_PLACEHOLDERS and
> MEM_PRESERVE_PLACEHOLDER to prevent similar errors.
> 
> Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")
> 
> Cc: stable@dpdk.org
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> ---

since we are duplicating something that comes from something else that
has been duplicated out of windows WDK here it might be a reasonable
safety check to verify that our duplicated values match our
expectations?

#ifndef MEM_COALESCE_PLACEHOLDERS
#define MEM_COALESCE_PLACEHOLDERS 0x00000001
#else
static_assert(MEM_COALESCE_PLACEHOLDERS == 0x00000001, "...")
#endif

either way, this is straight forward.

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>


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

* Re: [PATCH] eal/windows: fix memory management macros usage
  2023-11-14 17:46 ` Tyler Retzlaff
@ 2023-11-14 18:16   ` Etelson, Gregory
  2023-11-14 18:22     ` Tyler Retzlaff
  0 siblings, 1 reply; 9+ messages in thread
From: Etelson, Gregory @ 2023-11-14 18:16 UTC (permalink / raw)
  To: Tyler Retzlaff
  Cc: Gregory Etelson, dev, mkashani, thomas, stable, Dmitry Kozlyuk,
	Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam

Hello Tyler,

>
> since we are duplicating something that comes from something else that
> has been duplicated out of windows WDK here it might be a reasonable
> safety check to verify that our duplicated values match our
> expectations?

MEM_COALESCE_PLACEHOLDERS, MEM_PRESERVE_PLACEHOLDER,
MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
are defined in Win32 API.

DPDK has no expectations about these values. DPDK needs them as parameters 
to the VirtualX function calls.
It looks like the macros were added to EAL because they were missing in 
mingw.

Once compiler environment was fixed, the proper order was restored.

Regards,
Gregory


>
> #ifndef MEM_COALESCE_PLACEHOLDERS
> #define MEM_COALESCE_PLACEHOLDERS 0x00000001
> #else
> static_assert(MEM_COALESCE_PLACEHOLDERS == 0x00000001, "...")
> #endif
>
> either way, this is straight forward.
>
> Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
>
>

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

* Re: [PATCH] eal/windows: fix memory management macros usage
  2023-11-14 18:16   ` Etelson, Gregory
@ 2023-11-14 18:22     ` Tyler Retzlaff
  2023-11-14 19:14       ` Etelson, Gregory
  2023-11-14 19:19       ` Dmitry Kozlyuk
  0 siblings, 2 replies; 9+ messages in thread
From: Tyler Retzlaff @ 2023-11-14 18:22 UTC (permalink / raw)
  To: Etelson, Gregory
  Cc: dev, mkashani, thomas, stable, Dmitry Kozlyuk,
	Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam

On Tue, Nov 14, 2023 at 08:16:22PM +0200, Etelson, Gregory wrote:
> Hello Tyler,
> 
> >
> >since we are duplicating something that comes from something else that
> >has been duplicated out of windows WDK here it might be a reasonable
> >safety check to verify that our duplicated values match our
> >expectations?
> 
> MEM_COALESCE_PLACEHOLDERS, MEM_PRESERVE_PLACEHOLDER,
> MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
> are defined in Win32 API.
> 
> DPDK has no expectations about these values. DPDK needs them as
> parameters to the VirtualX function calls.
> It looks like the macros were added to EAL because they were missing
> in mingw.
> 
> Once compiler environment was fixed, the proper order was restored.

yes, there is a lag between when names appear in the actual WDK and when
mingw takes a the snapshot of the headers. so long as the copy they take
is only from released WDK versions that align with an OS we shouldn't
expect the values to change but if the duplicated names in dpdk were
based upon an insider (preview version of SDK) value that later got changed
there could be a misalignment. unlikely but possible.

> 
> Regards,
> Gregory
> 
> 
> >
> >#ifndef MEM_COALESCE_PLACEHOLDERS
> >#define MEM_COALESCE_PLACEHOLDERS 0x00000001
> >#else
> >static_assert(MEM_COALESCE_PLACEHOLDERS == 0x00000001, "...")
> >#endif
> >
> >either way, this is straight forward.
> >
> >Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> >
> >

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

* Re: [PATCH] eal/windows: fix memory management macros usage
  2023-11-14 18:22     ` Tyler Retzlaff
@ 2023-11-14 19:14       ` Etelson, Gregory
  2023-11-14 19:19       ` Dmitry Kozlyuk
  1 sibling, 0 replies; 9+ messages in thread
From: Etelson, Gregory @ 2023-11-14 19:14 UTC (permalink / raw)
  To: Tyler Retzlaff
  Cc: Etelson, Gregory, dev, mkashani, thomas, stable, Dmitry Kozlyuk,
	Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam

Hello Tyler,

>>>
>>> since we are duplicating something that comes from something else that
>>> has been duplicated out of windows WDK here it might be a reasonable
>>> safety check to verify that our duplicated values match our
>>> expectations?
>>
>> MEM_COALESCE_PLACEHOLDERS, MEM_PRESERVE_PLACEHOLDER,
>> MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
>> are defined in Win32 API.
>>
>> DPDK has no expectations about these values. DPDK needs them as
>> parameters to the VirtualX function calls.
>> It looks like the macros were added to EAL because they were missing
>> in mingw.
>>
>> Once compiler environment was fixed, the proper order was restored.
>
> yes, there is a lag between when names appear in the actual WDK and when
> mingw takes a the snapshot of the headers. so long as the copy they take
> is only from released WDK versions that align with an OS we shouldn't
> expect the values to change but if the duplicated names in dpdk were
> based upon an insider (preview version of SDK) value that later got changed
> there could be a misalignment. unlikely but possible.
>

DPDK matrix works with official OS compiler versions.
Such compilers will not provide bad API.
As for non-official compilers or releases, they come without any warranty.

Regards,
Gregory

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

* Re: [PATCH] eal/windows: fix memory management macros usage
  2023-11-14 18:22     ` Tyler Retzlaff
  2023-11-14 19:14       ` Etelson, Gregory
@ 2023-11-14 19:19       ` Dmitry Kozlyuk
  1 sibling, 0 replies; 9+ messages in thread
From: Dmitry Kozlyuk @ 2023-11-14 19:19 UTC (permalink / raw)
  To: Tyler Retzlaff
  Cc: Etelson, Gregory, dev, mkashani, thomas, stable,
	Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam

2023-11-14 10:22 (UTC-0800), Tyler Retzlaff:
> On Tue, Nov 14, 2023 at 08:16:22PM +0200, Etelson, Gregory wrote:
> > Hello Tyler,
> >   
> > >
> > >since we are duplicating something that comes from something else that
> > >has been duplicated out of windows WDK here it might be a reasonable
> > >safety check to verify that our duplicated values match our
> > >expectations?  
> > 
> > MEM_COALESCE_PLACEHOLDERS, MEM_PRESERVE_PLACEHOLDER,
> > MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
> > are defined in Win32 API.
> > 
> > DPDK has no expectations about these values. DPDK needs them as
> > parameters to the VirtualX function calls.
> > It looks like the macros were added to EAL because they were missing
> > in mingw.
> > 
> > Once compiler environment was fixed, the proper order was restored.  
> 
> yes, there is a lag between when names appear in the actual WDK and when
> mingw takes a the snapshot of the headers. so long as the copy they take
> is only from released WDK versions that align with an OS we shouldn't
> expect the values to change but if the duplicated names in dpdk were
> based upon an insider (preview version of SDK) value that later got changed
> there could be a misalignment. unlikely but possible.

I think we should trust the toolchain unless there is an known bug,
i.e. the patch is good as-is.

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

* Re: [PATCH] eal/windows: fix memory management macros usage
  2023-11-14 17:05 [PATCH] eal/windows: fix memory management macros usage Gregory Etelson
  2023-11-14 17:46 ` Tyler Retzlaff
@ 2023-11-14 19:19 ` Dmitry Kozlyuk
  2023-11-22 16:47   ` Thomas Monjalon
  2023-11-22 16:56 ` David Marchand
  2 siblings, 1 reply; 9+ messages in thread
From: Dmitry Kozlyuk @ 2023-11-14 19:19 UTC (permalink / raw)
  To: Gregory Etelson
  Cc: dev, mkashani, thomas, stable, Narcisa Ana Maria Vasile,
	Dmitry Malloy, Pallavi Kadam

2023-11-14 19:05 (UTC+0200), Gregory Etelson:
> Windows compilation with cross-mingw on Fedora 39 failed
> because MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER were
> already defined in the compiler environment:
> 
> eal_memory.c:77: error: "MEM_REPLACE_PLACEHOLDER" redefined
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5710: note:
> this is the location of the previous definition
> 
> eal_memory.c:78: error: "MEM_RESERVE_PLACEHOLDER" redefined
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5715: note:
> this is the location of the previous definition
> 
> The patch masks MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
> macros if they were pre-defined by compiler.
> 
> The patch also masks MEM_COALESCE_PLACEHOLDERS and
> MEM_PRESERVE_PLACEHOLDER to prevent similar errors.
> 
> Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")
> 
> Cc: stable@dpdk.org
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>

Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>

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

* Re: [PATCH] eal/windows: fix memory management macros usage
  2023-11-14 19:19 ` Dmitry Kozlyuk
@ 2023-11-22 16:47   ` Thomas Monjalon
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Monjalon @ 2023-11-22 16:47 UTC (permalink / raw)
  To: Gregory Etelson
  Cc: dev, mkashani, stable, Narcisa Ana Maria Vasile, Dmitry Malloy,
	Pallavi Kadam, Dmitry Kozlyuk

14/11/2023 20:19, Dmitry Kozlyuk:
> 2023-11-14 19:05 (UTC+0200), Gregory Etelson:
> > Windows compilation with cross-mingw on Fedora 39 failed
> > because MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER were
> > already defined in the compiler environment:
> > 
> > eal_memory.c:77: error: "MEM_REPLACE_PLACEHOLDER" redefined
> > /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5710: note:
> > this is the location of the previous definition
> > 
> > eal_memory.c:78: error: "MEM_RESERVE_PLACEHOLDER" redefined
> > /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5715: note:
> > this is the location of the previous definition
> > 
> > The patch masks MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
> > macros if they were pre-defined by compiler.
> > 
> > The patch also masks MEM_COALESCE_PLACEHOLDERS and
> > MEM_PRESERVE_PLACEHOLDER to prevent similar errors.
> > 
> > Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")
> > 
> > Cc: stable@dpdk.org
> > Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> 
> Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>

Acked-by: Thomas Monjalon <thomas@monjalon.net>



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

* Re: [PATCH] eal/windows: fix memory management macros usage
  2023-11-14 17:05 [PATCH] eal/windows: fix memory management macros usage Gregory Etelson
  2023-11-14 17:46 ` Tyler Retzlaff
  2023-11-14 19:19 ` Dmitry Kozlyuk
@ 2023-11-22 16:56 ` David Marchand
  2 siblings, 0 replies; 9+ messages in thread
From: David Marchand @ 2023-11-22 16:56 UTC (permalink / raw)
  To: Gregory Etelson
  Cc: dev, mkashani, thomas, stable, Dmitry Kozlyuk,
	Narcisa Ana Maria Vasile, Dmitry Malloy, Pallavi Kadam,
	Bruce Richardson

On Tue, Nov 14, 2023 at 6:06 PM Gregory Etelson <getelson@nvidia.com> wrote:
>
> Windows compilation with cross-mingw on Fedora 39 failed
> because MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER were
> already defined in the compiler environment:
>
> eal_memory.c:77: error: "MEM_REPLACE_PLACEHOLDER" redefined
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5710: note:
> this is the location of the previous definition
>
> eal_memory.c:78: error: "MEM_RESERVE_PLACEHOLDER" redefined
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:5715: note:
> this is the location of the previous definition
>
> The patch masks MEM_REPLACE_PLACEHOLDER and MEM_RESERVE_PLACEHOLDER
> macros if they were pre-defined by compiler.
>
> The patch also masks MEM_COALESCE_PLACEHOLDERS and
> MEM_PRESERVE_PLACEHOLDER to prevent similar errors.
>
> Fixes: 2a5d547a4a9b ("eal/windows: implement basic memory management")
> Cc: stable@dpdk.org
>
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>

For the record, the same issue has been reported with Ubuntu 23.10.

Applied, thanks.


-- 
David Marchand


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

end of thread, other threads:[~2023-11-22 16:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-14 17:05 [PATCH] eal/windows: fix memory management macros usage Gregory Etelson
2023-11-14 17:46 ` Tyler Retzlaff
2023-11-14 18:16   ` Etelson, Gregory
2023-11-14 18:22     ` Tyler Retzlaff
2023-11-14 19:14       ` Etelson, Gregory
2023-11-14 19:19       ` Dmitry Kozlyuk
2023-11-14 19:19 ` Dmitry Kozlyuk
2023-11-22 16:47   ` Thomas Monjalon
2023-11-22 16:56 ` David Marchand

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).