io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Hao Xu <haoxu@linux.alibaba.com>,
	Bixuan Cui <cuibixuan@huawei.com>,
	linux-kernel@vger.kernel.org, io-uring@vger.kernel.org
Cc: asml.silence@gmail.com, Joseph Qi <joseph.qi@linux.alibaba.com>
Subject: Re: [PATCH -next] io-wq: Remove duplicate code in io_workqueue_create()
Date: Wed, 15 Sep 2021 12:12:12 -0600	[thread overview]
Message-ID: <ba41595d-d7a7-4641-3c4c-26ddfe01eaed@kernel.dk> (raw)
In-Reply-To: <49d9bb13-a7b3-48b5-20ef-d3b72052f92b@linux.alibaba.com>

On 9/12/21 9:36 AM, Hao Xu wrote:
> 在 2021/9/11 下午4:58, Bixuan Cui 写道:
>> While task_work_add() in io_workqueue_create() is true,
>> then duplicate code is executed:
>>
>>    -> clear_bit_unlock(0, &worker->create_state);
>>    -> io_worker_release(worker);
>>    -> atomic_dec(&acct->nr_running);
>>    -> io_worker_ref_put(wq);
>>    -> return false;
>>
>>    -> clear_bit_unlock(0, &worker->create_state); // back to io_workqueue_create()
>>    -> io_worker_release(worker);
>>    -> kfree(worker);
>>
>> The io_worker_release() and clear_bit_unlock() are executed twice.
>>
>> Fixes: 3146cba99aa2 ("io-wq: make worker creation resilient against signals")
>> Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
>> ---
>>   fs/io-wq.c | 9 ++++-----
>>   1 file changed, 4 insertions(+), 5 deletions(-)
>>
>> diff --git a/fs/io-wq.c b/fs/io-wq.c
>> index 6c55362c1f99..95d0eaed7c00 100644
>> --- a/fs/io-wq.c
>> +++ b/fs/io-wq.c
>> @@ -329,8 +329,10 @@ static bool io_queue_worker_create(struct io_worker *worker,
>>   
>>   	init_task_work(&worker->create_work, func);
>>   	worker->create_index = acct->index;
>> -	if (!task_work_add(wq->task, &worker->create_work, TWA_SIGNAL))
>> +	if (!task_work_add(wq->task, &worker->create_work, TWA_SIGNAL)) {
>> +		clear_bit_unlock(0, &worker->create_state);
>>   		return true;
>> +	}
>>   	clear_bit_unlock(0, &worker->create_state);
>>   fail_release:
>>   	io_worker_release(worker);
>> @@ -723,11 +725,8 @@ static void io_workqueue_create(struct work_struct *work)
>>   	struct io_worker *worker = container_of(work, struct io_worker, work);
>>   	struct io_wqe_acct *acct = io_wqe_get_acct(worker);
>>   
>> -	if (!io_queue_worker_create(worker, acct, create_worker_cont)) {
>> -		clear_bit_unlock(0, &worker->create_state);
>> -		io_worker_release(worker);
>> +	if (!io_queue_worker_create(worker, acct, create_worker_cont))
>>   		kfree(worker);
>> -	}
>>   }
>>   
>>   static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index)
>>
> AFAIK, this looks reasonable for me.

I took that as a reviewed-by, let me know if that isn't correct.

-- 
Jens Axboe


      reply	other threads:[~2021-09-15 18:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-11  8:58 [PATCH -next] io-wq: Remove duplicate code in io_workqueue_create() Bixuan Cui
2021-09-12 15:36 ` Hao Xu
2021-09-15 18:12   ` Jens Axboe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba41595d-d7a7-4641-3c4c-26ddfe01eaed@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=cuibixuan@huawei.com \
    --cc=haoxu@linux.alibaba.com \
    --cc=io-uring@vger.kernel.org \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).