public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH for-5.15] io-wq: move nr_running and worker_refs out of wqe->lock protection
@ 2021-08-10 12:55 Hao Xu
  2021-08-18  9:22 ` Hao Xu
  2021-08-18 13:27 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Hao Xu @ 2021-08-10 12:55 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, Pavel Begunkov, Joseph Qi

We don't need to protect nr_running and worker_refs by wqe->lock, so
narrow the range of raw_spin_lock_irq - raw_spin_unlock_irq

Signed-off-by: Hao Xu <[email protected]>
---
 fs/io-wq.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/io-wq.c b/fs/io-wq.c
index 4ce83bb48021..8da9bb103916 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -256,16 +256,17 @@ static void io_wqe_wake_worker(struct io_wqe *wqe, struct io_wqe_acct *acct)
 
 		raw_spin_lock_irq(&wqe->lock);
 		if (acct->nr_workers < acct->max_workers) {
-			atomic_inc(&acct->nr_running);
-			atomic_inc(&wqe->wq->worker_refs);
 			if (!acct->nr_workers)
 				first = true;
 			acct->nr_workers++;
 			do_create = true;
 		}
 		raw_spin_unlock_irq(&wqe->lock);
-		if (do_create)
+		if (do_create) {
+			atomic_inc(&acct->nr_running);
+			atomic_inc(&wqe->wq->worker_refs);
 			create_io_worker(wqe->wq, wqe, acct->index, first);
+		}
 	}
 }
 
-- 
2.24.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH for-5.15] io-wq: move nr_running and worker_refs out of wqe->lock protection
  2021-08-10 12:55 [PATCH for-5.15] io-wq: move nr_running and worker_refs out of wqe->lock protection Hao Xu
@ 2021-08-18  9:22 ` Hao Xu
  2021-08-18 13:27 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Hao Xu @ 2021-08-18  9:22 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, Pavel Begunkov, Joseph Qi

在 2021/8/10 下午8:55, Hao Xu 写道:
ping
> We don't need to protect nr_running and worker_refs by wqe->lock, so
> narrow the range of raw_spin_lock_irq - raw_spin_unlock_irq
> 
> Signed-off-by: Hao Xu <[email protected]>
> ---
>   fs/io-wq.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/io-wq.c b/fs/io-wq.c
> index 4ce83bb48021..8da9bb103916 100644
> --- a/fs/io-wq.c
> +++ b/fs/io-wq.c
> @@ -256,16 +256,17 @@ static void io_wqe_wake_worker(struct io_wqe *wqe, struct io_wqe_acct *acct)
>   
>   		raw_spin_lock_irq(&wqe->lock);
>   		if (acct->nr_workers < acct->max_workers) {
> -			atomic_inc(&acct->nr_running);
> -			atomic_inc(&wqe->wq->worker_refs);
>   			if (!acct->nr_workers)
>   				first = true;
>   			acct->nr_workers++;
>   			do_create = true;
>   		}
>   		raw_spin_unlock_irq(&wqe->lock);
> -		if (do_create)
> +		if (do_create) {
> +			atomic_inc(&acct->nr_running);
> +			atomic_inc(&wqe->wq->worker_refs);
>   			create_io_worker(wqe->wq, wqe, acct->index, first);
> +		}
>   	}
>   }
>   
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH for-5.15] io-wq: move nr_running and worker_refs out of wqe->lock protection
  2021-08-10 12:55 [PATCH for-5.15] io-wq: move nr_running and worker_refs out of wqe->lock protection Hao Xu
  2021-08-18  9:22 ` Hao Xu
@ 2021-08-18 13:27 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2021-08-18 13:27 UTC (permalink / raw)
  To: Hao Xu; +Cc: io-uring, Pavel Begunkov, Joseph Qi

On 8/10/21 6:55 AM, Hao Xu wrote:
> We don't need to protect nr_running and worker_refs by wqe->lock, so
> narrow the range of raw_spin_lock_irq - raw_spin_unlock_irq

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-18 13:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-10 12:55 [PATCH for-5.15] io-wq: move nr_running and worker_refs out of wqe->lock protection Hao Xu
2021-08-18  9:22 ` Hao Xu
2021-08-18 13:27 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox