[lkml]   [2015]   [Nov]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRE: [PATCH 4/5] NVMe: add blk polling support
> -----Original Message-----
> From: [mailto:linux-kernel-
>] On Behalf Of Jens Axboe
> Sent: Friday, November 6, 2015 11:20 AM
> Subject: [PATCH 4/5] NVMe: add blk polling support
> Add nvme_poll(), which will check a specific completion queue for
> command completions. Wire that up to the new block layer poll
> mechanism.
> Later on we'll setup specific sq/cq pairs that don't have interrups
> enabled, so we can do more efficient polling. As of this patch, an
> IRQ will still trigger on command completion.
> -static int nvme_process_cq(struct nvme_queue *nvmeq)
> +static void __nvme_process_cq(struct nvme_queue *nvmeq, unsigned int
> *tag)
> {
> u16 head, phase;
> @@ -953,6 +953,8 @@ static int nvme_process_cq(struct nvme_queue *nvmeq)
> head = 0;
> phase = !phase;
> }
> + if (tag && *tag == cqe.command_id)
> + *tag = -1;
> ctx = nvme_finish_cmd(nvmeq, cqe.command_id, &fn);
> fn(nvmeq, ctx, &cqe);
> }

The NVMe completion queue entries are 16 bytes long. Although it's
most likely to write them from 0..15 in one PCIe Memory Write
transaction, the NVMe device could write those bytes in any order.
It could thus update the command identifier before the other bytes,
causing this code to process invalid stale values in the other

When using interrupts, the MSI-X interrupt ensures the whole entry
is updated first, since it is delivered with a PCIe Memory Write
transaction and upstream writes do not pass upstream writes.

The existing interrupt handler loops looking for additional
completions, so is susceptible to this same problem - it's
just less likely. The only concern is completions that are
added while the CPU is in the interrupt handler.

Robert Elliott, HPE Persistent Memory

 \ /
  Last update: 2015-11-07 01:01    [W:0.057 / U:11.252 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site