[2/2] mempool: use rte constant macro instead of GCC builtin
Checks
Commit Message
Use newly introduced __rte_constant(e) macro instead of directly using
__builtin_constant_p() allowing mempool to be built by MSVC.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
lib/mempool/rte_mempool.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
Comments
> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> Sent: Wednesday, 20 March 2024 22.34
>
> Use newly introduced __rte_constant(e) macro instead of directly using
> __builtin_constant_p() allowing mempool to be built by MSVC.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
On 3/26/24 12:57, Morten Brørup wrote:
>> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
>> Sent: Wednesday, 20 March 2024 22.34
>>
>> Use newly introduced __rte_constant(e) macro instead of directly using
>> __builtin_constant_p() allowing mempool to be built by MSVC.
>>
>> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
>> ---
>
> Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
20/03/2024 22:33, Tyler Retzlaff:
> Use newly introduced __rte_constant(e) macro instead of directly using
> __builtin_constant_p() allowing mempool to be built by MSVC.
Does it mean we should enable mempool build?
If yes, please send a v2.
On Wed, May 29, 2024 at 4:51 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 20/03/2024 22:33, Tyler Retzlaff:
> > Use newly introduced __rte_constant(e) macro instead of directly using
> > __builtin_constant_p() allowing mempool to be built by MSVC.
>
> Does it mean we should enable mempool build?
> If yes, please send a v2.
I guess now it is possible, as I merged some other patches on mempool
from Stephen that were for MSVC.
Tyler, can you send a v2 so it passes through the CI?
Thanks.
14/06/2024 16:32, David Marchand:
> On Wed, May 29, 2024 at 4:51 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> >
> > 20/03/2024 22:33, Tyler Retzlaff:
> > > Use newly introduced __rte_constant(e) macro instead of directly using
> > > __builtin_constant_p() allowing mempool to be built by MSVC.
> >
> > Does it mean we should enable mempool build?
> > If yes, please send a v2.
>
> I guess now it is possible, as I merged some other patches on mempool
> from Stephen that were for MSVC.
> Tyler, can you send a v2 so it passes through the CI?
I tried a retest last week and there is this failure on Ubuntu 24.04
that I don't manage to reproduce locally:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: error: argument 2 null where non-null expected [-Werror=nonnull]
29 | return __builtin___memcpy_chk (__dest, __src, __len,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30 | __glibc_objsize0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: note: in a call to built-in function '__builtin___memcpy_chk'
In function 'memcpy',
inlined from 'pcapng_add_option' at ../lib/pcapng/rte_pcapng.c:131:2,
inlined from 'rte_pcapng_write_stats' at ../lib/pcapng/rte_pcapng.c:371:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: error: argument 2 null where non-null expected [-Werror=nonnull]
29 | return __builtin___memcpy_chk (__dest, __src, __len,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30 | __glibc_objsize0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: note: in a call to built-in function '__builtin___memcpy_chk'
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Wednesday, 3 July 2024 15.17
>
> 14/06/2024 16:32, David Marchand:
> > On Wed, May 29, 2024 at 4:51 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> > >
> > > 20/03/2024 22:33, Tyler Retzlaff:
> > > > Use newly introduced __rte_constant(e) macro instead of directly using
> > > > __builtin_constant_p() allowing mempool to be built by MSVC.
> > >
> > > Does it mean we should enable mempool build?
> > > If yes, please send a v2.
> >
> > I guess now it is possible, as I merged some other patches on mempool
> > from Stephen that were for MSVC.
> > Tyler, can you send a v2 so it passes through the CI?
>
> I tried a retest last week and there is this failure on Ubuntu 24.04
> that I don't manage to reproduce locally:
>
> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: error: argument 2
> null where non-null expected [-Werror=nonnull]
> 29 | return __builtin___memcpy_chk (__dest, __src, __len,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 30 | __glibc_objsize0 (__dest));
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: note: in a call
> to built-in function '__builtin___memcpy_chk'
> In function 'memcpy',
> inlined from 'pcapng_add_option' at ../lib/pcapng/rte_pcapng.c:131:2,
pcapng_add_option() in rte_pcapng.c has memcpy() on line 132 [1] (and has a fix for this error, by comparing len > 0 before calling memcpy()); older versions had memcpy() on line 131, so the CI must be building with an older version of rte_pcapng.c.
[1]: https://elixir.bootlin.com/dpdk/v24.07-rc1/source/lib/pcapng/rte_pcapng.c#L132
[2]: https://elixir.bootlin.com/dpdk/v24.03/source/lib/pcapng/rte_pcapng.c#L131
> inlined from 'rte_pcapng_write_stats' at ../lib/pcapng/rte_pcapng.c:371:9:
> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: error: argument 2
> null where non-null expected [-Werror=nonnull]
> 29 | return __builtin___memcpy_chk (__dest, __src, __len,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 30 | __glibc_objsize0 (__dest));
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: note: in a call
> to built-in function '__builtin___memcpy_chk'
>
>
On Wed, Jul 3, 2024 at 3:49 PM Morten Brørup <mb@smartsharesystems.com> wrote:
>
> > From: Thomas Monjalon [mailto:thomas@monjalon.net]
> > Sent: Wednesday, 3 July 2024 15.17
> >
> > 14/06/2024 16:32, David Marchand:
> > > On Wed, May 29, 2024 at 4:51 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> > > >
> > > > 20/03/2024 22:33, Tyler Retzlaff:
> > > > > Use newly introduced __rte_constant(e) macro instead of directly using
> > > > > __builtin_constant_p() allowing mempool to be built by MSVC.
> > > >
> > > > Does it mean we should enable mempool build?
> > > > If yes, please send a v2.
> > >
> > > I guess now it is possible, as I merged some other patches on mempool
> > > from Stephen that were for MSVC.
> > > Tyler, can you send a v2 so it passes through the CI?
> >
> > I tried a retest last week and there is this failure on Ubuntu 24.04
> > that I don't manage to reproduce locally:
> >
> > /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: error: argument 2
> > null where non-null expected [-Werror=nonnull]
> > 29 | return __builtin___memcpy_chk (__dest, __src, __len,
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 30 | __glibc_objsize0 (__dest));
> > | ~~~~~~~~~~~~~~~~~~~~~~~~~~
> > /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:10: note: in a call
> > to built-in function '__builtin___memcpy_chk'
> > In function 'memcpy',
> > inlined from 'pcapng_add_option' at ../lib/pcapng/rte_pcapng.c:131:2,
>
> pcapng_add_option() in rte_pcapng.c has memcpy() on line 132 [1] (and has a fix for this error, by comparing len > 0 before calling memcpy()); older versions had memcpy() on line 131, so the CI must be building with an older version of rte_pcapng.c.
>
> [1]: https://elixir.bootlin.com/dpdk/v24.07-rc1/source/lib/pcapng/rte_pcapng.c#L132
> [2]: https://elixir.bootlin.com/dpdk/v24.03/source/lib/pcapng/rte_pcapng.c#L131
This is likely the reason.
Looking at the report:
http://mails.dpdk.org/archives/test-report/2024-June/717951.html
_Testing issues RETEST #1_
Submitter: Tyler Retzlaff <roretzla at linux.microsoft.com>
Date: Wednesday, March 20 2024 21:33:36
DPDK git baseline: Repo:dpdk
Branch: master
CommitID:80ecef6d1f71fcebc0a51d7cabc51f73ee142ff2
$ git describe --contains 80ecef6d1f71fcebc0a51d7cabc51f73ee142ff2
v24.03-rc3^0
From the discussions on the retest mechanism, I understand we need to
ask for a rebase.
I sent a new retest. Let's see...
On Wed, Jul 3, 2024 at 10:22 AM David Marchand
<david.marchand@redhat.com> wrote:
>
>
>
> From the discussions on the retest mechanism, I understand we need to
> ask for a rebase.
> I sent a new retest. Let's see...
>
Hi,
That makes sense that we need to re-apply on the latest mainline and
retest. But, the "rebase" feature for rechecks which you are referring
to is still in development. So, unfortunately your request won't work
with the automated system - it's just going to recheck from the DPDK
artifact created in March when Tyler originally submitted the series.
For now, I can manually trigger a job in our CI platform which will
re-apply Tyler's patch to the up to date tree, and rerun all testing.
Thanks!
@@ -1521,7 +1521,7 @@ struct rte_mempool_cache *
/* The cache is a stack, so copy will be in reverse order. */
cache_objs = &cache->objs[cache->len];
- if (__extension__(__builtin_constant_p(n)) && n <= cache->len) {
+ if (__rte_constant(n) && n <= cache->len) {
/*
* The request size is known at build time, and
* the entire request can be satisfied from the cache,
@@ -1542,8 +1542,7 @@ struct rte_mempool_cache *
* If the request size 'n' is known at build time, the above comparison
* ensures that n > cache->len here, so omit RTE_MIN().
*/
- len = __extension__(__builtin_constant_p(n)) ? cache->len :
- RTE_MIN(n, cache->len);
+ len = __rte_constant(n) ? cache->len : RTE_MIN(n, cache->len);
cache->len -= len;
remaining = n - len;
for (index = 0; index < len; index++)
@@ -1554,7 +1553,7 @@ struct rte_mempool_cache *
* where the entire request can be satisfied from the cache
* has already been handled above, so omit handling it here.
*/
- if (!__extension__(__builtin_constant_p(n)) && remaining == 0) {
+ if (!__rte_constant(n) && remaining == 0) {
/* The entire request is satisfied from the cache. */
RTE_MEMPOOL_CACHE_STAT_ADD(cache, get_success_bulk, 1);