[PATCH] nvme: find numa distance only if controller has valid numa id

Christoph Hellwig hch at lst.de
Mon Apr 15 00:25:30 PDT 2024


On Sat, Apr 13, 2024 at 02:34:36PM +0530, Nilay Shroff wrote:
>  			continue;
>  
> -		if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_NUMA)
> -			distance = node_distance(node, ns->ctrl->numa_node);
> -		else
> -			distance = LOCAL_DISTANCE;
> +		if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_NUMA) {
> +			if (ns->ctrl->numa_node != NUMA_NO_NODE)
> +				distance = node_distance(node, ns->ctrl->numa_node);
> +		}

Please avoid the overly long line.  This could be easily done by keeping
the old code structure, which IMHO is more readable anyway:

		if (ns->ctrl->numa_node != NUMA_NO_NODE &&
		    READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_NUMA)
			distance = node_distance(node, ns->ctrl->numa_node);
		else
			distance = LOCAL_DISTANCE;




More information about the Linux-nvme mailing list