public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Bart Van Assche <bvanassche@acm.org>,
	Gabriel Ryan <gabe@cs.columbia.edu>,
	linux-block@vger.kernel.org
Subject: Re: Race in block/blk-mq-sched.c blk_mq_sched_dispatch_requests
Date: Wed, 17 Jan 2024 13:28:07 -0700	[thread overview]
Message-ID: <3f676f69-690a-480c-850d-ff1d9e502e4f@kernel.dk> (raw)
In-Reply-To: <37b7836b-f231-4bf5-bee1-7571f889d6ff@acm.org>

On 1/17/24 1:22 PM, Bart Van Assche wrote:
> On 1/17/24 12:17, Jens Axboe wrote:
>> On 1/17/24 1:16 PM, Gabriel Ryan wrote:
>>> We found a race in the block message queue for kernel v5.18-rc5 using
>>> a race testing tool we are developing. We are reporting this race
>>> because it appears to be potentially harmful. The race occurs in
>>>
>>> block/blk-mq-sched.c:333 blk_mq_sched_dispatch_requests
>>>
>>>      hctx->run++;
>>>
>>> where multiple threads can schedule dispatch requests and increment
>>> the request counter htctx->run simultaneously. This appears to lead to
>>> undefined behavior where multiple conflicting updates to the hctx->run
>>> value could result in it not matching the number of requests that
>>> have been scheduled with calls to blk_mq_sched_dispatch_requests.
>>
>> I suggest you take a closer look at how that variable is actually
>> used.
> 
> It's probably a good idea to explain this in a comment above the
> code that increments hctx->runs because others may also be wondering
> what the impact is of concurrent hctx->runs increments.

If you do a quick grep, you'll very quickly see that it's just used
for debugfs output. Being racy is not a problem. It should just get
removed, honestly, like I did with some of the other accounting some
time ago.

-- 
Jens Axboe



  reply	other threads:[~2024-01-17 20:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 20:16 Race in block/blk-mq-sched.c blk_mq_sched_dispatch_requests Gabriel Ryan
2024-01-17 20:17 ` Jens Axboe
2024-01-17 20:22   ` Bart Van Assche
2024-01-17 20:28     ` Jens Axboe [this message]
2024-01-17 20:36       ` Gabriel Ryan
2024-01-17 20:49         ` 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=3f676f69-690a-480c-850d-ff1d9e502e4f@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=gabe@cs.columbia.edu \
    --cc=linux-block@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