Skip to content

Commit e2a366a

Browse files
Alexey Dobriyankeithbusch
authored andcommitted
nvme-pci: slimmer CQ head update
Update CQ head with pre-increment operator. This saves subtraction of 1 and a few registers. Also update phase with "^= 1". This generates only one RMW instruction. ffffffff815ba150 <nvme_update_cq_head>: ffffffff815ba150: 0f b7 47 70 movzx eax,WORD PTR [rdi+0x70] ffffffff815ba154: 83 c0 01 add eax,0x1 ffffffff815ba157: 66 89 47 70 mov WORD PTR [rdi+0x70],ax ffffffff815ba15b: 66 3b 47 68 cmp ax,WORD PTR [rdi+0x68] ffffffff815ba15f: 74 01 je ffffffff815ba162 <nvme_update_cq_head+0x12> ffffffff815ba161: c3 ret ffffffff815ba162: 31 c0 xor eax,eax ffffffff815ba164: 80 77 74 01 ===> xor BYTE PTR [rdi+0x74],0x1 ffffffff815ba168: 66 89 47 70 mov WORD PTR [rdi+0x70],ax ffffffff815ba16c: c3 ret add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-119 (-119) Function old new delta nvme_poll 690 678 -12 nvme_dev_disable 1230 1177 -53 nvme_irq 613 559 -54 Signed-off-by: Alexey Dobriyan <[email protected]>
1 parent 6d525f9 commit e2a366a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/nvme/host/pci.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -982,11 +982,9 @@ static void nvme_complete_cqes(struct nvme_queue *nvmeq, u16 start, u16 end)
982982

983983
static inline void nvme_update_cq_head(struct nvme_queue *nvmeq)
984984
{
985-
if (nvmeq->cq_head == nvmeq->q_depth - 1) {
985+
if (++nvmeq->cq_head == nvmeq->q_depth) {
986986
nvmeq->cq_head = 0;
987-
nvmeq->cq_phase = !nvmeq->cq_phase;
988-
} else {
989-
nvmeq->cq_head++;
987+
nvmeq->cq_phase ^= 1;
990988
}
991989
}
992990

0 commit comments

Comments
 (0)