Skip to contentSkip to conversation

clean io_wq->do_work()

PATCH Applied Pavel Begunkov 2 participants 4 messages Jun 25, 2020

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

PATCH 1/2 io-wq: compact io-wq flags numbers

In reply to Pavel Begunkov

Renumerate IO_WQ flags, so they take adjacent bits

---
 fs/io-wq.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/io-wq.h +4 -4
index 071f1a997800..04239dfb12b0 100644
@@ -5,10 +5,10 @@ struct io_wq;
 
 enum {
 	IO_WQ_WORK_CANCEL	= 1,
-	IO_WQ_WORK_HASHED	= 4,
-	IO_WQ_WORK_UNBOUND	= 32,
-	IO_WQ_WORK_NO_CANCEL	= 256,
-	IO_WQ_WORK_CONCURRENT	= 512,
+	IO_WQ_WORK_HASHED	= 2,
+	IO_WQ_WORK_UNBOUND	= 4,
+	IO_WQ_WORK_NO_CANCEL	= 8,
+	IO_WQ_WORK_CONCURRENT	= 16,
 
 	IO_WQ_HASH_SHIFT	= 24,	/* upper 8 bits are used for hash key */
 };
Signature · 1 line
2.24.0
#0 lore raw

cover clean io_wq->do_work()

Small io-wq cleanups after getting rid of per-work callbacks.

Pavel Begunkov (2):
io-wq: compact io-wq flags numbers
io-wq: return next work from ->do_work() directly

 fs/io-wq.c    |  8 +++-----
 fs/io-wq.h    | 10 +++++-----
 fs/io_uring.c | 53 ++++++++++++++++++++-------------------------------
 3 files changed, 29 insertions(+), 42 deletions(-)
Signature · 1 line
2.24.0
#2 lore raw

PATCH 2/2 io-wq: return next work from ->do_work() directly

It's easier to return next work from ->do_work() than having an in-out argument. Looks nicer and easier to compile. Also, merge io_wq_assign_next() into its only user.

---
 fs/io-wq.c    |  8 +++-----
 fs/io-wq.h    |  2 +-
 fs/io_uring.c | 53 ++++++++++++++++++++-------------------------------
 3 files changed, 25 insertions(+), 38 deletions(-)
fs/io-wq.c +3 -5
index 47c5f3aeb460..72f759e1d6eb 100644
@@ -523,9 +523,8 @@ static void io_worker_handle_work(struct io_worker *worker)
 				work->flags |= IO_WQ_WORK_CANCEL;
 
 			hash = io_get_work_hash(work);
-			linked = old_work = work;
-			wq->do_work(&linked);
-			linked = (old_work == linked) ? NULL : linked;
+			old_work = work;
+			linked = wq->do_work(work);
 
 			work = next_hashed;
 			if (!work && linked && !io_wq_is_hashed(linked)) {
@@ -781,8 +780,7 @@ static void io_run_cancel(struct io_wq_work *work, struct io_wqe *wqe)
 		struct io_wq_work *old_work = work;
 
 		work->flags |= IO_WQ_WORK_CANCEL;
-		wq->do_work(&work);
-		work = (work == old_work) ? NULL : work;
+		work = wq->do_work(work);
 		wq->free_work(old_work);
 	} while (work);
 }
fs/io-wq.h +1 -1
index 04239dfb12b0..114f12ec2d65 100644
@@ -101,7 +101,7 @@ static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)
 }
 
 typedef void (free_work_fn)(struct io_wq_work *);
-typedef void (io_wq_work_fn)(struct io_wq_work **);
+typedef struct io_wq_work *(io_wq_work_fn)(struct io_wq_work *);
 
 struct io_wq_data {
 	struct user_struct *user;
fs/io_uring.c +21 -32

88 lines not on this page · raw message

Signature · 1 line
2.24.0
maintainer Applied
#3 lore raw
In reply to Pavel Begunkov
Quoted 10 lines · Pavel Begunkov

Small io-wq cleanups after getting rid of per-work callbacks.

Pavel Begunkov (2):
io-wq: compact io-wq flags numbers
io-wq: return next work from ->do_work() directly

 fs/io-wq.c    |  8 +++-----
 fs/io-wq.h    | 10 +++++-----
 fs/io_uring.c | 53 ++++++++++++++++++++-------------------------------
 3 files changed, 29 insertions(+), 42 deletions(-)

Applied, thanks.

Signature · 1 line
Jens Axboe