public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing] tests/poll: poll update as a part of poll remove
@ 2021-04-14 23:22 Pavel Begunkov
  2021-04-14 23:29 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Begunkov @ 2021-04-14 23:22 UTC (permalink / raw)
  To: Jens Axboe, io-uring

Fix up poll-mshot-update test doing poll updates as we moved poll
updates under IORING_OP_POLL_REMOVE. And add a helper for updates.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 src/include/liburing.h   | 13 +++++++++++++
 test/poll-mshot-update.c |  7 +++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 5b96e02..5bda635 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -329,6 +329,19 @@ static inline void io_uring_prep_poll_remove(struct io_uring_sqe *sqe,
 	io_uring_prep_rw(IORING_OP_POLL_REMOVE, sqe, -1, user_data, 0, 0);
 }
 
+static inline void io_uring_prep_poll_update(struct io_uring_sqe *sqe,
+					     void *old_user_data,
+					     void *new_user_data,
+					     unsigned poll_mask, unsigned flags)
+{
+	io_uring_prep_rw(IORING_OP_POLL_REMOVE, sqe, -1, old_user_data, flags,
+			 (__u64)new_user_data);
+#if __BYTE_ORDER == __BIG_ENDIAN
+	poll_mask = __swahw32(poll_mask);
+#endif
+	sqe->poll32_events = poll_mask;
+}
+
 static inline void io_uring_prep_fsync(struct io_uring_sqe *sqe, int fd,
 				       unsigned fsync_flags)
 {
diff --git a/test/poll-mshot-update.c b/test/poll-mshot-update.c
index bfe96c8..1a9ea0a 100644
--- a/test/poll-mshot-update.c
+++ b/test/poll-mshot-update.c
@@ -56,11 +56,10 @@ static int reap_polls(struct io_uring *ring)
 		struct io_uring_sqe *sqe;
 
 		sqe = io_uring_get_sqe(ring);
-		io_uring_prep_poll_add(sqe, p[i].fd[0], POLLIN);
+		/* update event */
+		io_uring_prep_poll_update(sqe, (void *)(unsigned long)i, NULL,
+					  POLLIN, 2);
 		sqe->user_data = 0x12345678;
-		sqe->addr = i;
-		sqe->off = POLLIN;
-		sqe->len = 2;
 	}
 
 	ret = io_uring_submit(ring);
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-14 23:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-14 23:22 [PATCH liburing] tests/poll: poll update as a part of poll remove Pavel Begunkov
2021-04-14 23:29 ` Jens Axboe
2021-04-14 23:44   ` Pavel Begunkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox