diff mbox series

[v6,1/4] liburing: add api to set napi busy poll settings

Message ID 20230203190310.2900766-2-shr@devkernel.io (mailing list archive)
State New
Headers show
Series liburing: add api for napi busy poll | expand

Commit Message

Stefan Roesch Feb. 3, 2023, 7:03 p.m. UTC
This adds two functions to manage the napi busy poll settings:
- io_uring_register_napi
- io_uring_unregister_napi

Signed-off-by: Stefan Roesch <shr@devkernel.io>
---
 src/include/liburing.h          |  3 +++
 src/include/liburing/io_uring.h | 12 ++++++++++++
 src/liburing.map                |  3 +++
 src/register.c                  | 12 ++++++++++++
 4 files changed, 30 insertions(+)

Comments

Ammar Faizi Feb. 3, 2023, 8:19 p.m. UTC | #1
On Fri, Feb 03, 2023 at 11:03:07AM -0800, Stefan Roesch wrote:
> This adds two functions to manage the napi busy poll settings:
> - io_uring_register_napi
> - io_uring_unregister_napi
> 
> Signed-off-by: Stefan Roesch <shr@devkernel.io>
> ---
>  src/include/liburing.h          |  3 +++
>  src/include/liburing/io_uring.h | 12 ++++++++++++
>  src/liburing.map                |  3 +++
>  src/register.c                  | 12 ++++++++++++
>  4 files changed, 30 insertions(+)

We have a new rule. Since commit:

  9e2890d35e9677d8cfc7ac66cdb2d97c48a0b5a2 ("build: add liburing-ffi")

Adding a new exported function should also be reflected in
liburing-ffi.map.
Stefan Roesch Feb. 3, 2023, 9:06 p.m. UTC | #2
Ammar Faizi <ammarfaizi2@gnuweeb.org> writes:

> On Fri, Feb 03, 2023 at 11:03:07AM -0800, Stefan Roesch wrote:
>> This adds two functions to manage the napi busy poll settings:
>> - io_uring_register_napi
>> - io_uring_unregister_napi
>>
>> Signed-off-by: Stefan Roesch <shr@devkernel.io>
>> ---
>>  src/include/liburing.h          |  3 +++
>>  src/include/liburing/io_uring.h | 12 ++++++++++++
>>  src/liburing.map                |  3 +++
>>  src/register.c                  | 12 ++++++++++++
>>  4 files changed, 30 insertions(+)
>
> We have a new rule. Since commit:
>
>   9e2890d35e9677d8cfc7ac66cdb2d97c48a0b5a2 ("build: add liburing-ffi")
>
> Adding a new exported function should also be reflected in
> liburing-ffi.map.

I'll add it to the next version.
diff mbox series

Patch

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 1f91983..13546c4 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -240,6 +240,9 @@  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(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_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 636a4c2..ab6c86e 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -518,6 +518,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			= 26,
+	IORING_UNREGISTER_NAPI			= 27,
+
 	/* this goes last */
 	IORING_REGISTER_LAST
 };
@@ -640,6 +644,14 @@  struct io_uring_buf_reg {
 	__u64	resv[3];
 };
 
+/* argument for IORING_(UN)REGISTER_NAPI */
+struct io_uring_napi {
+	__u32   busy_poll_to;
+	__u8    prefer_busy_poll;
+	__u8    pad[3];
+	__u64   resv;
+};
+
 /*
  * io_uring_restriction->opcode values
  */
diff --git a/src/liburing.map b/src/liburing.map
index 1dbe765..013dc4a 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -76,4 +76,7 @@  LIBURING_2.4 {
 
 		io_uring_enable_rings;
 		io_uring_register_restrictions;
+
+		io_uring_register_napi;
+		io_uring_unregister_napi;
 } LIBURING_2.3;
diff --git a/src/register.c b/src/register.c
index ac4c9e3..966839b 100644
--- a/src/register.c
+++ b/src/register.c
@@ -342,3 +342,15 @@  int io_uring_register_file_alloc_range(struct io_uring *ring,
 				       IORING_REGISTER_FILE_ALLOC_RANGE, &range,
 				       0);
 }
+
+int io_uring_register_napi(struct io_uring *ring, struct io_uring_napi *napi)
+{
+	return __sys_io_uring_register(ring->ring_fd,
+				IORING_REGISTER_NAPI, napi, 0);
+}
+
+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, 0);
+}