Skip to contentSkip to conversation

io_uring: remove structures from include/linux/io_uring.h

PATCH In review Stefan Metzmacher 3 participants 10 messages Mar 14, 2021 – Mar 17, 2021 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH v2 1/2 io_uring: remove structures from include/linux/io_uring.h

In reply to a message not in the archive
---
 fs/io-wq.h               | 10 +++++++++-
 fs/io_uring.c            | 16 ++++++++++++++++
 include/linux/io_uring.h | 25 -------------------------
 3 files changed, 25 insertions(+), 26 deletions(-)
fs/io-wq.h +0 -1
index 1ac2f3248088..80d590564ff9 100644
@@ -2,7 +2,6 @@
 #define INTERNAL_IO_WQ_H
  #include <linux/refcount.h>
-#include <linux/io_uring.h>
  struct io_wq;
 @@ -21,6 +20,15 @@ enum io_wq_cancel {
 	IO_WQ_CANCEL_NOTFOUND,	/* work not found */
 };

+struct io_wq_work_node {
+ struct io_wq_work_node *next;
+};
+
+struct io_wq_work_list {
+ struct io_wq_work_node *first;
+ struct io_wq_work_node *last;
+};
+
static inline void wq_list_add_after(struct io_wq_work_node *node,
struct io_wq_work_node *pos, struct io_wq_work_list *list)

fs/io_uring.c +15 -0
index 642ad08d8964..fd0807a3c9c3 100644
@@ -454,6 +454,22 @@ struct io_ring_ctx {
 	struct list_head		tctx_list;
 };
 +struct io_uring_task {
+	/* submission side */
+	struct xarray		xa;
+	struct wait_queue_head	wait;
+	void			*last;
+	void			*io_wq;
+	struct percpu_counter	inflight;
+	atomic_t		in_idle;
+	bool			sqpoll;
+
+	spinlock_t		task_lock;
+	struct io_wq_work_list	task_list;
+	unsigned long		task_state;
+	struct callback_head	task_work;
+};
+
 /*
  * First field must be the file pointer in all the
  * iocb unions! See also 'struct kiocb' in <linux/fs.h>
include/linux/io_uring.h +0 -24
index 9761a0ec9f95..79cde9906be0 100644
@@ -5,31 +5,6 @@
 #include <linux/sched.h>
 #include <linux/xarray.h>
 -struct io_wq_work_node {
-	struct io_wq_work_node *next;
-};
-
-struct io_wq_work_list {
-	struct io_wq_work_node *first;
-	struct io_wq_work_node *last;
-};
-
-struct io_uring_task {
-	/* submission side */
-	struct xarray		xa;
-	struct wait_queue_head	wait;
-	void			*last;
-	void			*io_wq;
-	struct percpu_counter	inflight;
-	atomic_t		in_idle;
-	bool			sqpoll;
-
-	spinlock_t		task_lock;
-	struct io_wq_work_list	task_list;
-	unsigned long		task_state;
-	struct callback_head	task_work;
-};
-
 #if defined(CONFIG_IO_URING)
 struct sock *io_uring_get_socket(struct file *file);
 void __io_uring_task_cancel(void);
Signature · 1 line
2.25.1
#10 lore raw

PATCH v2 2/2 io_uring: use typesafe pointers in io_uring_task

In reply to a message not in the archive
---
 fs/io_uring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/io_uring.c +2 -2
index fd0807a3c9c3..9b8cd9559584 100644
@@ -458,8 +458,8 @@ struct io_uring_task {
 	/* submission side */
 	struct xarray		xa;
 	struct wait_queue_head	wait;
-	void			*last;
-	void			*io_wq;
+	const struct io_ring_ctx *last;
+	struct io_wq		*io_wq;
 	struct percpu_counter	inflight;
 	atomic_t		in_idle;
 	bool			sqpoll;
Signature · 1 line
2.25.1
#2 lore raw
In reply to Stefan Metzmacher

Both patches are really nice. However, 1/2 doesn't apply and looks it needs small stylistic changes, see nits below

Quoted 11 lines · Stefan Metzmacher
---
 fs/io-wq.h               | 10 +++++++++-
 fs/io_uring.c            | 16 ++++++++++++++++
 include/linux/io_uring.h | 25 -------------------------
 3 files changed, 25 insertions(+), 26 deletions(-)
fs/io-wq.h +0 -0
index 1ac2f3248088..80d590564ff9 100644

fs/io-wq.h line 7

Quoted 7 lines
fs/io-wq.h +0 -1
@@ -2,7 +2,6 @@
 #define INTERNAL_IO_WQ_H
  #include <linux/refcount.h>
-#include <linux/io_uring.h>
  struct io_wq;
 @@ -21,6 +20,15 @@ enum io_wq_cancel {
 	IO_WQ_CANCEL_NOTFOUND,	/* work not found */
 };

newline (nl)?

Quoted 17 lines

+struct io_wq_work_node {

fs/io-wq.h +8 -0
+	struct io_wq_work_node *next;
+};
+
+struct io_wq_work_list {
+	struct io_wq_work_node *first;
+	struct io_wq_work_node *last;
+};
+
 static inline void wq_list_add_after(struct io_wq_work_node *node,
 				     struct io_wq_work_node *pos,
 				     struct io_wq_work_list *list)
fs/io_uring.c +0 -0
index 642ad08d8964..fd0807a3c9c3 100644

fs/io_uring.c struct io_ring_ctx { · line 455

Quoted 2 lines
fs/io_uring.c +0 -0
@@ -454,6 +454,22 @@ struct io_ring_ctx {
 	struct list_head		tctx_list;
 };

nl

Quoted 41 lines
fs/io_uring.c +15 -0
 +struct io_uring_task {
+	/* submission side */
+	struct xarray		xa;
+	struct wait_queue_head	wait;
+	void			*last;
+	void			*io_wq;
+	struct percpu_counter	inflight;
+	atomic_t		in_idle;
+	bool			sqpoll;
+
+	spinlock_t		task_lock;
+	struct io_wq_work_list	task_list;
+	unsigned long		task_state;
+	struct callback_head	task_work;
+};
+
 /*
  * First field must be the file pointer in all the
  * iocb unions! See also 'struct kiocb' in <linux/fs.h>
include/linux/io_uring.h +0 -14
index 9761a0ec9f95..79cde9906be0 100644
@@ -5,31 +5,6 @@
 #include <linux/sched.h>
 #include <linux/xarray.h>
 -struct io_wq_work_node {
-	struct io_wq_work_node *next;
-};
-
-struct io_wq_work_list {
-	struct io_wq_work_node *first;
-	struct io_wq_work_node *last;
-};
-
-struct io_uring_task {
-	/* submission side */
-	struct xarray		xa;
-	struct wait_queue_head	wait;
-	void			*last;
-	void			*io_wq;

include/linux/io_uring.h line 31

Quoted 10 lines
include/linux/io_uring.h +0 -10
-	struct percpu_counter	inflight;
-	atomic_t		in_idle;
-	bool			sqpoll;
-
-	spinlock_t		task_lock;
-	struct io_wq_work_list	task_list;
-	unsigned long		task_state;
-	struct callback_head	task_work;
-};
-

nl

Quoted 4 lines
include/linux/io_uring.h +0 -0
 #if defined(CONFIG_IO_URING)
 struct sock *io_uring_get_socket(struct file *file);
 void __io_uring_task_cancel(void);
Signature · 1 line
Pavel Begunkov
#4 lore raw
Quoted 11 lines · Stefan Metzmacher

Hi Pavel,

Quoted 2 lines

Both patches are really nice. However, 1/2 doesn't apply and looks it needs small stylistic changes, see nits below

It seems the mails got corrupted, I played with git imap-send... :-(

Here a branch with the patches:
https://git.samba.org/?p=metze/linux/wip.git;a=shortlog;h=refs/heads/io_uring-5.12

Should I resend them once I fixed my mail setup?

Who knows. Jens, do you want to take it for 5.12?

I just recently converted tctx->last from file* to ctx* and had to gaze enough to not screw, in this light 2/2 looks good from the safety perspective.

Signature · 1 line
Pavel Begunkov
#6 lore raw

v2 cover Some header cleanups

In reply to Stefan Metzmacher

Hi,

here're a few cleanups in order to make structures as private and typesafe as possible. It also cleans up the layering from io_uring.c being on top of io-wq.*.

Changes since v1:

- None, hopefully correct patch format now.

Stefan Metzmacher (2):
io_uring: remove structures from include/linux/io_uring.h
io_uring: use typesafe pointers in io_uring_task

 fs/io-wq.h               | 10 +++++++++-
 fs/io_uring.c            | 16 ++++++++++++++++
 include/linux/io_uring.h | 25 -------------------------
 3 files changed, 25 insertions(+), 26 deletions(-)
Signature · 1 line
2.25.1
#7 lore raw

PATCH v2 1/2 io_uring: remove structures from include/linux/io_uring.h

---
 fs/io-wq.h               | 10 +++++++++-
 fs/io_uring.c            | 16 ++++++++++++++++
 include/linux/io_uring.h | 25 -------------------------
 3 files changed, 25 insertions(+), 26 deletions(-)
fs/io-wq.h +9 -1
index 1ac2f3248088..80d590564ff9 100644
@@ -2,7 +2,6 @@
 #define INTERNAL_IO_WQ_H
 
 #include <linux/refcount.h>
-#include <linux/io_uring.h>
 
 struct io_wq;
 
@@ -21,6 +20,15 @@ enum io_wq_cancel {
 	IO_WQ_CANCEL_NOTFOUND,	/* work not found */
 };
 
+struct io_wq_work_node {
+	struct io_wq_work_node *next;
+};
+
+struct io_wq_work_list {
+	struct io_wq_work_node *first;
+	struct io_wq_work_node *last;
+};
+
 static inline void wq_list_add_after(struct io_wq_work_node *node,
 				     struct io_wq_work_node *pos,
 				     struct io_wq_work_list *list)
fs/io_uring.c +16 -0
index 58d62dd9f8e4..52b5ed71d770 100644
@@ -454,6 +454,22 @@ struct io_ring_ctx {
 	struct list_head		tctx_list;
 };
 
+struct io_uring_task {
+	/* submission side */
+	struct xarray		xa;
+	struct wait_queue_head	wait;
+	void			*last;
+	void			*io_wq;
+	struct percpu_counter	inflight;
+	atomic_t		in_idle;
+	bool			sqpoll;
+
+	spinlock_t		task_lock;
+	struct io_wq_work_list	task_list;
+	unsigned long		task_state;
+	struct callback_head	task_work;
+};
+
 /*
  * First field must be the file pointer in all the
  * iocb unions! See also 'struct kiocb' in <linux/fs.h>
include/linux/io_uring.h +0 -25
index 9761a0ec9f95..79cde9906be0 100644
@@ -5,31 +5,6 @@
 #include <linux/sched.h>
 #include <linux/xarray.h>
 
-struct io_wq_work_node {
-	struct io_wq_work_node *next;
-};
-
-struct io_wq_work_list {
-	struct io_wq_work_node *first;
-	struct io_wq_work_node *last;
-};
-
-struct io_uring_task {
-	/* submission side */
-	struct xarray		xa;
-	struct wait_queue_head	wait;
-	void			*last;
-	void			*io_wq;
-	struct percpu_counter	inflight;
-	atomic_t		in_idle;
-	bool			sqpoll;
-
-	spinlock_t		task_lock;
-	struct io_wq_work_list	task_list;
-	unsigned long		task_state;
-	struct callback_head	task_work;
-};
-
 #if defined(CONFIG_IO_URING)
 struct sock *io_uring_get_socket(struct file *file);
 void __io_uring_task_cancel(void);
Signature · 1 line
2.25.1
#8 lore raw

PATCH v2 2/2 io_uring: use typesafe pointers in io_uring_task

In reply to Stefan Metzmacher
---
 fs/io_uring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/io_uring.c +2 -2
index 52b5ed71d770..f048c42d8b8f 100644
@@ -458,8 +458,8 @@ struct io_uring_task {
 	/* submission side */
 	struct xarray		xa;
 	struct wait_queue_head	wait;
-	void			*last;
-	void			*io_wq;
+	const struct io_ring_ctx *last;
+	struct io_wq		*io_wq;
 	struct percpu_counter	inflight;
 	atomic_t		in_idle;
 	bool			sqpoll;
Signature · 1 line
2.25.1
maintainer
#5 lore raw
In reply to Pavel Begunkov
Quoted 11 lines · Pavel Begunkov
Quoted 10 lines · Stefan Metzmacher

Hi Pavel,

Quoted 2 lines

Both patches are really nice. However, 1/2 doesn't apply and looks it needs small stylistic changes, see nits below

It seems the mails got corrupted, I played with git imap-send... :-(

Here a branch with the patches:
https://git.samba.org/?p=metze/linux/wip.git;a=shortlog;h=refs/heads/io_uring-5.12

Quoted 6 lines
Quoted 1 line

Should I resend them once I fixed my mail setup?

Who knows. Jens, do you want to take it for 5.12?

I just recently converted tctx->last from file* to ctx* and had to gaze enough to not screw, in this light 2/2 looks good from the safety perspective.

Let's do them for 5.12 - Stefan, can you resend please?

Signature · 1 line
Jens Axboe
maintainer
#9 lore raw

Re: [PATCH v2 0/2] Some header cleanups

In reply to Stefan Metzmacher
Quoted 9 lines · Stefan Metzmacher

Hi,

here're a few cleanups in order to make structures as private and typesafe as possible. It also cleans up the layering from io_uring.c being on top of io-wq.*.

Changes since v1:

- None, hopefully correct patch format now.

And I see you already did resend, thanks I'll take them for 5.12.

Signature · 1 line
Jens Axboe