nvme-tcp: NIC topology aware I/O queue scaling and queue info export
v4 cover nvme-tcp: NIC topology aware I/O queue scaling and queue info export
This patch series has been revised based on feedback from the netdev community [1].
Following the feedback, the logic for determining the number of fabric I/O queues (nr-io-queues) has been now moved to userspace in nvme-cli [2]. As a result, the first two patches from the earlier series v2, which implemented this logic in the kernel driver, have been dropped in series v3.
Based on further feedback received on v3, this revision also moves the export of NVMe/TCP I/O queue information from debugfs to sysfs, making it easier for userspace tools to access the information and configure host-side network tuning.
The first patch exports the socket endpoint addresses of each NVMe/TCP I/O queue through a new per-queue sysfs attribute named address. This provides the TCP flow information (source/destination IP addresses and ports) for each I/O queue. The associated CPU assignment can be retrieved through the existing io_cpu attribute.
Together, these attributes provide userspace tools with the information needed to configure:
- IRQ affinity
- RPS/XPS
- ntuple steering
- or any other scaling as deemed feasible
Together with tunning, these changes allow better alignment of:
flow -> NIC queue -> IRQ -> CPU -> NVMe/TCP I/O worker
Improving this alignment can enhance flow-to-CPU locality, potentially improving performance and reducing I/O latency. Performance evaluation results comparing the baseline with the tuned configuration are available in [3].
Thanks!
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://github.com/linux-nvme/nvme-cli/pull/4140
[3]: https://lore.kernel.org/all/[email protected]/
Changes from v3
- Moved per-queue tcp flow information from debugfs to sysfs
(Daniel Wagner, Hannes Reinecke)
Link to v3: https://lore.kernel.org/all/[email protected]/
Changes from v2
- Dropped patch #1 and #2 from v2
- Added new debugfs attribute parameter "is_visible" which could be useful to hide the attribute for certain configuration or transport.
Link to v2: https://lore.kernel.org/all/[email protected]/
Nilay Shroff (2):
nvme-tcp: expose per-queue socket addresses via sysfs
nvme: document NVMe/TCP per-queue address sysfs attribute
Documentation/ABI/stable/sysfs-nvme | 18 +++++++++++ drivers/nvme/host/tcp.c | 50 +++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+)
Signature · 1 line
2.53.0
PATCH v4 1/2 nvme-tcp: expose per-queue socket addresses via sysfs
Add a read-only per-queue sysfs attribute named "address" to expose the socket addresses associated with each NVMe/TCP I/O queue.
The attribute reports the socket's peer and local endpoint information using the following fields:
- traddr: Peer transport address
- trsvcid: Peer transport service identifier
- host_traddr: Host transport address
- host_trsvcid: Host transport service identifier
The attribute is available at:
/sys/class/nvme/nvmeX/queues/<qid>/address
Together with the existing per-queue "io_cpu" attribute, this information helps correlate NVMe/TCP I/O queues with network stack components and tune their interaction, including IRQ affinity, RPS/RFS, XPS and NIC flow steering (ntuple).
No changes to I/O behavior are expected.
--- drivers/nvme/host/tcp.c | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
drivers/nvme/host/tcp.c +50 -0
@@ -2123,14 +2123,64 @@ static ssize_t managed_show(struct kobject *kobj, struct kobj_attribute *attr, !test_bit(NVME_TCP_Q_IO_CPU_USER, &queue->flags)); } +static ssize_t address_show (struct kobject *kobj,struct kobj_attribute *attr, +char *buf) +{ +struct nvme_tcp_queue *queue =nvme_queue_info_data (kobj); +struct sockaddr_storage src, dst; +int ret =0 ; + +mutex_lock (&queue->queue_lock); + +if (!test_bit (NVME_TCP_Q_LIVE , &queue->flags)) + goto out; + + ret =kernel_getsockname (queue->sock, (struct sockaddr *)&src); +if (ret <=0 ) + goto out; + + ret =kernel_getpeername (queue->sock, (struct sockaddr *)&dst); +if (ret <=0 ) + goto out; + +if (src.ss_family != dst.ss_family) { + ret = -EAFNOSUPPORT ; + goto out; + } + +if (src.ss_family ==AF_INET ) { +struct sockaddr_in *sip = (struct sockaddr_in *)&src; +struct sockaddr_in *dip = (struct sockaddr_in *)&dst; + + ret =sysfs_emit (buf,"traddr=%pI4,trsvcid=%hu,host_traddr=%pI4,host_trsvcid=%hu\n" , + &dip->sin_addr.s_addr,ntohs (dip->sin_port), + &sip->sin_addr.s_addr,ntohs (sip->sin_port)); + }else if (src.ss_family ==AF_INET6 ) { +struct sockaddr_in6 *sip6 = (struct sockaddr_in6 *)&src; +struct sockaddr_in6 *dip6 = (struct sockaddr_in6 *)&dst; + + ret =sysfs_emit (buf,"traddr=%pI6c,trsvcid=%hu,host_traddr=%pI6c,host_trsvcid=%hu\n" , + &dip6->sin6_addr,ntohs (dip6->sin6_port), + &sip6->sin6_addr,ntohs (sip6->sin6_port)); + }else { + ret = -EAFNOSUPPORT ; + } +out: +mutex_unlock (&queue->queue_lock); +return ret; +} +static struct kobj_attribute nvme_tcp_io_cpu_attr =__ATTR (io_cpu,0644 , io_cpu_show, io_cpu_store);static struct kobj_attribute nvme_tcp_managed_attr =__ATTR_RO (managed); +static struct kobj_attribute nvme_tcp_address_attr = +__ATTR_RO (address);static struct attribute *nvme_tcp_queue_attrs[] = { &nvme_tcp_io_cpu_attr.attr, &nvme_tcp_managed_attr.attr, + &nvme_tcp_address_attr.attr,NULL , };ATTRIBUTE_GROUPS (nvme_tcp_queue);
Signature · 1 line
2.53.0
PATCH v4 2/2 nvme: document NVMe/TCP per-queue address sysfs attribute
In reply to Nilay ShroffDocument the per-I/O-queue "address" sysfs attribute introduced for NVMe/TCP. The attribute is available at:
/sys/class/nvme/nvmeX/queues/<qid>/address
--- Documentation/ABI/stable/sysfs-nvme | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Documentation/ABI/stable/sysfs-nvme +18 -0
@@ -534,3 +534,21 @@ Description: managed: (RO) Shows who owns the CPU placement. 1 while io_cpu is driver managed, 0 once the user assigned it, for the life of the controller. + +What: /sys/class/nvme/nvmeX/queues/<qid>/address +Date: November 2026 +KernelVersion: 7.5 +Contact: Nilay Shroff <[email protected]> +Description: + (RO) Shows the socket endpoint addresses associated with + an NVMe/TCP I/O queue. The output contains the following + comma-separated fields: + + traddr: Peer transport address (IPv4/IPv6). + trsvcid: Peer transport service identifier (TCP port). + host_traddr: Local transport address (IPv4/IPv6). + host_trsvcid: Local transport service identifier (TCP port). + + Returns an empty result if the I/O queue is not live. + Returns error if host or peer transport address can't be + determined or transport address family is unsupported.
Signature · 1 line
2.53.0
Re: [PATCH v4 1/2] nvme-tcp: expose per-queue socket addresses via sysfs
In reply to Nilay ShroffQuoted 71 lines · Nilay Shroff
Add a read-only per-queue sysfs attribute named "address" to expose the socket addresses associated with each NVMe/TCP I/O queue.
The attribute reports the socket's peer and local endpoint information using the following fields:
- traddr: Peer transport address
- trsvcid: Peer transport service identifier
-host_traddr: Host transport address
-host_trsvcid: Host transport service identifierThe attribute is available at:
/sys/class/nvme/nvmeX/queues/<qid>/addressTogether with the existing per-queue "
io_cpu" attribute, this information helps correlate NVMe/TCP I/O queues with network stack components and tune their interaction, including IRQ affinity, RPS/RFS, XPS and NIC flow steering (ntuple).No changes to I/O behavior are expected.
Signed-off-by Nilay Shroff <[email protected]>--- drivers/nvme/host/tcp.c | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)drivers/nvme/host/tcp.c +37
-0@@ -2123,14 +2123,64 @@ static ssize_t managed_show(struct kobject *kobj, struct kobj_attribute *attr, !test_bit(NVME_TCP_Q_IO_CPU_USER, &queue->flags)); } +static ssize_t address_show (struct kobject *kobj,struct kobj_attribute *attr, +char *buf) +{ +struct nvme_tcp_queue *queue =nvme_queue_info_data (kobj); +struct sockaddr_storage src, dst; +int ret =0 ; + +mutex_lock (&queue->queue_lock); + +if (!test_bit (NVME_TCP_Q_LIVE , &queue->flags)) + goto out; + + ret =kernel_getsockname (queue->sock, (struct sockaddr *)&src); +if (ret <=0 ) + goto out; + + ret =kernel_getpeername (queue->sock, (struct sockaddr *)&dst); +if (ret <=0 ) + goto out; + +if (src.ss_family != dst.ss_family) { + ret = -EAFNOSUPPORT ; + goto out; + } + +if (src.ss_family ==AF_INET ) { +struct sockaddr_in *sip = (struct sockaddr_in *)&src; +struct sockaddr_in *dip = (struct sockaddr_in *)&dst; + + ret =sysfs_emit (buf,"traddr=%pI4,trsvcid=%hu,host_traddr=%pI4,host_trsvcid=%hu\n" , + &dip->sin_addr.s_addr,ntohs (dip->sin_port), + &sip->sin_addr.s_addr,ntohs (sip->sin_port)); + }else if (src.ss_family ==AF_INET6 ) { +struct sockaddr_in6 *sip6 = (struct sockaddr_in6 *)&src; +struct sockaddr_in6 *dip6 = (struct sockaddr_in6 *)&dst; + + ret = sysfs_emit(buf, "traddr=%pI6c,trsvcid=%hu,host_traddr=%pI6c,host_trsvcid=%hu\n",
drivers/nvme/host/tcp.c static ssize_t managed_show(struct kobject *kobj, struct kobj_attribute *attr, · line 2172
Quoted 10 lines
drivers/nvme/host/tcp.c +10
-0+ &dip6->sin6_addr,ntohs (dip6->sin6_port), + &sip6->sin6_addr, ntohs(sip6->sin6_port)); + }else { + ret = -EAFNOSUPPORT ; + } +out: +mutex_unlock (&queue->queue_lock); +return ret; +} +
Hmm. This is stretching the definition of 'traddr' and 'host_traddr' a bit, as normally these are controller settings, not queue settings. I do see the logic, but I'm not quite happy with it.
Quoted 4 lines
drivers/nvme/host/tcp.c +0
-0static struct kobj_attribute nvme_tcp_io_cpu_attr =__ATTR (io_cpu,0644 , io_cpu_show, io_cpu_store);static struct kobj_attribute nvme_tcp_managed_attr =__ATTR_RO (managed);
drivers/nvme/host/tcp.c static ssize_t managed_show(struct kobject *kobj, struct kobj_attribute *attr, · line 2186
Quoted 10 lines
drivers/nvme/host/tcp.c +3
-0+static struct kobj_attribute nvme_tcp_address_attr = +__ATTR_RO (address);static struct attribute *nvme_tcp_queue_attrs[] = { &nvme_tcp_io_cpu_attr.attr, &nvme_tcp_managed_attr.attr, + &nvme_tcp_address_attr.attr,NULL , };ATTRIBUTE_GROUPS (nvme_tcp_queue);
But in general it's a good idea.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Re: [PATCH v4 2/2] nvme: document NVMe/TCP per-queue address sysfs attribute
In reply to Nilay ShroffQuoted 26 lines · Nilay Shroff
Document the per-I/O-queue "address" sysfs attribute introduced for NVMe/TCP. The attribute is available at:
/sys/class/nvme/nvmeX/queues/<qid>/address
Signed-off-by Nilay Shroff <[email protected]>--- Documentation/ABI/stable/sysfs-nvme | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)Documentation/ABI/stable/sysfs-nvme +8
-0@@ -534,3 +534,21 @@ Description: managed: (RO) Shows who owns the CPU placement. 1 while io_cpu is driver managed, 0 once the user assigned it, for the life of the controller. + +What: /sys/class/nvme/nvmeX/queues/<qid>/address +Date: November 2026 +KernelVersion: 7.5 +Contact: Nilay Shroff <[email protected]> +Description: + (RO) Shows the socket endpoint addresses associated with + an NVMe/TCP I/O queue. The output contains the following
Documentation/ABI/stable/sysfs-nvme Description: · line 554
Quoted 10 lines
Documentation/ABI/stable/sysfs-nvme +10
-0+ comma-separated fields: + + traddr: Peer transport address (IPv4/IPv6). + trsvcid: Peer transport service identifier (TCP port). + host_traddr: Local transport address (IPv4/IPv6). + host_trsvcid: Local transport service identifier (TCP port). + + Returns an empty result if the I/O queue is not live. + Returns error if host or peer transport address can't be + determined or transport address family is unsupported.
Please merge it with the previous patch.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Re: [PATCH v4 1/2] nvme-tcp: expose per-queue socket addresses via sysfs
In reply to Hannes ReineckeQuoted 77 lines · Hannes Reinecke
Quoted 76 lines · Nilay Shroff
Add a read-only per-queue sysfs attribute named "address" to expose the socket addresses associated with each NVMe/TCP I/O queue.
The attribute reports the socket's peer and local endpoint information using the following fields:
- traddr: Peer transport address
- trsvcid: Peer transport service identifier
-host_traddr: Host transport address
-host_trsvcid: Host transport service identifierThe attribute is available at:
/sys/class/nvme/nvmeX/queues/<qid>/addressTogether with the existing per-queue "
io_cpu" attribute, this information helps correlate NVMe/TCP I/O queues with network stack components and tune their interaction, including IRQ affinity, RPS/RFS, XPS and NIC flow steering (ntuple).No changes to I/O behavior are expected.
Signed-off-by Nilay Shroff <[email protected]>---
drivers/nvme/host/tcp.c| 50 +++++++++++++++++++++++++++++++++++++++++1 file changed, 50 insertions(+)drivers/nvme/host/tcp.c +43
-0@@ -2123,14 +2123,64 @@ static ssize_t managed_show(struct kobject *kobj, struct kobj_attribute *attr, !test_bit(NVME_TCP_Q_IO_CPU_USER, &queue->flags)); } +static ssize_t address_show (struct kobject *kobj,struct kobj_attribute *attr, + char *buf) +{ + struct nvme_tcp_queue *queue = nvme_queue_info_data(kobj); + struct sockaddr_storage src, dst; + int ret = 0; + + mutex_lock(&queue->queue_lock); + + if (!test_bit(NVME_TCP_Q_LIVE, &queue->flags)) + goto out; + + ret = kernel_getsockname(queue->sock, (struct sockaddr *)&src); + if (ret <= 0) + goto out; + + ret = kernel_getpeername(queue->sock, (struct sockaddr *)&dst); + if (ret <= 0) + goto out; + + if (src.ss_family != dst.ss_family) { + ret = -EAFNOSUPPORT; + goto out; + } + + if (src.ss_family == AF_INET) { + struct sockaddr_in *sip = (struct sockaddr_in *)&src; + struct sockaddr_in *dip = (struct sockaddr_in *)&dst; + + ret = sysfs_emit(buf, "traddr=%pI4,trsvcid=%hu,host_traddr=%pI4,host_trsvcid=%hu\n", + &dip->sin_addr.s_addr, ntohs(dip->sin_port), + &sip->sin_addr.s_addr, ntohs(sip->sin_port)); + } else if (src.ss_family == AF_INET6) { + struct sockaddr_in6 *sip6 = (struct sockaddr_in6 *)&src; + struct sockaddr_in6 *dip6 = (struct sockaddr_in6 *)&dst; + + ret = sysfs_emit(buf, "traddr=%pI6c,trsvcid=%hu,host_traddr=%pI6c,host_trsvcid=%hu\n", + &dip6->sin6_addr, ntohs(dip6->sin6_port), + &sip6->sin6_addr, ntohs(sip6->sin6_port)); + } else { + ret = -EAFNOSUPPORT; + } +out:
Quoted 9 lines
drivers/nvme/host/tcp.c static ssize_t managed_show(struct kobject *kobj, struct kobj_attribute *attr, · line 2172
Quoted 4 lines
drivers/nvme/host/tcp.c +4
-0+ mutex_unlock(&queue->queue_lock); + return ret; +} +Hmm. This is stretching the definition of 'traddr' and '
host_traddr' a bit, as normally these are controller settings, not queue settings. I do see the logic, but I'm not quite happy with it.
Would you prefer sip, dip, sport and dport instead of host_traddr, traddr, host_trsvcid and trsvcid?
Quoted 14 lines
Quoted 5 lines
static struct
kobj_attributenvme_tcp_io_cpu_attr=__ATTR(io_cpu, 0644, io_cpu_show, io_cpu_store); static structkobj_attributenvme_tcp_managed_attr=__ATTR_RO(managed);
+static structkobj_attributenvme_tcp_address_attr=Quoted 8 lines
+
__ATTR_RO(address);
static struct attribute *nvme_tcp_queue_attrs[] = { &nvme_tcp_io_cpu_attr.attr, &nvme_tcp_managed_attr.attr,
+ &nvme_tcp_address_attr.attr,
NULL,
};
ATTRIBUTE_GROUPS(nvme_tcp_queue);
Quoted 2 lines
But in general it's a good idea.
Thanks,
--Nilay
Re: [PATCH v4 2/2] nvme: document NVMe/TCP per-queue address sysfs attribute
In reply to Hannes ReineckeQuoted 31 lines · Hannes Reinecke
Quoted 30 lines · Nilay Shroff
Document the per-I/O-queue "address" sysfs attribute introduced for NVMe/TCP. The attribute is available at:
/sys/class/nvme/nvmeX/queues/<qid>/address
Signed-off-by Nilay Shroff <[email protected]>---
Documentation/ABI/stable/sysfs-nvme| 18 ++++++++++++++++++1 file changed, 18 insertions(+)Documentation/ABI/stable/sysfs-nvme +0
-0@@ -534,3 +534,21 @@ Description:managed: (RO) Shows who owns the CPU placement. 1 while
io_cpuis driver managed, 0 once the user assigned it, for the life of the controller.Documentation/ABI/stable/sysfs-nvme +12
-0+ +What: /sys/class/nvme/nvmeX/queues/<qid>/address +Date: November 2026 +KernelVersion: 7.5 +Contact: Nilay Shroff <[email protected]> +Description: + (RO) Shows the socket endpoint addresses associated with + an NVMe/TCP I/O queue. The output contains the following + comma-separated fields: + + traddr: Peer transport address (IPv4/IPv6). + trsvcid: Peer transport service identifier (TCP port).
Quoted 9 lines
Quoted 6 lines
+
host_traddr: Local transport address (IPv4/IPv6). +host_trsvcid: Local transport service identifier (TCP port). +
+ Returns an empty result if the I/O queue is not live. + Returns error if host or peer transport address can't be + determined or transport address family is unsupported.Please merge it with the previous patch.
Yeah will fold this patch into the previous.
Thanks,
--Nilay