From: Oleg Nesterov <oleg@redhat.com>
To: Josef Bacik <josef@toxicpanda.com>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org, kernel-team@fb.com,
peterz@infradead.org
Subject: Re: [PATCH 3/4] rq-qos: use READ_ONCE/WRITE_ONCE for got_token
Date: Tue, 16 Jul 2019 10:29:56 +0200 [thread overview]
Message-ID: <20190716082955.GA15528@redhat.com> (raw)
In-Reply-To: <20190715201120.72749-4-josef@toxicpanda.com>
On 07/15, Josef Bacik wrote:
>
> Oleg noticed that our checking of data.got_token is unsafe in the
> cleanup case, and should really use a memory barrier. Use the
> READ_ONCE/WRITE_ONCE helpers on got_token so we can be sure we're always
> safe.
READ/WRITE_ONCE can't help, both are compiler barriers. You need smp_wmb/rmb.
Alternatively,
> @@ -246,7 +246,7 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
> prepare_to_wait_exclusive(&rqw->wait, &data.wq, TASK_UNINTERRUPTIBLE);
> has_sleeper = !wq_has_single_sleeper(&rqw->wait);
> do {
> - if (data.got_token)
> + if (READ_ONCE(data.got_token))
> break;
> if (!has_sleeper && acquire_inflight_cb(rqw, private_data)) {
> finish_wait(&rqw->wait, &data.wq);
You can use remove_wait_queue() which takes rqw->wait->lock unconditonally,
but then you will need to do __set_current_state(TASK_RUNNING) and use
"return" instead of break.
Oleg.
next prev parent reply other threads:[~2019-07-16 8:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-15 20:11 [PATCH 0/4][v2] rq-qos memory barrier shenanigans Josef Bacik
2019-07-15 20:11 ` [PATCH 1/4] wait: add wq_has_single_sleeper helper Josef Bacik
2019-07-15 20:11 ` [PATCH 2/4] rq-qos: fix missed wake-ups in rq_qos_throttle Josef Bacik
2019-07-15 20:11 ` [PATCH 3/4] rq-qos: use READ_ONCE/WRITE_ONCE for got_token Josef Bacik
2019-07-16 8:29 ` Oleg Nesterov [this message]
2019-07-15 20:11 ` [PATCH 4/4] rq-qos: don't reset has_sleepers on spurious wakeups Josef Bacik
2019-07-16 8:35 ` Oleg Nesterov
2019-07-16 8:39 ` [PATCH 0/4][v2] rq-qos memory barrier shenanigans 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=20190716082955.GA15528@redhat.com \
--to=oleg@redhat.com \
--cc=axboe@kernel.dk \
--cc=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-block@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.