<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Oct 1, 2026 at 10:19 AM David Marchand <<a href="mailto:david.marchand@redhat.com">david.marchand@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, 30 Sept 2026 at 17:37, Maxime Coquelin<br>
<<a href="mailto:maxime.coquelin@redhat.com" target="_blank">maxime.coquelin@redhat.com</a>> wrote:<br>
> On Wed, Sep 30, 2026 at 5:26 PM Stephen Hemminger <<a href="mailto:stephen@networkplumber.org" target="_blank">stephen@networkplumber.org</a>> wrote:<br>
>><br>
>> On Wed, 30 Sep 2026 11:57:59 +0200<br>
>> Maxime Coquelin <<a href="mailto:maxime.coquelin@redhat.com" target="_blank">maxime.coquelin@redhat.com</a>> wrote:<br>
>><br>
>> > This patch adds a compatibility define for __counted_by attribute,<br>
>> > which is not present in older compilers but required for recent UAPI<br>
>> > headers like vfio.h.<br>
>> ><br>
>> > Signed-off-by: Maxime Coquelin <<a href="mailto:maxime.coquelin@redhat.com" target="_blank">maxime.coquelin@redhat.com</a>><br>
>> > ---<br>
>> > config/rte_config.h | 9 +++++++++<br>
>> > 1 file changed, 9 insertions(+)<br>
>> ><br>
>> > diff --git a/config/rte_config.h b/config/rte_config.h<br>
>> > index 0447cdf2ad..307e7dac62 100644<br>
>> > --- a/config/rte_config.h<br>
>> > +++ b/config/rte_config.h<br>
>> > @@ -25,6 +25,15 @@<br>
>> > #define RTE_TOOLCHAIN_MSVC 1<br>
>> > #endif<br>
>> ><br>
>> > +/*<br>
>> > + * Compatibility define for Linux kernel UAPI headers that may use __counted_by<br>
>> > + * attribute for bounds checking. This attribute is not understood by userspace<br>
>> > + * compilers, so define it as empty if not already provided.<br>
>> > + */<br>
>> > +#ifndef __counted_by<br>
>> > +#define __counted_by(m)<br>
>> > +#endif<br>
>> > +<br>
>> > /* legacy defines */<br>
>> > #ifdef RTE_EXEC_ENV_LINUX<br>
>> > #define RTE_EXEC_ENV_LINUXAPP 1<br>
>><br>
>> NAK this is best done by keeping up to date stddef over in virtio headers.<br>
><br>
> This is for VFIO, not Virtio but that does not change the issue.<br>
><br>
> Problem is importing stddef in UAPI as currently done, does not work,<br>
> because the system version is included first so the imported one is discarded.<br>
><br>
> An alternative solution I tested would be to include the imported headers first,<br>
> but it means imported headers get silently intermixed, which worked in my test<br>
> but could lead to hard to debug issues.<br>
<br>
I don't like the alternative, for the reason you listed, plus the fact<br>
that this intermixing is invisible.<br>
At the moment, using an imported uapi header is opt-in, and I prefer<br>
it like this.<br>
<br>
<br>
> While not ideal, the solution proposed in this patch is harmless, we are talking<br>
> about an attribute defined as empty.<br>
<br>
Your solution of wrapping __counted_by is simple.<br>
<br>
On the other hand, fixing the existing import script would require<br>
relying on an external tool (unifef), which could be acceptable.<br></blockquote><div><br></div><div>Your solution is certainly more future-proof.</div><div>If others agree, can you send a series that supersedes mine so that we can get it merged early?</div><div>Eugenio will need to rebase his series on top of it.</div><div> </div><div>Thanks,</div><div>Maxime</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I tried some:<br>
<br>
diff --git a/devtools/linux-uapi.sh b/devtools/linux-uapi.sh<br>
index dbf3163bc8..189164928c 100755<br>
--- a/devtools/linux-uapi.sh<br>
+++ b/devtools/linux-uapi.sh<br>
@@ -13,6 +13,9 @@ file=""<br>
check_headers=false<br>
quiet=false<br>
<br>
+# Require unifdef<br>
+unifdef -h 2>&1 >/dev/null || { echo "This script requires unifdef."; exit 1; }<br>
+<br>
print_usage()<br>
{<br>
echo "Usage: $(basename $0) [-h] [-i FILE] [-u VERSION] [-c] [-q]"<br>
@@ -85,6 +88,9 @@ fixup_includes()<br>
sed -i 's|#\(define\)[[:space:]]*_UAPI|#\1 |' $path<br>
sed -i 's|#\(endif[[:space:]]*/[*]\)[[:space:]]*_UAPI|#\1 |' $path<br>
<br>
+ unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ -o ${path}.tmp<br>
$path || [ $? -lt 2 ]<br>
+ mv -f ${path}.tmp $path<br>
+<br>
# Prepend include path with "uapi/" if the header is imported<br>
for include in $(sed -ne 's/^#include <\(.*\)>$/\1/p' $path); do<br>
if [ -f "$base_path$include" ]; then<br>
diff --git a/doc/guides/contributing/linux_uapi.rst<br>
b/doc/guides/contributing/linux_uapi.rst<br>
index b8febfc420..a3490bfbb6 100644<br>
--- a/doc/guides/contributing/linux_uapi.rst<br>
+++ b/doc/guides/contributing/linux_uapi.rst<br>
@@ -27,6 +27,8 @@ Importing or updating an uAPI header file<br>
To ensure that imported uAPI headers are unmodified<br>
and sourced from an official Linux kernel release,<br>
a helper script is provided and must be used.<br>
+This script requires the ``unifdef`` tool.<br>
+<br>
Below is an example to import ``linux/vduse.h`` file from Linux ``v6.10``:<br>
<br>
.. code-block:: console<br>
<br>
<br>
Then imported linux/types.h, linux/posix_types.h and linux/stddef.h.<br>
<br>
And net/nbl needs some fixing... as it includes uapi/linux/vfio.h too late...<br>
Only occurence in the whole DPDK tree:<br>
$ git grep -l '# *include.*uapi' :^devtools/linux-uapi.sh<br>
:^doc/guides/contributing/linux_uapi.rst | while read file; do [ $(git<br>
grep -B100 '# *include.*uapi' $file | grep '# *include' | wc -l) = 1 ]<br>
|| echo $file; done<br>
drivers/net/nbl/nbl_common/nbl_userdev.c<br>
<br>
<br>
-- <br>
David Marchand<br>
<br>
</blockquote></div></div>