liburing: add api for napi busy poll timeout
Subsystems (3)
v3 cover liburing: add api for napi busy poll timeout
This adds three new api's to set/clear the napi busy poll timeout and to set the napi prefer busy poll setting. The three new functions are called:
- io_uring_napi_register_busy_poll_timeout,
- io_uring_napi_unregister_busy_poll_timeout,
- io_uring_register_napi_prefer_busy_poll.
The patch series also contains the documentation for the three new functions and two example programs. The client program is called napi-busy-poll-client and the server program napi-busy-poll-server. The client measures the roundtrip times of requests.
There is also a kernel patch "io-uring: support napi busy poll" to enable this feature on the kernel side.
Changes:
- V3:
- Updated liburing.map file
- Moved example programs from the test directory to the example directory. The two example programs don't fit well in the test category and need to be run from separate hosts.
- Added the io_uring_register_napi_prefer_busy_poll API.
- Added the call to io_uring_register_napi_prefer_busy_poll to the example programs
- Updated the documentation
- V2:
- Updated the liburing.map file for the two new functions. (added a 2.4 section)
- Added a description of the new feature to the changelog file
- Fixed the indentation of the longopts structure
- Used defined exit constants
- Fixed encodeUserData to support 32 bit builds
Stefan Roesch (4):
liburing: add api to set napi busy poll settings
liburing: add documentation for new napi busy polling
liburing: add test programs for napi busy poll
liburing: update changelog with new feature
.gitignore | 2 + CHANGELOG | 3 + examples/Makefile | 2 + examples/napi-busy-poll-client.c | 432 ++++++++++++++++++ examples/napi-busy-poll-server.c | 380 +++++++++++++++ ...io_uring_register_napi_busy_poll_timeout.3 | 35 ++ man/io_uring_register_napi_prefer_busy_poll.3 | 35 ++ ..._uring_unregister_napi_busy_poll_timeout.3 | 26 ++ src/include/liburing.h | 6 + src/include/liburing/io_uring.h | 4 + src/liburing.map | 7 + src/register.c | 23 + 12 files changed, 955 insertions(+) create mode 100644 examples/napi-busy-poll-client.c create mode 100644 examples/napi-busy-poll-server.c create mode 100644 man/io_uring_register_napi_busy_poll_timeout.3 create mode 100644 man/io_uring_register_napi_prefer_busy_poll.3 create mode 100644 man/io_uring_unregister_napi_busy_poll_timeout.3
base-commit: 8fc22e3b3348c0a6384ec926e0b19b6707622e58
Signature · 1 line
2.30.2
RFC PATCH v3 1/4 liburing: add api to set napi busy poll settings
This adds three functions to manage the napi busy poll settings:
- io_uring_register_napi_busy_poll_timeout
- io_uring_unregister_napi_busy_poll_timeout
- io_uring_register_napi_prefer_busy_poll
--- src/include/liburing.h | 6 ++++++ src/include/liburing/io_uring.h | 4 ++++ src/liburing.map | 7 +++++++ src/register.c | 23 +++++++++++++++++++++++ 4 files changed, 40 insertions(+)
src/include/liburing.h +6 -0
@@ -235,6 +235,12 @@ int io_uring_register_sync_cancel(struct io_uring *ring,int io_uring_register_file_alloc_range (struct io_uring *ring,unsigned off,unsigned len); +int io_uring_register_napi_prefer_busy_poll (struct io_uring *ring, +bool prefer_busy_poll); +int io_uring_register_napi_busy_poll_timeout (struct io_uring *ring, +unsigned int to); +int io_uring_unregister_napi_busy_poll_timeout (struct io_uring *ring); +int io_uring_get_events (struct io_uring *ring);int io_uring_submit_and_get_events (struct io_uring *ring);
src/include/liburing/io_uring.h +4 -0
@@ -499,6 +499,10 @@ enum {/* register a range of fixed file slots for automatic slot allocation */ IORING_REGISTER_FILE_ALLOC_RANGE =25 , +/* set/clear busy poll settings */ +IORING_REGISTER_NAPI_PREFER_BUSY_POLL =26 , +IORING_REGISTER_NAPI_BUSY_POLL_TIMEOUT =27 , +/* this goes last */ IORING_REGISTER_LAST };
src/liburing.map +7 -0
@@ -67,3 +67,10 @@ LIBURING_2.3 { io_uring_get_events; io_uring_submit_and_get_events; } LIBURING_2.2; + +LIBURING_2.4 { + global: + io_uring_napi_register_prefer_busy_poll; + io_uring_napi_register_busy_poll_timeout; + io_uring_napi_unregister_busy_poll_timeout; +} LIBURING_2.3;
src/register.c +23 -0
@@ -367,3 +367,26 @@ int io_uring_register_file_alloc_range(struct io_uring *ring,IORING_REGISTER_FILE_ALLOC_RANGE , &range, 0); } + +int io_uring_register_napi_prefer_busy_poll (struct io_uring *ring, +bool prefer_busy_poll) +{ +return __sys_io_uring_register (ring->ring_fd, +IORING_REGISTER_NAPI_PREFER_BUSY_POLL , +NULL , prefer_busy_poll); +} + +int io_uring_register_napi_busy_poll_timeout (struct io_uring *ring, +unsigned int to) +{ +return __sys_io_uring_register (ring->ring_fd, +IORING_REGISTER_NAPI_BUSY_POLL_TIMEOUT , +NULL , to); +} + +int io_uring_unregister_napi_busy_poll_timeout (struct io_uring *ring) +{ +return __sys_io_uring_register (ring->ring_fd, +IORING_REGISTER_NAPI_BUSY_POLL_TIMEOUT , +NULL ,0 ); +}
Signature · 1 line
2.30.2
RFC PATCH v3 2/4 liburing: add documentation for new napi busy polling
In reply to Stefan RoeschThis adds two man pages for the two new functions:
- io_uring_register_napi_busy_poll_timeout
- io_uring_unregister_napi_busy_poll_timeout
--- ...io_uring_register_napi_busy_poll_timeout.3 | 35 +++++++++++++++++++ man/io_uring_register_napi_prefer_busy_poll.3 | 35 +++++++++++++++++++ ..._uring_unregister_napi_busy_poll_timeout.3 | 26 ++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 man/io_uring_register_napi_busy_poll_timeout.3 create mode 100644 man/io_uring_register_napi_prefer_busy_poll.3 create mode 100644 man/io_uring_unregister_napi_busy_poll_timeout.3
man/io_uring_register_napi_busy_poll_timeout.3 new file +35 -0
@@ -0,0 +1,35 @@ +.\" Copyright (C) 2022 Stefan Roesch <[email protected]> +.\" +.\" SPDX-License-Identifier: LGPL-2.0-or-later +.\" +.TH io_uring_register_napi_busy_poll_timeout 3 "November 10, 2022" "liburing-2.4" "liburing Manual" +.SH NAME +io_uring_register_napi_busy_poll_timeout \- register NAPI busy poll timeout +.SH SYNOPSIS +.nf +.B #include <liburing.h> +.PP +.BI "int io_uring_register_napi_busy_poll_timeout(struct io_uring *" ring "," +.BI " unsigned int " timeout) +.PP +.fi +.SH DESCRIPTION +.PP +The +.BR io_uring_register_napi_busy_poll_timeout (3) +function registers the NAPI busy poll +.I timeout +for subsequent operations. + +Registering a NAPI busy poll timeout is a requirement to be able to use +NAPI busy polling. The other way to enable NAPI busy polling is to set the +proc setting /proc/sys/net/core/busy_poll. + +NAPI busy poll can reduce the network roundtrip time. + + +.SH RETURN VALUE +On success +.BR io_uring_register_napi_busy_poll_timeout (3) +return 0. On failure they return +.BR -errno .
man/io_uring_register_napi_prefer_busy_poll.3 new file +35 -0
@@ -0,0 +1,35 @@ +.\" Copyright (C) 2022 Stefan Roesch <[email protected]> +.\" +.\" SPDX-License-Identifier: LGPL-2.0-or-later +.\" +.TH io_uring_register_napi_prefer_busy_poll 3 "November 11, 2022" "liburing-2.4" "liburing Manual" +.SH NAME +io_uring_register_napi_prefer_busy_poll \- register NAPI prefer busy poll setting +.SH SYNOPSIS +.nf +.B #include <liburing.h> +.PP +.BI "int io_uring_register_napi_prefer_busy_poll(struct io_uring *" ring "," +.BI " bool " prefer_busy_poll) +.PP +.fi +.SH DESCRIPTION +.PP +The +.BR io_uring_register_napi_prefer_busy_poll (3) +function registers the NAPI +.I prefer_busy_poll +for subsequent operations. + +Registering a NAPI prefer busy poll seeting sets the mode when calling the +function napi_busy_loop and corresponds to the SO_PREFER_BUSY_POLL socket +option. + +NAPI prefer busy poll can help in reducng the network roundtrip time. + + +.SH RETURN VALUE +On success +.BR io_uring_register_napi_prefer_busy_poll (3) +return 0. On failure they return +.BR -errno .
man/io_uring_unregister_napi_busy_poll_timeout.3 new file +26 -0
@@ -0,0 +1,26 @@ +.\" Copyright (C) 2022 Stefan Roesch <[email protected]> +.\" +.\" SPDX-License-Identifier: LGPL-2.0-or-later +.\" +.TH io_uring_unregister_napi_busy_poll_timeout 3 "November 10, 2022" "liburing-2.4" "liburing Manual" +.SH NAME +io_uring_unregister_napi_busy_poll_timeout \- unregister NAPI busy poll timeout +.SH SYNOPSIS +.nf +.B #include <liburing.h> +.PP +.BI "int io_uring_unregister_napi_busy_poll_timeout(struct io_uring *" ring ") +.PP +.fi +.SH DESCRIPTION +.PP +The +.BR io_uring_unregister_napi_busy_poll_timeout (3) +function unregisters the NAPI busy poll +for subsequent operations. + +.SH RETURN VALUE +On success +.BR io_uring_unregister_napi_busy_poll_timeout (3) +return 0. On failure they return +.BR -errno .
Signature · 1 line
2.30.2
RFC PATCH v3 3/4 liburing: add test programs for napi busy poll
In reply to Stefan RoeschThis adds two test programs to test the napi busy poll functionality. It consists of a client program and a server program. To get a napi id, the client and the server program need to be run on different hosts.
To test the napi busy poll timeout, the -t needs to be specified. A reasonable value for the busy poll timeout is 100. By specifying the busy poll timeout on the server and the client the best results are accomplished.
--- .gitignore | 2 + examples/Makefile | 2 + examples/napi-busy-poll-client.c | 432 +++++++++++++++++++++++++++++++ examples/napi-busy-poll-server.c | 380 +++++++++++++++++++++++++++ 4 files changed, 816 insertions(+) create mode 100644 examples/napi-busy-poll-client.c create mode 100644 examples/napi-busy-poll-server.c
.gitignore +2 -0
@@ -15,6 +15,8 @@ /examples/io_uring-test /examples/io_uring-udp /examples/link-cp +/examples/napi-busy-poll-client +/examples/napi-busy-poll-server /examples/ucontext-cp /examples/poll-bench /examples/send-zerocopy
examples/Makefile +2 -0
@@ -15,6 +15,8 @@ example_srcs := \ io_uring-test.c \ io_uring-udp.c \ link-cp.c \ + napi-busy-poll-client.c \ + napi-busy-poll-server.c \ poll-bench.c \ send-zerocopy.c
examples/napi-busy-poll-client.c new file +432 -0
432 lines not on this page · raw message
examples/napi-busy-poll-server.c new file +380 -0
380 lines not on this page · raw message
Signature · 1 line
2.30.2
RFC PATCH v3 4/4 liburing: update changelog with new feature
In reply to Stefan RoeschAdd a new entry to the changelog file for the napi busy poll feature.
--- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+)
CHANGELOG +3 -0
@@ -1,3 +1,6 @@ +liburing-2.4 release +- Support for napi busy polling + liburing-2.3 release - Support non-libc build for aarch64.
Signature · 1 line
2.30.2