* [PATCH 1/1] io-wq: close cancel gap for hashed linked work
@ 2020-03-22 16:14 Pavel Begunkov
2020-03-22 17:04 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: Pavel Begunkov @ 2020-03-22 16:14 UTC (permalink / raw)
To: Jens Axboe, io-uring, linux-kernel
After io_assign_current_work() of a linked work, it can be decided to
offloaded to another thread so doing io_wqe_enqueue(). However, until
next io_assign_current_work() it can be cancelled, that isn't handled.
Don't assign it, if it's not going to be executed.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io-wq.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/io-wq.c b/fs/io-wq.c
index 9541df2729de..b3fb61ec0870 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -485,7 +485,7 @@ static void io_worker_handle_work(struct io_worker *worker)
struct io_wq *wq = wqe->wq;
do {
- struct io_wq_work *work;
+ struct io_wq_work *work, *assign_work;
unsigned int hash;
get_next:
/*
@@ -522,10 +522,14 @@ static void io_worker_handle_work(struct io_worker *worker)
hash = io_get_work_hash(work);
work->func(&work);
work = (old_work == work) ? NULL : work;
- io_assign_current_work(worker, work);
+
+ assign_work = work;
+ if (work && io_wq_is_hashed(work))
+ assign_work = NULL;
+ io_assign_current_work(worker, assign_work);
wq->free_work(old_work);
- if (work && io_wq_is_hashed(work)) {
+ if (work && !assign_work) {
io_wqe_enqueue(wqe, work);
work = NULL;
}
--
2.24.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] io-wq: close cancel gap for hashed linked work
2020-03-22 16:14 [PATCH 1/1] io-wq: close cancel gap for hashed linked work Pavel Begunkov
@ 2020-03-22 17:04 ` Jens Axboe
2020-03-22 17:31 ` Pavel Begunkov
2020-03-22 17:33 ` [PATCH v2] " Pavel Begunkov
0 siblings, 2 replies; 4+ messages in thread
From: Jens Axboe @ 2020-03-22 17:04 UTC (permalink / raw)
To: Pavel Begunkov, io-uring, linux-kernel
On 3/22/20 10:14 AM, Pavel Begunkov wrote:
> After io_assign_current_work() of a linked work, it can be decided to
> offloaded to another thread so doing io_wqe_enqueue(). However, until
> next io_assign_current_work() it can be cancelled, that isn't handled.
>
> Don't assign it, if it's not going to be executed.
This needs a Fixes: line as well. I'm guessing like this:
Fixes: 60cf46ae6054 ("io-wq: hash dependent work")
but I didn't look too closely yet... Fix looks good, though.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] io-wq: close cancel gap for hashed linked work
2020-03-22 17:04 ` Jens Axboe
@ 2020-03-22 17:31 ` Pavel Begunkov
2020-03-22 17:33 ` [PATCH v2] " Pavel Begunkov
1 sibling, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2020-03-22 17:31 UTC (permalink / raw)
To: Jens Axboe, io-uring, linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 601 bytes --]
On 22/03/2020 20:04, Jens Axboe wrote:
> On 3/22/20 10:14 AM, Pavel Begunkov wrote:
>> After io_assign_current_work() of a linked work, it can be decided to
>> offloaded to another thread so doing io_wqe_enqueue(). However, until
>> next io_assign_current_work() it can be cancelled, that isn't handled.
>>
>> Don't assign it, if it's not going to be executed.
>
> This needs a Fixes: line as well. I'm guessing like this:
>
> Fixes: 60cf46ae6054 ("io-wq: hash dependent work")
>
> but I didn't look too closely yet... Fix looks good, though.
Yep, this one
--
Pavel Begunkov
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] io-wq: close cancel gap for hashed linked work
2020-03-22 17:04 ` Jens Axboe
2020-03-22 17:31 ` Pavel Begunkov
@ 2020-03-22 17:33 ` Pavel Begunkov
1 sibling, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2020-03-22 17:33 UTC (permalink / raw)
To: Jens Axboe, io-uring, linux-kernel
After io_assign_current_work() of a linked work, it can be decided to
offloaded to another thread so doing io_wqe_enqueue(). However, until
next io_assign_current_work() it can be cancelled, that isn't handled.
Don't assign it, if it's not going to be executed.
Fixes: 60cf46ae605446feb0c43c472c0 ("io-wq: hash dependent work")
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io-wq.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/io-wq.c b/fs/io-wq.c
index 9541df2729de..b3fb61ec0870 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -485,7 +485,7 @@ static void io_worker_handle_work(struct io_worker *worker)
struct io_wq *wq = wqe->wq;
do {
- struct io_wq_work *work;
+ struct io_wq_work *work, *assign_work;
unsigned int hash;
get_next:
/*
@@ -522,10 +522,14 @@ static void io_worker_handle_work(struct io_worker *worker)
hash = io_get_work_hash(work);
work->func(&work);
work = (old_work == work) ? NULL : work;
- io_assign_current_work(worker, work);
+
+ assign_work = work;
+ if (work && io_wq_is_hashed(work))
+ assign_work = NULL;
+ io_assign_current_work(worker, assign_work);
wq->free_work(old_work);
- if (work && io_wq_is_hashed(work)) {
+ if (work && !assign_work) {
io_wqe_enqueue(wqe, work);
work = NULL;
}
--
2.24.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-22 17:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-22 16:14 [PATCH 1/1] io-wq: close cancel gap for hashed linked work Pavel Begunkov
2020-03-22 17:04 ` Jens Axboe
2020-03-22 17:31 ` Pavel Begunkov
2020-03-22 17:33 ` [PATCH v2] " Pavel Begunkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox