On 12/20/22 15:38, Ilya Maximets wrote:
> On 12/20/22 14:14, Eelco Chaudron wrote:
>>
>>
>> On 20 Dec 2022, at 14:06, David Marchand wrote:
>>
>>> On Tue, Dec 20, 2022 at 2:01 PM Eelco Chaudron <[email protected]> wrote:
>>>> I have problems building this on my fedora35 system with 
>>>> gcc-11.3.1-3.fc35.x86_64:
>>>>
>>>> libtool: link: ( cd "include/openvswitch/.libs" && rm -f "libcxxtest.la" 
>>>> && ln -s "../libcxxtest.la" "libcxxtest.la" )
>>>> In file included from lib/netdev-linux-private.h:30,
>>>>                  from lib/netdev-afxdp.c:19:
>>>> In function ‘dp_packet_delete’,
>>>>     inlined from ‘dp_packet_delete’ at lib/dp-packet.h:246:1,
>>>>     inlined from ‘dp_packet_batch_add__’ at lib/dp-packet.h:775:9,
>>>>     inlined from ‘dp_packet_batch_add’ at lib/dp-packet.h:783:5,
>>>>     inlined from ‘netdev_afxdp_rxq_recv’ at lib/netdev-afxdp.c:894:9:
>>>> lib/dp-packet.h:260:9: error: ‘free’ called on pointer ‘*umem.xpool.array’ 
>>>> with nonzero offset [8, 2558044588346441168] [-Werror=free-nonheap-object]
>>>>   260 |         free(b);
>>>>       |         ^~~~~~~
>>>>
>>>> Guess it does not recognise the (b->source == DPBUF_AFXDP) statement…
>>>>
>>>> This is my build config:
>>>>
>>>> ./configure --enable-Werror --enable-usdt-probes --localstatedir=/var 
>>>> --prefix=/usr --sysconfdir=/etc --enable-afxdp
>>>>
>>>> Guess this should be fixed before we enable afxdp by default?
>>>
>>> Same for me.
>>> I have been scratching my head over this report... I wonder if this is
>>> a compiler bug.
>>
>> I guess the compiler does not understand that we will always call 
>> dp_packet_delete() with the source being DPBUF_AFXDP, and don’t hit the 
>> free().
>> Guess we should probably disable the warning in this specific code path.
>>
>> //Eelco
>>
> 
> Meanwhile I opened a GCC bug:
>   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108187

So, AFAICT, the issue is that implementation of the dp_packet_use_afxdp()
is part of a different translation unit (dp-packet.c) and GCC has no access
to it while processing netdev-afxdp.c, so it doesn't know that packet
source is set to DPBUF_AFXDP.  Hence the warning.  There are still a few
misteries around this, e.g. why the issue is not seen with -O0, but they
will likely not very important.

I don't see a good way to fix that.  We could inline a bunch of functions
from dp-packet.c, or explicitly set the source to DPBUF_AFXDP somewhere in
the realm of netdev-afxdp.c module, but I don't think that any of that is
a good solution.

I'll add a patch to disable the warning with #pragma GCC here around the
dp_packet_batch_add() call in netdev-afxdp.c for now, unless there are
better suggestions.  Clang doesn't emit this warning, so we don't need
to have a workaround for it.

Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to