From: Jens Axboe <axboe@kernel.dk>
To: Bart Van Assche <bvanassche@acm.org>,
Damien Le Moal <dlemoal@kernel.org>,
"lsf-pc@lists.linux-foundation.org"
<lsf-pc@lists.linux-foundation.org>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [LSF/MM/BPF TOPIC] Improving Zoned Storage Support
Date: Wed, 17 Jan 2024 14:40:55 -0700 [thread overview]
Message-ID: <90de77e4-ed8a-47be-b5df-2178913ec115@kernel.dk> (raw)
In-Reply-To: <86a1f9e6-d3ae-4051-8528-13a952cf74a1@acm.org>
On 1/17/24 2:33 PM, Bart Van Assche wrote:
> On 1/17/24 13:14, Jens Axboe wrote:
>> /* Maps an I/O priority class to a deadline scheduler priority. */
>> @@ -600,6 +604,10 @@ static struct request *dd_dispatch_request(struct blk_mq_hw_ctx *hctx)
>> struct request *rq;
>> enum dd_prio prio;
>> + if (test_bit(0, &dd->dispatch_state) ||
>> + test_and_set_bit(0, &dd->dispatch_state))
>> + return NULL;
>> +
>> spin_lock(&dd->lock);
>> rq = dd_dispatch_prio_aged_requests(dd, now);
>> if (rq)
>> @@ -616,6 +624,7 @@ static struct request *dd_dispatch_request(struct blk_mq_hw_ctx *hctx)
>> }
>> unlock:
>> + clear_bit(0, &dd->dispatch_state);
>> spin_unlock(&dd->lock);
>
> Can the above code be simplified by using spin_trylock() instead of
> test_bit() and test_and_set_bit()?
It can't, because you can't assume that just because dd->lock is already
being held that dispatch is running.
> Please note that whether or not spin_trylock() is used, there is a
> race condition in this approach: if dd_dispatch_request() is called
> just before another CPU calls spin_unlock() from inside
> dd_dispatch_request() then some requests won't be dispatched until the
> next time dd_dispatch_request() is called.
Sure, that's not surprising. What I cared most about here is that we
should not have a race such that we'd stall. Since we haven't returned
this request just yet if we race, we know at least one will be issued
and we'll re-run at completion. So yeah, we may very well skip an issue,
that's well known within that change, which will be postponed to the
next queue run.
The patch is more to demonstrate that it would not take much to fix this
case, at least, it's a proof-of-concept.
--
Jens Axboe
next prev parent reply other threads:[~2024-01-17 21:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-16 18:20 [LSF/MM/BPF TOPIC] Improving Zoned Storage Support Bart Van Assche
2024-01-16 23:34 ` Damien Le Moal
2024-01-17 1:21 ` Bart Van Assche
2024-01-17 17:36 ` Bart Van Assche
2024-01-17 17:48 ` Jens Axboe
2024-01-17 18:22 ` Bart Van Assche
2024-01-17 18:43 ` Jens Axboe
2024-01-17 20:06 ` Jens Axboe
2024-01-17 20:18 ` Bart Van Assche
2024-01-17 20:20 ` Jens Axboe
2024-01-17 21:02 ` Jens Axboe
2024-01-17 21:14 ` Jens Axboe
2024-01-17 21:33 ` Bart Van Assche
2024-01-17 21:40 ` Jens Axboe [this message]
2024-01-18 0:43 ` Bart Van Assche
2024-01-18 14:51 ` Jens Axboe
2024-01-18 0:38 ` Bart Van Assche
2024-01-18 0:42 ` Jens Axboe
2024-01-18 0:54 ` Bart Van Assche
2024-01-18 15:07 ` Jens Axboe
2024-01-17 8:15 ` Viacheslav Dubeyko
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=90de77e4-ed8a-47be-b5df-2178913ec115@kernel.dk \
--to=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=dlemoal@kernel.org \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=lsf-pc@lists.linux-foundation.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