From: Hao Xu <[email protected]>
To: Jens Axboe <[email protected]>
Cc: [email protected], Pavel Begunkov <[email protected]>,
Joseph Qi <[email protected]>
Subject: Re: [RFC] io-wq: decouple work_list protection from the big wqe->lock
Date: Thu, 4 Nov 2021 19:35:15 +0800 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
在 2021/11/4 上午3:10, Jens Axboe 写道:
> On 10/31/21 4:49 AM, Hao Xu wrote:
>> @@ -380,10 +382,14 @@ static void io_wqe_dec_running(struct io_worker *worker)
>> if (!(worker->flags & IO_WORKER_F_UP))
>> return;
>>
>> + raw_spin_lock(&acct->lock);
>> if (atomic_dec_and_test(&acct->nr_running) && io_acct_run_queue(acct)) {
>> + raw_spin_unlock(&acct->lock);
>> atomic_inc(&acct->nr_running);
>> atomic_inc(&wqe->wq->worker_refs);
>> io_queue_worker_create(worker, acct, create_worker_cb);
>> + } else {
>> + raw_spin_unlock(&acct->lock);
>> }
>> }
>
> I think this may be more readable as:
>
> static void io_wqe_dec_running(struct io_worker *worker)
> __must_hold(wqe->lock)
> {
> struct io_wqe_acct *acct = io_wqe_get_acct(worker);
> struct io_wqe *wqe = worker->wqe;
>
> if (!(worker->flags & IO_WORKER_F_UP))
> return;
> if (!atomic_dec_and_test(&acct->nr_running))
> return;
>
> raw_spin_lock(&acct->lock);
> if (!io_acct_run_queue(acct)) {
> raw_spin_unlock(&acct->lock);
> return;
> }
>
> raw_spin_unlock(&acct->lock);
> atomic_inc(&acct->nr_running);
> atomic_inc(&wqe->wq->worker_refs);
> io_queue_worker_create(worker, acct, create_worker_cb);
> }
>
> ?
>
> Patch looks pretty sane to me, but there's a lot of lock shuffling going
> on for it. Like in io_worker_handle_work(), and particularly in
> io_worker_handle_work(). I think it'd be worthwhile to spend some time
> to see if that could be improved. These days, lock contention is more
> about frequency of lock grabbing rather than hold time. Maybe clean
> nesting of wqe->lock -> acct->lock (which would be natural) can help
> that?
Sure, I'm working on reduce the lock contension further, will
update it and send the whole patchset later.
Regards,
Hao
>
next prev parent reply other threads:[~2021-11-04 11:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-31 10:49 [RFC] io-wq: decouple work_list protection from the big wqe->lock Hao Xu
2021-10-31 13:03 ` Hao Xu
2021-11-03 12:17 ` Hao Xu
2021-11-03 12:22 ` Jens Axboe
2021-11-03 12:53 ` Hao Xu
2021-11-03 19:10 ` Jens Axboe
2021-11-04 11:35 ` Hao Xu [this message]
2021-11-04 14:57 ` Jens Axboe
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=b77a69a7-5637-0d20-bbf1-d8d2936fdd16@linux.alibaba.com \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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