Skip to contentSkip to conversation

aio-posix: fix build failure io_uring 2.2

PATCH Superseded Haiyue Wang 3 participants 9 messages Feb 17, 2022 – Feb 22, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aio-posix: fix build failure io_uring 2.2

The io_uring fixed "Don't truncate addr fields to 32-bit on 32-bit":
https://git.kernel.dk/cgit/liburing/commit/?id=d84c29b19ed0b130000619cff40141bb1fc3615b

This leads to build failure:
../util/fdmon-io_uring.c: In function ‘add_poll_remove_sqe’:
../util/fdmon-io_uring.c:182:36: error: passing argument 2 of ‘io_uring_prep_poll_remove’ makes integer from pointer without a cast [-Werror=int-conversion]

  182 |     io_uring_prep_poll_remove(sqe, node);
      |                                    ^~~~
      |                                    |
      |                                    AioHandler *
In file included from /root/io/qemu/include/block/aio.h:18,
                 from ../util/aio-posix.h:20,
                 from ../util/fdmon-io_uring.c:49:
/usr/include/liburing.h:415:17: note: expected ‘__u64’ {aka ‘long long unsigned int’} but argument is of type ‘AioHandler *’
  415 |           __u64 user_data)
      |           ~~~~~~^~~~~~~~~

cc1: all warnings being treated as errors

So convert the paramter to right type according to the io_uring define.

---
 util/fdmon-io_uring.c | 4 ++++
 1 file changed, 4 insertions(+)
util/fdmon-io_uring.c +4 -0
index 1461dfa407..e7febbf11f 100644
@@ -179,7 +179,11 @@ static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node)
 {
     struct io_uring_sqe *sqe = get_sqe(ctx);
 
+#ifdef LIBURING_HAVE_DATA64
+    io_uring_prep_poll_remove(sqe, (__u64)node);
+#else
     io_uring_prep_poll_remove(sqe, node);
+#endif
 }
 
 /* Add a timeout that self-cancels when another cqe becomes ready */
Signature · 1 line
2.35.1
#1 lore raw
Quoted 30 lines · Haiyue Wang

The io_uring fixed "Don't truncate addr fields to 32-bit on 32-bit":
https://git.kernel.dk/cgit/liburing/commit/?id=d84c29b19ed0b130000619cff40141bb1fc3615b

This leads to build failure:
../util/fdmon-io_uring.c: In function ‘add_poll_remove_sqe’:
../util/fdmon-io_uring.c:182:36: error: passing argument 2 of ‘io_uring_prep_poll_remove’ makes integer from pointer without a cast [-Werror=int-conversion]

  182 |     io_uring_prep_poll_remove(sqe, node);
      |                                    ^~~~
      |                                    |
      |                                    AioHandler *
In file included from /root/io/qemu/include/block/aio.h:18,
                 from ../util/aio-posix.h:20,
                 from ../util/fdmon-io_uring.c:49:
/usr/include/liburing.h:415:17: note: expected ‘__u64’ {aka ‘long long unsigned int’} but argument is of type ‘AioHandler *’
  415 |           __u64 user_data)
      |           ~~~~~~^~~~~~~~~

cc1: all warnings being treated as errors

So convert the paramter to right type according to the io_uring define.

---
 util/fdmon-io_uring.c | 4 ++++
 1 file changed, 4 insertions(+)
util/fdmon-io_uring.c +0 -0
index 1461dfa407..e7febbf11f 100644

util/fdmon-io_uring.c static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node) · line 187

Quoted 9 lines
util/fdmon-io_uring.c +4 -0
@@ -179,7 +179,11 @@ static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node)
 {
     struct io_uring_sqe *sqe = get_sqe(ctx);
 
+#ifdef LIBURING_HAVE_DATA64
+    io_uring_prep_poll_remove(sqe, (__u64)node);
+#else
     io_uring_prep_poll_remove(sqe, node);
+#endif
 }

Thanks for the patch. I suggest using the same approach as the liburing commit to avoid the #ifdef:

test/poll-cancel-ton.c +1 -1
index f0875cd..05bf565 100644
@@ -55,7 +55,7 @@ static int del_polls(struct io_uring *ring, int fd, int nr)
 
                        sqe = io_uring_get_sqe(ring);
                        data = sqe_index[lrand48() % nr];
-                       io_uring_prep_poll_remove(sqe, data);
+                       io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)data);
 

So the QEMU add_poll_remove_sqe() function would do:

  io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node);

Was there a reason why you chose an #ifdef instead?

Thanks,
Stefan

#2 lore raw
Quoted 3 lines · Stefan Hajnoczi

So the QEMU add_poll_remove_sqe() function would do:

  io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node);

__u64 is a linux-kernel-ism -- we should use uint64_t, I think.

thanks
-- PMM

#3 lore raw
Quoted 8 lines

-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: Monday, February 21, 2022 23:55
To: Stefan Hajnoczi <[email protected]>
Cc: Wang, Haiyue <[email protected]>; Fam Zheng <[email protected]>; [email protected]; open list:Block I/O path <[email protected]>
Subject: Re: [PATCH v1] aio-posix: fix build failure io_uring 2.2

Quoted 6 lines
Quoted 3 lines · Stefan Hajnoczi

So the QEMU add_poll_remove_sqe() function would do:

  io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node);

__u64 is a linux-kernel-ism -- we should use uint64_t, I think.

Use '(__u64)(uintptr_t)' to follow the liburing code style ?

Quoted 3 lines

thanks
-- PMM

#4 lore raw
In reply to Peter Maydell
Quoted 6 lines · Peter Maydell
Quoted 3 lines · Stefan Hajnoczi

So the QEMU add_poll_remove_sqe() function would do:

  io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node);

__u64 is a linux-kernel-ism -- we should use uint64_t, I think.

<liburing.h> and QEMU's util/fdmon-io_uring.c are Linux-only. I think it's fine to use __u64 here exactly as defined in the liburing API.

Stefan

#5 lore raw
In reply to Stefan Hajnoczi
Quoted 43 lines

-----Original Message-----
From: Stefan Hajnoczi <[email protected]>
Sent: Monday, February 21, 2022 22:54
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Fam Zheng <[email protected]>; open list:Block I/O path <[email protected]>
Subject: Re: [PATCH v1] aio-posix: fix build failure io_uring 2.2

Quoted 6 lines · Haiyue Wang

The io_uring fixed "Don't truncate addr fields to 32-bit on 32-bit":
https://git.kernel.dk/cgit/liburing/commit/?id=d84c29b19ed0b130000619cff40141bb1fc3615b

This leads to build failure:
../util/fdmon-io_uring.c: In function ‘add_poll_remove_sqe’:
../util/fdmon-io_uring.c:182:36: error: passing argument 2 of ‘io_uring_prep_poll_remove’ makes

integer from pointer without a cast [-Werror=int-conversion]

Quoted 8 lines
  182 |     io_uring_prep_poll_remove(sqe, node);
      |                                    ^~~~
      |                                    |
      |                                    AioHandler *
In file included from /root/io/qemu/include/block/aio.h:18,
                 from ../util/aio-posix.h:20,
                 from ../util/fdmon-io_uring.c:49:

/usr/include/liburing.h:415:17: note: expected ‘__u64’ {aka ‘long long unsigned int’} but argument

is of type ‘AioHandler *’

Quoted 19 lines
  415 |           __u64 user_data)
      |           ~~~~~~^~~~~~~~~

cc1: all warnings being treated as errors

So convert the paramter to right type according to the io_uring define.

---
 util/fdmon-io_uring.c | 4 ++++
 1 file changed, 4 insertions(+)
util/fdmon-io_uring.c +0 -0
index 1461dfa407..e7febbf11f 100644
@@ -179,7 +179,11 @@ static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node)
 {
     struct io_uring_sqe *sqe = get_sqe(ctx);
 
Quoted 9 lines

util/fdmon-io_uring.c static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node) · line 187

Quoted 6 lines
util/fdmon-io_uring.c +4 -0
+#ifdef LIBURING_HAVE_DATA64
+    io_uring_prep_poll_remove(sqe, (__u64)node);
+#else
     io_uring_prep_poll_remove(sqe, node);
+#endif
 }

Thanks for the patch. I suggest using the same approach as the liburing commit to avoid the #ifdef:

Old version is "void *user_data", so need to use ' LIBURING_HAVE_DATA64', also, as the comment said:

/*
* Tell the app the have the 64-bit variants of the get/set userdata */
#define LIBURING_HAVE_DATA64

And yes, two casts seems be more safe: (__u64)(uintptr_t)node

Quoted 20 lines
test/poll-cancel-ton.c +1 -1
index f0875cd..05bf565 100644
@@ -55,7 +55,7 @@ static int del_polls(struct io_uring *ring, int fd, int nr)
 
                        sqe = io_uring_get_sqe(ring);
                        data = sqe_index[lrand48() % nr];
-                       io_uring_prep_poll_remove(sqe, data);
+                       io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)data);
 

So the QEMU add_poll_remove_sqe() function would do:

  io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node);

Was there a reason why you chose an #ifdef instead?

Thanks,
Stefan

#6 lore raw
Quoted 56 lines · Haiyue
Quoted 43 lines

-----Original Message-----
From: Stefan Hajnoczi <[email protected]>
Sent: Monday, February 21, 2022 22:54
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Fam Zheng <[email protected]>; open list:Block I/O path <[email protected]>
Subject: Re: [PATCH v1] aio-posix: fix build failure io_uring 2.2

Quoted 6 lines · Haiyue Wang

The io_uring fixed "Don't truncate addr fields to 32-bit on 32-bit":
https://git.kernel.dk/cgit/liburing/commit/?id=d84c29b19ed0b130000619cff40141bb1fc3615b

This leads to build failure:
../util/fdmon-io_uring.c: In function ‘add_poll_remove_sqe’:
../util/fdmon-io_uring.c:182:36: error: passing argument 2 of ‘io_uring_prep_poll_remove’ makes

integer from pointer without a cast [-Werror=int-conversion]

Quoted 8 lines
  182 |     io_uring_prep_poll_remove(sqe, node);
      |                                    ^~~~
      |                                    |
      |                                    AioHandler *
In file included from /root/io/qemu/include/block/aio.h:18,
                 from ../util/aio-posix.h:20,
                 from ../util/fdmon-io_uring.c:49:

/usr/include/liburing.h:415:17: note: expected ‘__u64’ {aka ‘long long unsigned int’} but argument

is of type ‘AioHandler *’

Quoted 19 lines
  415 |           __u64 user_data)
      |           ~~~~~~^~~~~~~~~

cc1: all warnings being treated as errors

So convert the paramter to right type according to the io_uring define.

---
 util/fdmon-io_uring.c | 4 ++++
 1 file changed, 4 insertions(+)
util/fdmon-io_uring.c +0 -0
index 1461dfa407..e7febbf11f 100644
@@ -179,7 +179,11 @@ static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node)
 {
     struct io_uring_sqe *sqe = get_sqe(ctx);
 
Quoted 9 lines

util/fdmon-io_uring.c static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node) · line 187

Quoted 6 lines
util/fdmon-io_uring.c +4 -0
+#ifdef LIBURING_HAVE_DATA64
+    io_uring_prep_poll_remove(sqe, (__u64)node);
+#else
     io_uring_prep_poll_remove(sqe, node);
+#endif
 }

Thanks for the patch. I suggest using the same approach as the liburing commit to avoid the #ifdef:

Old version is "void *user_data", so need to use ' LIBURING_HAVE_DATA64', also, as the comment said:

Quoted 6 lines

/*
* Tell the app the have the 64-bit variants of the get/set userdata */
#define LIBURING_HAVE_DATA64

And yes, two casts seems be more safe: (__u64)(uintptr_t)node

You are right. I forgot that QEMU needs to support old liburing versions too. The #ifdef is necessary.

Stefan

#7 lore raw

PATCH v2 1/1 aio-posix: fix build failure io_uring 2.2

In reply to Haiyue Wang

The io_uring fixed "Don't truncate addr fields to 32-bit on 32-bit":
https://git.kernel.dk/cgit/liburing/commit/?id=d84c29b19ed0b130000619cff40141bb1fc3615b

This leads to build failure:
../util/fdmon-io_uring.c: In function ‘add_poll_remove_sqe’:
../util/fdmon-io_uring.c:182:36: error: passing argument 2 of ‘io_uring_prep_poll_remove’ makes integer from pointer without a cast [-Werror=int-conversion]

  182 |     io_uring_prep_poll_remove(sqe, node);
      |                                    ^~~~
      |                                    |
      |                                    AioHandler *
In file included from /root/io/qemu/include/block/aio.h:18,
                 from ../util/aio-posix.h:20,
                 from ../util/fdmon-io_uring.c:49:
/usr/include/liburing.h:415:17: note: expected ‘__u64’ {aka ‘long long unsigned int’} but argument is of type ‘AioHandler *’
  415 |           __u64 user_data)
      |           ~~~~~~^~~~~~~~~

cc1: all warnings being treated as errors

Use LIBURING_HAVE_DATA64 to check whether the io_uring supports 64-bit variants of the get/set userdata, to convert the paramter to the right data type.

---
v2: update the commit log, and change the type cast as io_uring test does.

---
 util/fdmon-io_uring.c | 4 ++++
 1 file changed, 4 insertions(+)
util/fdmon-io_uring.c +4 -0
index 1461dfa407..ab43052dd7 100644
@@ -179,7 +179,11 @@ static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node)
 {
     struct io_uring_sqe *sqe = get_sqe(ctx);
 
+#ifdef LIBURING_HAVE_DATA64
+    io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node);
+#else
     io_uring_prep_poll_remove(sqe, node);
+#endif
 }
 
 /* Add a timeout that self-cancels when another cqe becomes ready */
Signature · 1 line
2.35.1
#8 lore raw
Quoted 22 lines · Haiyue Wang

The io_uring fixed "Don't truncate addr fields to 32-bit on 32-bit":
https://git.kernel.dk/cgit/liburing/commit/?id=d84c29b19ed0b130000619cff40141bb1fc3615b

This leads to build failure:
../util/fdmon-io_uring.c: In function ‘add_poll_remove_sqe’:
../util/fdmon-io_uring.c:182:36: error: passing argument 2 of ‘io_uring_prep_poll_remove’ makes integer from pointer without a cast [-Werror=int-conversion]

  182 |     io_uring_prep_poll_remove(sqe, node);
      |                                    ^~~~
      |                                    |
      |                                    AioHandler *
In file included from /root/io/qemu/include/block/aio.h:18,
                 from ../util/aio-posix.h:20,
                 from ../util/fdmon-io_uring.c:49:
/usr/include/liburing.h:415:17: note: expected ‘__u64’ {aka ‘long long unsigned int’} but argument is of type ‘AioHandler *’
  415 |           __u64 user_data)
      |           ~~~~~~^~~~~~~~~

cc1: all warnings being treated as errors

Use LIBURING_HAVE_DATA64 to check whether the io_uring supports 64-bit variants of the get/set userdata, to convert the paramter to the right data type.

Quoted 6 lines

---
v2: update the commit log, and change the type cast as io_uring test does.

---
 util/fdmon-io_uring.c | 4 ++++
 1 file changed, 4 insertions(+)

Thanks, applied to my block tree:
https://gitlab.com/stefanha/qemu/commits/block

I will update the patch in my queue if further discussion raises issues.

Stefan