linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH rfc] nvme-pci: make sure to flush sqe writes before db record update
Date: Thu, 31 May 2018 02:34:33 +0300	[thread overview]
Message-ID: <84ebcf65-d1a2-2ee5-d4d7-b96d61ed3c16@grimberg.me> (raw)
In-Reply-To: <c6a92092-f1f0-cf3c-3f34-fe5904d9718b@grimberg.me>

resurrecting this one...

Can anyone say why this is _not_ needed?

On 03/08/2018 07:56 PM, Sagi Grimberg wrote:
> 
>>>> @@ -437,8 +437,14 @@ static void __nvme_submit_cmd(struct nvme_queue 
>>>> *nvmeq,
>>>> ????? if (++tail == nvmeq->q_depth)
>>>> ????????? tail = 0;
>>>> ????? if (nvme_dbbuf_update_and_check_event(tail, nvmeq->dbbuf_sq_db,
>>>> -????????????????????????? nvmeq->dbbuf_sq_ei))
>>>> +????????????????????????? nvmeq->dbbuf_sq_ei)) {
>>>> +??????? /*
>>>> +???????? * Make sure that descriptors are written before
>>>> +???????? * doorbell record.
>>>> +???????? */
>>>> +??????? wmb();
>>>> ????????? writel(tail, nvmeq->q_db);
>>>> +??? }
>>>> ????? nvmeq->sq_tail = tail;
>>>> ? }
>>>
>>> If this really is necessary, we'd need this before updating the event
>>> shadow registers too.
>>>
>>> I'd like to understand this a bit more as we haven't done this in eight
>>> years and I can't recall any issues around this section. Have we just
>>> been fortunate that the problem this fixes is extraordinarily unlikely,
>>> or is something else implicitly ordering within this critical section?
>>
>> Well, there is a wmb() already inside
>> nvme_dbbuf_update_and_check_event so any failure would only
>> be related to dbbuf_sq_db being wrong when tail is written to q_db.
> 
> Right, we have that covered.
> 
>> Guessing that might be a basically undetectable situation, maybe some
>> temporary higher latency or something?
> 
> If the SQE and DB update have been reordered, and the device was able
> to fetch the old copy of the SQE, it would be either silent data
> corruption or dma access to unmapped memory or unexpected behavior (if
> the SQE wasn't initialized). I just think its a *very* rare race that
> can happen...

  parent reply	other threads:[~2018-05-30 23:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 17:56 [PATCH rfc] nvme-pci: make sure to flush sqe writes before db record update Sagi Grimberg
2018-03-08  7:56 ` Christoph Hellwig
2018-03-08 15:51 ` Keith Busch
2018-03-08 17:20   ` Jason Gunthorpe
2018-03-08 17:37     ` Keith Busch
2018-03-08 17:56     ` Sagi Grimberg
2018-03-08 18:36       ` Jason Gunthorpe
2018-03-08 18:42         ` Keith Busch
2018-05-30 23:34       ` Sagi Grimberg [this message]
2018-05-31  5:47         ` Christoph Hellwig
2018-05-31  7:53           ` Sagi Grimberg
2018-05-31 15:20             ` Jason Gunthorpe

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=84ebcf65-d1a2-2ee5-d4d7-b96d61ed3c16@grimberg.me \
    --to=sagi@grimberg.me \
    /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).