nvme: batch completions and do them outside of the queue lock

Jens Axboe axboe at kernel.dk
Wed May 16 20:16:42 PDT 2018


On 5/16/18 8:09 PM, Keith Busch wrote:
> On Wed, May 16, 2018 at 05:39:02PM -0600, Jens Axboe wrote:
>>  static int __nvme_poll(struct nvme_queue *nvmeq, unsigned int tag)
>>  {
>> -	struct nvme_completion cqe;
>> -	int found = 0, consumed = 0;
>> +	u16 start, end;
>>  
>>  	if (!nvme_cqe_valid(nvmeq, nvmeq->cq_head, nvmeq->cq_phase))
>>  		return 0;
>>  
>>  	spin_lock_irq(&nvmeq->q_lock);
>> -	while (nvme_read_cqe(nvmeq, &cqe)) {
>> -		nvme_handle_cqe(nvmeq, &cqe);
>> -		consumed++;
>> -
>> -		if (tag == cqe.command_id) {
>> -			found = 1;
>> -			break;
>> -		}
>> -       }
>> -
>> -	if (consumed)
>> -		nvme_ring_cq_doorbell(nvmeq);
>> -	spin_unlock_irq(&nvmeq->q_lock);
>> +	nvme_process_cq(nvmeq, &start, &end);
>> +	spin_unlock(&nvmeq->q_lock);
> 
> You'll need to use the spin_unlock_irq() here, otherwise looks good.

Ugh good catch, fixed up. How do you want to proceed?

-- 
Jens Axboe




More information about the Linux-nvme mailing list