[PATCH 6/8] nvme-rdma: clamp queue size according to ctrl cap

Max Gurtovoy mgurtovoy at nvidia.com
Tue Jan 23 01:32:49 PST 2024



On 23/01/2024 10:54, Christoph Hellwig wrote:
> On Thu, Jan 04, 2024 at 11:25:47AM +0200, Max Gurtovoy wrote:
>> If a controller is configured with metadata support, clamp the maximal
>> queue size to be 128 since there are more resources that are needed
>> for metadata operations. Otherwise, clamp it to 256.
>>
>> Reviewed-by: Israel Rukshin <israelr at nvidia.com>
>> Signed-off-by: Max Gurtovoy <mgurtovoy at nvidia.com>
>> ---
>>   drivers/nvme/host/rdma.c | 19 ++++++++++++++-----
>>   1 file changed, 14 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
>> index bc90ec3c51b0..d81a7148fbc5 100644
>> --- a/drivers/nvme/host/rdma.c
>> +++ b/drivers/nvme/host/rdma.c
>> @@ -1029,11 +1029,20 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new)
>>   			ctrl->ctrl.opts->queue_size, ctrl->ctrl.sqsize + 1);
>>   	}
>>   
>> +	if (ctrl->ctrl.max_integrity_segments) {
>> +		if (ctrl->ctrl.sqsize + 1 > NVME_RDMA_MAX_METADATA_QUEUE_SIZE) {
>> +			dev_warn(ctrl->ctrl.device,
>> +				"ctrl sqsize %u > max queue size %u, clamping down\n",
>> +				ctrl->ctrl.sqsize + 1, NVME_RDMA_MAX_METADATA_QUEUE_SIZE);
>> +			ctrl->ctrl.sqsize = NVME_RDMA_MAX_METADATA_QUEUE_SIZE - 1;
>> +		}
>> +	} else {
>> +		if (ctrl->ctrl.sqsize + 1 > NVME_RDMA_MAX_QUEUE_SIZE) {
>> +			dev_warn(ctrl->ctrl.device,
>> +				"ctrl sqsize %u > max queue size %u, clamping down\n",
>> +				ctrl->ctrl.sqsize + 1, NVME_RDMA_MAX_QUEUE_SIZE);
>> +			ctrl->ctrl.sqsize = NVME_RDMA_MAX_QUEUE_SIZE - 1;
>> +		}
> 
> Can you just add a local max_queue_size variable instead of
> duplicating all this?
> 

Sure.
something like:


         if (ctrl->ctrl.max_integrity_segments)
                 max_queue_size = NVME_RDMA_MAX_METADATA_QUEUE_SIZE;
         else
                 max_queue_size = NVME_RDMA_MAX_QUEUE_SIZE;

         if (ctrl->ctrl.sqsize + 1 > max_queue_size) {
                 dev_warn(ctrl->ctrl.device,
                         "ctrl sqsize %u > max queue size %u, clamping 
down\n",
                         ctrl->ctrl.sqsize + 1, max_queue_size);
                 ctrl->ctrl.sqsize = max_queue_size - 1;





More information about the Linux-nvme mailing list