From: Oleg Nesterov <oleg@redhat.com>
To: Jens Axboe <axboe@fb.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Jens Axboe <axboe@kernel.dk>, Josef Bacik <josef@toxicpanda.com>,
Kernel Team <Kernel-team@fb.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH 1/2] wait: add wq_has_multiple_sleepers helper
Date: Thu, 11 Jul 2019 15:40:06 +0200 [thread overview]
Message-ID: <20190711134006.GA19160@redhat.com> (raw)
In-Reply-To: <20190711114543.GA14901@redhat.com>
On 07/11, Oleg Nesterov wrote:
>
> Jens,
>
> I managed to convince myself I understand why 2/2 needs this change...
> But rq_qos_wait() still looks suspicious to me. Why can't the main loop
> "break" right after io_schedule()? rq_qos_wake_function() either sets
> data->got_token = true or it doesn't wakeup the waiter sleeping in
> io_schedule()
>
> This means that data.got_token = F at the 2nd iteration is only possible
> after a spurious wakeup, right? But in this case we need to set state =
> TASK_UNINTERRUPTIBLE again to avoid busy-wait looping ?
Oh. I can be easily wrong, I never read this code before, but it seems to
me there is another unrelated race.
rq_qos_wait() can't rely on finish_wait() because it doesn't necessarily
take wq_head->lock.
rq_qos_wait() inside the main loop does
if (!has_sleeper && acquire_inflight_cb(rqw, private_data)) {
finish_wait(&rqw->wait, &data.wq);
/*
* We raced with wbt_wake_function() getting a token,
* which means we now have two. Put our local token
* and wake anyone else potentially waiting for one.
*/
if (data.got_token)
cleanup_cb(rqw, private_data);
break;
}
finish_wait() + "if (data.got_token)" can race with rq_qos_wake_function()
which does
data->got_token = true;
list_del_init(&curr->entry);
rq_qos_wait() can see these changes out-of-order: finish_wait() can see
list_empty_careful() == T and avoid wq_head->lock, and in this case the
code above can see data->got_token = false.
No?
and I don't really understand
has_sleeper = false;
at the end of the main loop. I think it should do "has_sleeper = true",
we need to execute the code above only once, right after prepare_to_wait().
But this is harmless.
Oleg.
next prev parent reply other threads:[~2019-07-11 13:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-10 19:52 [PATCH 1/2] wait: add wq_has_multiple_sleepers helper Josef Bacik
2019-07-10 19:52 ` [PATCH 2/2] rq-qos: fix missed wake-ups in rq_qos_throttle Josef Bacik
2019-07-10 20:23 ` [PATCH 1/2] wait: add wq_has_multiple_sleepers helper Jens Axboe
2019-07-10 20:35 ` Peter Zijlstra
2019-07-10 20:39 ` Jens Axboe
2019-07-11 11:45 ` Oleg Nesterov
2019-07-11 13:40 ` Oleg Nesterov [this message]
2019-07-11 19:21 ` Josef Bacik
2019-07-12 8:05 ` Oleg Nesterov
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=20190711134006.GA19160@redhat.com \
--to=oleg@redhat.com \
--cc=Kernel-team@fb.com \
--cc=axboe@fb.com \
--cc=axboe@kernel.dk \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.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).