[2/2] vhost: fix build error caused by 64bit print formatting
Checks
Commit Message
Use of %llx print formatting causes meson build error on Power systems with
RHEL 7.6 and gcc 4.8.5. Replace with PRIx64 macro.
Fixes: 9b62e2da1844 (vhost: register new regions with userfaultfd)
Cc: maxime.coquelin@redhat.com
Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
---
lib/librte_vhost/vhost_user.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Comments
On Wed, Aug 14, 2019 at 8:37 PM David Christensen
<drc@linux.vnet.ibm.com> wrote:
>
> Use of %llx print formatting causes meson build error on Power systems with
> RHEL 7.6 and gcc 4.8.5. Replace with PRIx64 macro.
>
> Fixes: 9b62e2da1844 (vhost: register new regions with userfaultfd)
> Cc: maxime.coquelin@redhat.com
>
> Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
> ---
> lib/librte_vhost/vhost_user.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 0b72648..6a6d694 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -1086,10 +1086,11 @@
> goto err_mmap;
> }
> RTE_LOG(INFO, VHOST_CONFIG,
> - "\t userfaultfd registered for range : %llx - %llx\n",
> - reg_struct.range.start,
> - reg_struct.range.start +
> - reg_struct.range.len - 1);
> + "\t userfaultfd registered for range : "
> + "%" PRIx64 " - %" PRIx64 "\n",
> + (uint64_t)reg_struct.range.start,
> + (uint64_t)reg_struct.range.start +
> + (uint64_t)reg_struct.range.len - 1);
struct uffdio_register {
struct uffdio_range range;
...
struct uffdio_range {
__u64 start;
__u64 len;
};
You can drop those casts.
>> Use of %llx print formatting causes meson build error on Power systems with
>> RHEL 7.6 and gcc 4.8.5. Replace with PRIx64 macro.
>>
>> + (uint64_t)reg_struct.range.start,
>> + (uint64_t)reg_struct.range.start +
>> + (uint64_t)reg_struct.range.len - 1);
I didn't need them when compiling on Power but it's the only way I could
get x86 to build without any warning:
cc -Ilib/lib@@rte_vhost@sta -Ilib -I../lib -Ilib/librte_vhost
-I../lib/librte_vhost -I. -I../ -Iconfig -I../config
-Ilib/librte_eal/common/include -I../lib/librte_eal/common/include
-I../lib/librte_eal/linux/eal/include -Ilib/librte_eal/common
-I../lib/librte_eal/common -Ilib/librte_eal/common/include/arch/x86
-I../lib/librte_eal/common/include/arch/x86 -Ilib/librte_eal
-I../lib/librte_eal -Ilib/librte_kvargs -I../lib/librte_kvargs
-Ilib/librte_ethdev -I../lib/librte_ethdev -Ilib/librte_net
-I../lib/librte_net -Ilib/librte_mbuf -I../lib/librte_mbuf
-Ilib/librte_mempool -I../lib/librte_mempool -Ilib/librte_ring
-I../lib/librte_ring -Ilib/librte_meter -I../lib/librte_meter
-Ilib/librte_cryptodev -I../lib/librte_cryptodev -Ilib/librte_hash
-I../lib/librte_hash -Ilib/librte_pci -I../lib/librte_pci -pipe
-D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O3 -include rte_config.h
-Wunused-parameter -Wsign-compare -Wcast-qual -D_GNU_SOURCE -fPIC
-march=native -fno-strict-aliasing -DALLOW_EXPERIMENTAL_API -MD -MQ
'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o' -MF
'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o.d' -o
'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o' -c
../lib/librte_vhost/vhost_user.c
../lib/librte_vhost/vhost_user.c: In function ‘vhost_user_set_mem_table’:
../lib/librte_vhost/vhost_user.c:1088:4: warning: format ‘%lx’ expects
argument of type ‘long unsigned int’, but argument 4 has type ‘__u64’
[-Wformat=]
RTE_LOG(INFO, VHOST_CONFIG,
^
../lib/librte_vhost/vhost_user.c:1088:4: warning: format ‘%lx’ expects
argument of type ‘long unsigned int’, but argument 5 has type ‘__u64’
[-Wformat=]
This system was also RHEL 7.6 with gcc 4.8.5-36
Dave
On Thu, Aug 15, 2019 at 6:16 PM David Christensen
<drc@linux.vnet.ibm.com> wrote:
>
> >> Use of %llx print formatting causes meson build error on Power systems with
> >> RHEL 7.6 and gcc 4.8.5. Replace with PRIx64 macro.
> >>
> >> + (uint64_t)reg_struct.range.start,
> >> + (uint64_t)reg_struct.range.start +
> >> + (uint64_t)reg_struct.range.len - 1);
>
> I didn't need them when compiling on Power but it's the only way I could
> get x86 to build without any warning:
>
> cc -Ilib/lib@@rte_vhost@sta -Ilib -I../lib -Ilib/librte_vhost
> -I../lib/librte_vhost -I. -I../ -Iconfig -I../config
> -Ilib/librte_eal/common/include -I../lib/librte_eal/common/include
> -I../lib/librte_eal/linux/eal/include -Ilib/librte_eal/common
> -I../lib/librte_eal/common -Ilib/librte_eal/common/include/arch/x86
> -I../lib/librte_eal/common/include/arch/x86 -Ilib/librte_eal
> -I../lib/librte_eal -Ilib/librte_kvargs -I../lib/librte_kvargs
> -Ilib/librte_ethdev -I../lib/librte_ethdev -Ilib/librte_net
> -I../lib/librte_net -Ilib/librte_mbuf -I../lib/librte_mbuf
> -Ilib/librte_mempool -I../lib/librte_mempool -Ilib/librte_ring
> -I../lib/librte_ring -Ilib/librte_meter -I../lib/librte_meter
> -Ilib/librte_cryptodev -I../lib/librte_cryptodev -Ilib/librte_hash
> -I../lib/librte_hash -Ilib/librte_pci -I../lib/librte_pci -pipe
> -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O3 -include rte_config.h
> -Wunused-parameter -Wsign-compare -Wcast-qual -D_GNU_SOURCE -fPIC
> -march=native -fno-strict-aliasing -DALLOW_EXPERIMENTAL_API -MD -MQ
> 'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o' -MF
> 'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o.d' -o
> 'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o' -c
> ../lib/librte_vhost/vhost_user.c
> ../lib/librte_vhost/vhost_user.c: In function ‘vhost_user_set_mem_table’:
> ../lib/librte_vhost/vhost_user.c:1088:4: warning: format ‘%lx’ expects
> argument of type ‘long unsigned int’, but argument 4 has type ‘__u64’
> [-Wformat=]
> RTE_LOG(INFO, VHOST_CONFIG,
> ^
> ../lib/librte_vhost/vhost_user.c:1088:4: warning: format ‘%lx’ expects
> argument of type ‘long unsigned int’, but argument 5 has type ‘__u64’
> [-Wformat=]
>
> This system was also RHEL 7.6 with gcc 4.8.5-36
Ok, I run the same.
The catch is that I did not have RTE_LIBRTE_VHOST_POSTCOPY enabled in
my working environment (using make) while meson enables it as long as
userfaultd.h is present.
Maxime, Tiwei,
Can't we use uintXX_t instead of (what looks to me) kernel types __uXX ?
On 8/19/19 10:40 AM, David Marchand wrote:
> On Thu, Aug 15, 2019 at 6:16 PM David Christensen
> <drc@linux.vnet.ibm.com> wrote:
>>
>>>> Use of %llx print formatting causes meson build error on Power systems with
>>>> RHEL 7.6 and gcc 4.8.5. Replace with PRIx64 macro.
>>>>
>>>> + (uint64_t)reg_struct.range.start,
>>>> + (uint64_t)reg_struct.range.start +
>>>> + (uint64_t)reg_struct.range.len - 1);
>>
>> I didn't need them when compiling on Power but it's the only way I could
>> get x86 to build without any warning:
>>
>> cc -Ilib/lib@@rte_vhost@sta -Ilib -I../lib -Ilib/librte_vhost
>> -I../lib/librte_vhost -I. -I../ -Iconfig -I../config
>> -Ilib/librte_eal/common/include -I../lib/librte_eal/common/include
>> -I../lib/librte_eal/linux/eal/include -Ilib/librte_eal/common
>> -I../lib/librte_eal/common -Ilib/librte_eal/common/include/arch/x86
>> -I../lib/librte_eal/common/include/arch/x86 -Ilib/librte_eal
>> -I../lib/librte_eal -Ilib/librte_kvargs -I../lib/librte_kvargs
>> -Ilib/librte_ethdev -I../lib/librte_ethdev -Ilib/librte_net
>> -I../lib/librte_net -Ilib/librte_mbuf -I../lib/librte_mbuf
>> -Ilib/librte_mempool -I../lib/librte_mempool -Ilib/librte_ring
>> -I../lib/librte_ring -Ilib/librte_meter -I../lib/librte_meter
>> -Ilib/librte_cryptodev -I../lib/librte_cryptodev -Ilib/librte_hash
>> -I../lib/librte_hash -Ilib/librte_pci -I../lib/librte_pci -pipe
>> -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O3 -include rte_config.h
>> -Wunused-parameter -Wsign-compare -Wcast-qual -D_GNU_SOURCE -fPIC
>> -march=native -fno-strict-aliasing -DALLOW_EXPERIMENTAL_API -MD -MQ
>> 'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o' -MF
>> 'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o.d' -o
>> 'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o' -c
>> ../lib/librte_vhost/vhost_user.c
>> ../lib/librte_vhost/vhost_user.c: In function ‘vhost_user_set_mem_table’:
>> ../lib/librte_vhost/vhost_user.c:1088:4: warning: format ‘%lx’ expects
>> argument of type ‘long unsigned int’, but argument 4 has type ‘__u64’
>> [-Wformat=]
>> RTE_LOG(INFO, VHOST_CONFIG,
>> ^
>> ../lib/librte_vhost/vhost_user.c:1088:4: warning: format ‘%lx’ expects
>> argument of type ‘long unsigned int’, but argument 5 has type ‘__u64’
>> [-Wformat=]
>>
>> This system was also RHEL 7.6 with gcc 4.8.5-36
>
> Ok, I run the same.
> The catch is that I did not have RTE_LIBRTE_VHOST_POSTCOPY enabled in
> my working environment (using make) while meson enables it as long as
> userfaultd.h is present.
>
> Maxime, Tiwei,
>
> Can't we use uintXX_t instead of (what looks to me) kernel types __uXX ?
>
>
That actually comes from a kernel header (linux/userfaultfd.h), so I
would say no.
On Mon, Aug 19, 2019 at 1:41 PM Maxime Coquelin
<maxime.coquelin@redhat.com> wrote:
> On 8/19/19 10:40 AM, David Marchand wrote:
> > On Thu, Aug 15, 2019 at 6:16 PM David Christensen
> > <drc@linux.vnet.ibm.com> wrote:
> >>
> >>>> Use of %llx print formatting causes meson build error on Power systems with
> >>>> RHEL 7.6 and gcc 4.8.5. Replace with PRIx64 macro.
> >>>>
> >>>> + (uint64_t)reg_struct.range.start,
> >>>> + (uint64_t)reg_struct.range.start +
> >>>> + (uint64_t)reg_struct.range.len - 1);
> >>
> >> I didn't need them when compiling on Power but it's the only way I could
> >> get x86 to build without any warning:
> >>
> >> cc -Ilib/lib@@rte_vhost@sta -Ilib -I../lib -Ilib/librte_vhost
> >> -I../lib/librte_vhost -I. -I../ -Iconfig -I../config
> >> -Ilib/librte_eal/common/include -I../lib/librte_eal/common/include
> >> -I../lib/librte_eal/linux/eal/include -Ilib/librte_eal/common
> >> -I../lib/librte_eal/common -Ilib/librte_eal/common/include/arch/x86
> >> -I../lib/librte_eal/common/include/arch/x86 -Ilib/librte_eal
> >> -I../lib/librte_eal -Ilib/librte_kvargs -I../lib/librte_kvargs
> >> -Ilib/librte_ethdev -I../lib/librte_ethdev -Ilib/librte_net
> >> -I../lib/librte_net -Ilib/librte_mbuf -I../lib/librte_mbuf
> >> -Ilib/librte_mempool -I../lib/librte_mempool -Ilib/librte_ring
> >> -I../lib/librte_ring -Ilib/librte_meter -I../lib/librte_meter
> >> -Ilib/librte_cryptodev -I../lib/librte_cryptodev -Ilib/librte_hash
> >> -I../lib/librte_hash -Ilib/librte_pci -I../lib/librte_pci -pipe
> >> -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O3 -include rte_config.h
> >> -Wunused-parameter -Wsign-compare -Wcast-qual -D_GNU_SOURCE -fPIC
> >> -march=native -fno-strict-aliasing -DALLOW_EXPERIMENTAL_API -MD -MQ
> >> 'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o' -MF
> >> 'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o.d' -o
> >> 'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o' -c
> >> ../lib/librte_vhost/vhost_user.c
> >> ../lib/librte_vhost/vhost_user.c: In function ‘vhost_user_set_mem_table’:
> >> ../lib/librte_vhost/vhost_user.c:1088:4: warning: format ‘%lx’ expects
> >> argument of type ‘long unsigned int’, but argument 4 has type ‘__u64’
> >> [-Wformat=]
> >> RTE_LOG(INFO, VHOST_CONFIG,
> >> ^
> >> ../lib/librte_vhost/vhost_user.c:1088:4: warning: format ‘%lx’ expects
> >> argument of type ‘long unsigned int’, but argument 5 has type ‘__u64’
> >> [-Wformat=]
> >>
> >> This system was also RHEL 7.6 with gcc 4.8.5-36
> >
> > Ok, I run the same.
> > The catch is that I did not have RTE_LIBRTE_VHOST_POSTCOPY enabled in
> > my working environment (using make) while meson enables it as long as
> > userfaultd.h is present.
> >
> > Maxime, Tiwei,
> >
> > Can't we use uintXX_t instead of (what looks to me) kernel types __uXX ?
> >
> >
>
> That actually comes from a kernel header (linux/userfaultfd.h), so I
> would say no.
Sorry, I had forgotten about this patch.
Seems fine to me then.
Maxime, Tiwei?
On Thu, Oct 24, 2019 at 09:27:38PM +0200, David Marchand wrote:
> On Mon, Aug 19, 2019 at 1:41 PM Maxime Coquelin
> <maxime.coquelin@redhat.com> wrote:
> > On 8/19/19 10:40 AM, David Marchand wrote:
> > > On Thu, Aug 15, 2019 at 6:16 PM David Christensen
> > > <drc@linux.vnet.ibm.com> wrote:
> > >>
> > >>>> Use of %llx print formatting causes meson build error on Power systems with
> > >>>> RHEL 7.6 and gcc 4.8.5. Replace with PRIx64 macro.
> > >>>>
> > >>>> + (uint64_t)reg_struct.range.start,
> > >>>> + (uint64_t)reg_struct.range.start +
> > >>>> + (uint64_t)reg_struct.range.len - 1);
> > >>
> > >> I didn't need them when compiling on Power but it's the only way I could
> > >> get x86 to build without any warning:
> > >>
> > >> cc -Ilib/lib@@rte_vhost@sta -Ilib -I../lib -Ilib/librte_vhost
> > >> -I../lib/librte_vhost -I. -I../ -Iconfig -I../config
> > >> -Ilib/librte_eal/common/include -I../lib/librte_eal/common/include
> > >> -I../lib/librte_eal/linux/eal/include -Ilib/librte_eal/common
> > >> -I../lib/librte_eal/common -Ilib/librte_eal/common/include/arch/x86
> > >> -I../lib/librte_eal/common/include/arch/x86 -Ilib/librte_eal
> > >> -I../lib/librte_eal -Ilib/librte_kvargs -I../lib/librte_kvargs
> > >> -Ilib/librte_ethdev -I../lib/librte_ethdev -Ilib/librte_net
> > >> -I../lib/librte_net -Ilib/librte_mbuf -I../lib/librte_mbuf
> > >> -Ilib/librte_mempool -I../lib/librte_mempool -Ilib/librte_ring
> > >> -I../lib/librte_ring -Ilib/librte_meter -I../lib/librte_meter
> > >> -Ilib/librte_cryptodev -I../lib/librte_cryptodev -Ilib/librte_hash
> > >> -I../lib/librte_hash -Ilib/librte_pci -I../lib/librte_pci -pipe
> > >> -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O3 -include rte_config.h
> > >> -Wunused-parameter -Wsign-compare -Wcast-qual -D_GNU_SOURCE -fPIC
> > >> -march=native -fno-strict-aliasing -DALLOW_EXPERIMENTAL_API -MD -MQ
> > >> 'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o' -MF
> > >> 'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o.d' -o
> > >> 'lib/lib@@rte_vhost@sta/librte_vhost_vhost_user.c.o' -c
> > >> ../lib/librte_vhost/vhost_user.c
> > >> ../lib/librte_vhost/vhost_user.c: In function ‘vhost_user_set_mem_table’:
> > >> ../lib/librte_vhost/vhost_user.c:1088:4: warning: format ‘%lx’ expects
> > >> argument of type ‘long unsigned int’, but argument 4 has type ‘__u64’
> > >> [-Wformat=]
> > >> RTE_LOG(INFO, VHOST_CONFIG,
> > >> ^
> > >> ../lib/librte_vhost/vhost_user.c:1088:4: warning: format ‘%lx’ expects
> > >> argument of type ‘long unsigned int’, but argument 5 has type ‘__u64’
> > >> [-Wformat=]
> > >>
> > >> This system was also RHEL 7.6 with gcc 4.8.5-36
> > >
> > > Ok, I run the same.
> > > The catch is that I did not have RTE_LIBRTE_VHOST_POSTCOPY enabled in
> > > my working environment (using make) while meson enables it as long as
> > > userfaultd.h is present.
> > >
> > > Maxime, Tiwei,
> > >
> > > Can't we use uintXX_t instead of (what looks to me) kernel types __uXX ?
> > >
> > >
> >
> > That actually comes from a kernel header (linux/userfaultfd.h), so I
> > would say no.
>
> Sorry, I had forgotten about this patch.
> Seems fine to me then.
> Maxime, Tiwei?
LGTM as well.
>
>
> --
> David Marchand
On Wed, Aug 14, 2019 at 01:36:41PM -0500, David Christensen wrote:
> Use of %llx print formatting causes meson build error on Power systems with
> RHEL 7.6 and gcc 4.8.5. Replace with PRIx64 macro.
>
> Fixes: 9b62e2da1844 (vhost: register new regions with userfaultfd)
> Cc: maxime.coquelin@redhat.com
>
> Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
> ---
> lib/librte_vhost/vhost_user.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 0b72648..6a6d694 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -1086,10 +1086,11 @@
> goto err_mmap;
> }
> RTE_LOG(INFO, VHOST_CONFIG,
> - "\t userfaultfd registered for range : %llx - %llx\n",
> - reg_struct.range.start,
> - reg_struct.range.start +
> - reg_struct.range.len - 1);
> + "\t userfaultfd registered for range : "
> + "%" PRIx64 " - %" PRIx64 "\n",
> + (uint64_t)reg_struct.range.start,
> + (uint64_t)reg_struct.range.start +
> + (uint64_t)reg_struct.range.len - 1);
> #else
> goto err_mmap;
> #endif
> --
> 1.8.3.1
>
Cc: stable@dpdk.org
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
Thanks,
Tiwei
On Fri, Oct 25, 2019 at 6:41 AM Tiwei Bie <tiwei.bie@intel.com> wrote:
>
> On Wed, Aug 14, 2019 at 01:36:41PM -0500, David Christensen wrote:
> > Use of %llx print formatting causes meson build error on Power systems with
> > RHEL 7.6 and gcc 4.8.5. Replace with PRIx64 macro.
> >
> > Fixes: 9b62e2da1844 (vhost: register new regions with userfaultfd)
> Cc: stable@dpdk.org
> >
> > Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
>
> Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
Applied, thanks.
--
David Marchand
@@ -1086,10 +1086,11 @@
goto err_mmap;
}
RTE_LOG(INFO, VHOST_CONFIG,
- "\t userfaultfd registered for range : %llx - %llx\n",
- reg_struct.range.start,
- reg_struct.range.start +
- reg_struct.range.len - 1);
+ "\t userfaultfd registered for range : "
+ "%" PRIx64 " - %" PRIx64 "\n",
+ (uint64_t)reg_struct.range.start,
+ (uint64_t)reg_struct.range.start +
+ (uint64_t)reg_struct.range.len - 1);
#else
goto err_mmap;
#endif