[PATCH v1 3/4] liburing: add helper for IORING_REGISTER_IOWAIT

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

 



From: David Wei <davidhwei@xxxxxxxx>

Sync include/liburing/io_uring.h and add io_uring_register_iowait()
helper function.

Currently we unconditionally account time spent waiting for events in CQ
ring as iowait time.

Some userspace tools consider iowait time to be CPU util/load which can
be misleading as the process is sleeping. High iowait time might be
indicative of issues for storage IO, but for network IO e.g. socket
recv() we do not control when the completions happen so its value
misleads userspace tooling.

Add io_uring_register_iowait() which gates the previously unconditional
iowait accounting. By default time is not accounted as iowait, unless
this is explicitly enabled for a ring. Thus userspace can decide,
depending on the type of work it expects to do, whether it wants to
consider cqring wait time as iowait or not.

Signed-off-by: David Wei <davidhwei@xxxxxxxx>
---
 src/include/liburing.h          | 2 ++
 src/include/liburing/io_uring.h | 3 +++
 src/register.c                  | 6 ++++++
 3 files changed, 11 insertions(+)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 6850fa7..5e39cc6 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -241,6 +241,8 @@ int io_uring_register_file_alloc_range(struct io_uring *ring,
 int io_uring_register_napi(struct io_uring *ring, struct io_uring_napi *napi);
 int io_uring_unregister_napi(struct io_uring *ring, struct io_uring_napi *napi);
 
+int io_uring_register_iowait(struct io_uring *ring, int enabled);
+
 int io_uring_get_events(struct io_uring *ring);
 int io_uring_submit_and_get_events(struct io_uring *ring);
 
diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index bde1199..ba94955 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -570,6 +570,9 @@ enum {
 	IORING_REGISTER_NAPI			= 27,
 	IORING_UNREGISTER_NAPI			= 28,
 
+	/* account time spent in cqring wait as iowait */
+	IORING_REGISTER_IOWAIT			= 29,
+
 	/* this goes last */
 	IORING_REGISTER_LAST,
 
diff --git a/src/register.c b/src/register.c
index f9bc52b..7f2890e 100644
--- a/src/register.c
+++ b/src/register.c
@@ -368,3 +368,9 @@ int io_uring_unregister_napi(struct io_uring *ring, struct io_uring_napi *napi)
 	return __sys_io_uring_register(ring->ring_fd,
 				IORING_UNREGISTER_NAPI, napi, 1);
 }
+
+int io_uring_register_iowait(struct io_uring *ring, int enabled)
+{
+	return __sys_io_uring_register(ring->ring_fd,
+				IORING_REGISTER_IOWAIT, NULL, enabled);
+}
-- 
2.43.0





[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