[PATCH liburing v3 09/11] expose CQ ring overflow state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Allow the application to easily view if the CQ ring is in overflow state in
case it would like to explicitly flush using io_uring_get_events.

Explicit flushing can be useful for applications that prefer to have
reduced latency on CQs than to process as many as possible.

Signed-off-by: Dylan Yudaken <dylany@xxxxxx>
---
 man/io_uring_cq_has_overflow.3 | 25 +++++++++++++++++++++++++
 man/io_uring_get_events.3      |  3 ++-
 src/include/liburing.h         |  9 +++++++++
 3 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 man/io_uring_cq_has_overflow.3

diff --git a/man/io_uring_cq_has_overflow.3 b/man/io_uring_cq_has_overflow.3
new file mode 100644
index 000000000000..e5b352a4f86a
--- /dev/null
+++ b/man/io_uring_cq_has_overflow.3
@@ -0,0 +1,25 @@
+.\" Copyright (C) 2022 Dylan Yudaken <dylany@xxxxxx>
+.\"
+.\" SPDX-License-Identifier: LGPL-2.0-or-later
+.\"
+.TH io_uring_cq_has_overflow 3 "September 5, 2022" "liburing-2.3" "liburing Manual"
+.SH NAME
+io_uring_cq_has_overflow \- returns if there are overflow entries waiting to move to the CQ ring
+.SH SYNOPSIS
+.nf
+.B #include <liburing.h>
+.PP
+.BI "bool io_uring_cq_has_overflow(const struct io_uring *" ring ");"
+.fi
+.SH DESCRIPTION
+.PP
+The
+.BR io_uring_cq_has_overflow (3)
+function informs the application if CQ entries have overflowed and are waiting to be flushed to
+the CQ ring. For example using
+.BR io_uring_get_events (3)
+.
+.SH RETURN VALUE
+True if there are CQ entries waiting to be flushed to the CQ ring.
+.SH SEE ALSO
+.BR io_uring_get_events (3)
diff --git a/man/io_uring_get_events.3 b/man/io_uring_get_events.3
index 2ac3e070473e..f2415423953c 100644
--- a/man/io_uring_get_events.3
+++ b/man/io_uring_get_events.3
@@ -29,4 +29,5 @@ returns 0. On failure it returns
 .BR -errno .
 .SH SEE ALSO
 .BR io_uring_get_sqe (3),
-.BR io_uring_submit_and_get_events (3)
+.BR io_uring_submit_and_get_events (3),
+.BR io_uring_cq_has_overflow (3)
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 765375cb5c6a..ae25e2199264 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -1098,6 +1098,15 @@ static inline unsigned io_uring_cq_ready(const struct io_uring *ring)
 	return io_uring_smp_load_acquire(ring->cq.ktail) - *ring->cq.khead;
 }
 
+/*
+ * Returns true if there are overflow entries waiting to be flushed onto
+ * the CQ ring
+ */
+static inline bool io_uring_cq_has_overflow(const struct io_uring *ring)
+{
+	return IO_URING_READ_ONCE(*ring->sq.kflags) & IORING_SQ_CQ_OVERFLOW;
+}
+
 /*
  * Returns true if the eventfd notification is currently enabled
  */
-- 
2.30.2





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux