net/9p: Add 9P transport over USB4STREAM
Subsystems (4)
cover net/9p: Add 9P transport over USB4STREAM
This series adds trans=thunderbolt, a 9P transport over the Thunderbolt/USB4 DMA tunnels exposed by the tbstream character devices (USB4STREAM). It's designed for simple host-to-host file sharing over single Thunderbolt/USB4 cable.
Today the only practical way to use 9P over a USB4 link is trans=fd which, due to its design, cannot fully utilize USB4STREAM capabilities. Thunderbolt transport offers a simpler mount (no fd redirection required), busy-poll support and substantial throughput increase compared to FD transport.
User may mount 9P export with following command:
mount -t 9p -o trans=thunderbolt,aname=<exported_remote> /dev/tbstreamX /mnt
Thunderbolt transport achieves a median 1.21x more throughput compared to FD transport under same conditions, and the advantage grows with
concurrency: 1.03-1.09x at 1-2 threads, 1.14-1.27x at 4, and 1.34-2.28x at 8-16.
As an example, 4K random reads, 4 worker threads. FD transport achieves ~53k IOPS, Thunderbolt transport ~66k (+24.7%). 4K random writes follow:
FD ~28k IOPS, Thunderbolt ~33k (+19.4%).
With busy-poll enabled, throughput drastically increases for single-threaded workloads. 4K random read, 1 thread: FD transport 12,345 IOPS, Thunderbolt 12,843 IOPS (+4%), Thunderbolt + busy-poll 22,262 IOPS (+80.3% vs fd). Normally, busy-polling trades lower latency for increase in CPU usage but measured system CPU usage was lower (23.1% -> 15.2%).
Above is replicated in more practical example: simulated file-manager style copy (drag&drop in GUI) of extracted Chromium release repo. Copy from 9P client to 9P server took 22m29s for FD transport, 21m52s for Thunderbolt transport (-3%), 14m50s for Thunderbolt + busy-poll (-34%).
__Technical details__
'fio' based benchmarks: random read, random write ioengine=psync, direct I/O, bs=512-128k, numjobs=1-16, rsize=128M, runtime=60, ramp=5
'GUI' copy simulation: one extracted chromium-156.0.8066.9 release, 4126 MiB, cp -a --no-preserve=ownership.
Testing was done between two hosts over a single Thunderbolt 5 cable, with diod as the server (version: 1.1.0-24-gde51d1e), fio (version:
3.36) on modified v7.3 kernel, Ubuntu 24.04 LTS.
Every transport ran on default settings: "msize=131096, cache=none, version=9p2000.L". Each scenario result is 3-run median. Between each run, 9P FS was remounted and page cache was dropped on both server and client.
Alan Borzeszkowski (3):
thunderbolt: stream: Add tbstream_dev_from_file() net/9p/thunderbolt: Add native 9P Thunderbolt transport support Documentation/fs/9p: Add Thunderbolt transport documentation
Documentation/filesystems/9p.rst | 39 +++- MAINTAINERS | 1 + drivers/thunderbolt/stream.c | 16 ++ include/linux/thunderbolt_stream.h | 14 ++ net/9p/Kconfig | 7 + net/9p/Makefile | 4 + net/9p/trans_thunderbolt.c | 348 +++++++++++++++++++++++++++++ 7 files changed, 419 insertions(+), 10 deletions(-) create mode 100644 include/linux/thunderbolt_stream.h create mode 100644 net/9p/trans_thunderbolt.c
base-commit: 93f51579e7df248780214094418f205253383cc5
Signature · 1 line
2.53.0
PATCH 1/3 thunderbolt: stream: Add tbstream_dev_from_file()
Add tbstream_dev_from_file() which returns USB4STREAM device behind a file. Expose it to in-kernel users via separate header.
Required by the 9P Thunderbolt transport driver to validate mount source.
--- MAINTAINERS | 1 + drivers/thunderbolt/stream.c | 16 ++++++++++++++++ include/linux/thunderbolt_stream.h | 14 ++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 include/linux/thunderbolt_stream.h
MAINTAINERS +1 -0
@@ -27211,6 +27211,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt.git F: Documentation/admin-guide/thunderbolt.rst F: drivers/thunderbolt/ F: include/linux/thunderbolt.h +F: include/linux/thunderbolt_stream.h THUNDERBOLT NETWORK DRIVER M: Mika Westerberg <[email protected]>
drivers/thunderbolt/stream.c +16 -0
@@ -21,6 +21,7 @@#include <linux/poll.h> #include <linux/sizes.h> #include <linux/thunderbolt.h> +#include <linux/thunderbolt_stream.h> #include <linux/uaccess.h> #include <linux/uio.h> #include <linux/uuid.h>
@@ -1024,6 +1025,21 @@ tbstream_dev_from_group(struct config_group *group) return container_of(group, struct tbstream_dev, group); } +/** +* tbstream_dev_from_file() - Return USB4STREAM device behind a file +* @file: File to check +* +* Return: Pointer to &struct tbstream_dev, %NULL if file is not +* USB4STREAM device. +*/ +struct tbstream_dev *tbstream_dev_from_file (struct file *file) +{ +if (file->f_op != &tbstream_dev_fops) +return NULL ; +return to_tbstream_dev (file->private_data); +} +EXPORT_SYMBOL_GPL (tbstream_dev_from_file); +static ssize_t tbstream_dev_busy_poll_show (struct config_item *item,char *buf) {struct config_group *group =to_config_group (item);
include/linux/thunderbolt_stream.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Thunderbolt Stream API +* +* Copyright (C) 2026, Intel Corporation +* Author: Alan Borzeszkowski <[email protected]> +*/ + +#ifndef THUNDERBOLT_STREAM_H_ +#define THUNDERBOLT_STREAM_H_ + +struct tbstream_dev *tbstream_dev_from_file (struct file *file); + +#endif /* THUNDERBOLT_STREAM_H_ */
Signature · 1 line
2.53.0
Re: [PATCH 1/3] thunderbolt: stream: Add tbstream_dev_from_file()
Quoted 7 lines · Alan Borzeszkowski
Add
tbstream_dev_from_file()which returns USB4STREAM device behind a file. Expose it to in-kernel users via separate header.Required by the 9P Thunderbolt transport driver to validate mount source.
Signed-off-by Alan Borzeszkowski <[email protected]>
PATCH 2/3 net/9p/thunderbolt: Add native 9P Thunderbolt transport support
In reply to Alan BorzeszkowskiAdd native Thunderbolt 9P transport driver which allows user to setup simple host-to-host file sharing over a Thunderbolt/USB4 cable. Compared to FD transport, it offers greater data throughput while being simpler to use.
Driver uses blocking write to send data over Thunderbolt fabric and dedicated kthread to read from it.
User may mount it like so:
mount -t 9p -o trans=thunderbolt,aname=<exported_dir> /dev/tbstream0 /mnt
--- net/9p/Kconfig | 7 + net/9p/Makefile | 4 + net/9p/trans_thunderbolt.c | 348 +++++++++++++++++++++++++++++++++++++ 3 files changed, 359 insertions(+) create mode 100644 net/9p/trans_thunderbolt.c
net/9p/Kconfig +7 -0
@@ -49,6 +49,13 @@ config NET_9P_USBG This builds support for a transport for 9pfs over usb gadget. +config NET_9P_USB4 + tristate "9P Thunderbolt/USB4 Transport" + depends on USB4_STREAM + help + This builds support for a transport for 9pfs over + Thunderbolt/USB4 cable. + config NET_9P_RDMA depends on INET && INFINIBAND && INFINIBAND_ADDR_TRANS tristate "9P RDMA Transport (Experimental)"
net/9p/Makefile +4 -0
@@ -5,6 +5,7 @@ obj-$(CONFIG_NET_9P_XEN) += 9pnet_xen.o obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o obj-$(CONFIG_NET_9P_RDMA) += 9pnet_rdma.o obj-$(CONFIG_NET_9P_USBG) += 9pnet_usbg.o +obj-$(CONFIG_NET_9P_USB4) += 9pnet_thunderbolt.o 9pnet-objs := \ mod.o \
@@ -27,3 +28,6 @@ obj-$(CONFIG_NET_9P_USBG) += 9pnet_usbg.o 9pnet_usbg-objs := \ trans_usbg.o \ + +9pnet_thunderbolt-objs := \ + trans_thunderbolt.o \
net/9p/trans_thunderbolt.c new file +348 -0
348 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 3/3 Documentation/fs/9p: Add Thunderbolt transport documentation
In reply to Alan BorzeszkowskiWith new 9P Thunderbolt transport added, update documentation with simple usage guide.
--- Documentation/filesystems/9p.rst | 39 ++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-)
Documentation/filesystems/9p.rst +29 -10
@@ -50,6 +50,24 @@ mount points. Each 9P export is seen by the client as a virtio device with an associated "mount_tag" property. Available mount tags can be seen by reading /sys/bus/virtio/drivers/9pnet_virtio/virtio<n>/mount_tag files. +Thunderbolt/USB4 Usage +====================== + +Establish USB4STREAM between two machines (see Documentation/admin-guide/thunderbolt.rst). +Export filesystem on server machine (e.g., using diod). Example:: + + diod -f -n -S -e /srv/shared -r 3 -w 4 3</dev/tbstream0 4>/dev/tbstream0 + +Mount remote filesystem on client machine using:: + + mount -t 9p -o trans=thunderbolt,aname=<exported_remote_dir > /dev/<USB4STREAM_device> /mnt/9 + +where USB4STREAM device is 'tbstreamX'. + +Example:: + + mount -t 9p -o trans=thunderbolt,aname=/srv/shared /dev/tbstream0 /mnt + USBG Usage ==========
@@ -112,16 +130,17 @@ Options trans=name select an alternative transport. Valid options are currently: - ======== ============================================ - unix specifying a named pipe mount point - tcp specifying a normal TCP/IP connection - fd used passed file descriptors for connection - (see rfdno and wfdno) - virtio connect to the next virtio channel available - (from QEMU with trans_virtio module) - rdma connect to a specified RDMA channel - usbg connect to a specified usb gadget channel - ======== ============================================ + =========== ========================================= + unix specifying a named pipe mount point + tcp specifying a normal TCP/IP connection + fd used passed file descriptors for connection + (see rfdno and wfdno) + virtio connect to the next virtio channel available + (from QEMU with trans_virtio module) + rdma connect to a specified RDMA channel + usbg connect to a specified usb gadget channel + thunderbolt connect using USB4STREAM + =========== ========================================= uname=name user name to attempt mount as on the remote server. The server may override or ignore this value. Certain user
Signature · 1 line
2.53.0
Dominique Martinet
maintainerAlan Borzeszkowski wrote on Thu, Sep 24, 2026 at 06:23:30PM +0200:
Quoted 15 lines
This series adds trans=thunderbolt, a 9P transport over the Thunderbolt/USB4 DMA tunnels exposed by the tbstream character devices (USB4STREAM). It's designed for simple host-to-host file sharing over single Thunderbolt/USB4 cable.
Today the only practical way to use 9P over a USB4 link is trans=fd which, due to its design, cannot fully utilize USB4STREAM capabilities. Thunderbolt transport offers a simpler mount (no fd redirection required), busy-poll support and substantial throughput increase compared to FD transport.
User may mount 9P export with following command:
mount -t 9p -o trans=thunderbolt,aname=<exported_remote>
/dev/tbstreamX/mnt
Quoted 8 lines
Thunderbolt transport achieves a median 1.21x more throughput compared to FD transport under same conditions, and the advantage grows with
concurrency: 1.03-1.09x at 1-2 threads, 1.14-1.27x at 4, and 1.34-2.28x at 8-16.As an example, 4K random reads, 4 worker threads. FD transport achieves ~53k IOPS, Thunderbolt transport ~66k (+24.7%). 4K random writes follow:
FD ~28k IOPS, Thunderbolt ~33k (+19.4%).
Thanks for the patches
We've kept adding new transports for 9p lately but maintenance is becoming a burden so let me push back a bit: is the increased performance really worth it over trans=fd ?
If this could be used to bringup a system with a root filesystem like it was done for trans=usbg I'd see the point, but otherwise the simpler usage could be addressed with a simple mount.9p helper, and at this point I'd consider usb4stream to be used for perhaps one-shot copy and not care too much about 4k random IOs (so less affected by latency if msize is large enough, and for a one-shot backup it doesn't matter too much if it takes 6 instead of 5 minutes)
If you can convince me this is worth it and can take care of the transport for the forseable future I'm not dead set to refuse this, but I can't say I'm convinced right now, especially as I can't even test this (I don't own two computers with working usb-c...)
Thanks,
Signature · 1 line
Dominique Martinet | Asmadeus
Hi,
Quoted 35 lines · Dominique Martinet
Alan Borzeszkowski wrote on Thu, Sep 24, 2026 at 06:23:30PM +0200:
Quoted 28 lines
This series adds trans=thunderbolt, a 9P transport over the Thunderbolt/USB4 DMA tunnels exposed by the tbstream character devices
(USB4STREAM). It's designed for simple host-to-host file sharing over
single Thunderbolt/USB4 cable.Today the only practical way to use 9P over a USB4 link is trans=fd which, due to its design, cannot fully utilize USB4STREAM capabilities.
Thunderbolt transport offers a simpler mount (no fd redirection required),
busy-poll support and substantial throughput increase compared to FD
transport.User may mount 9P export with following command:
mount -t 9p -o trans=thunderbolt,aname=<exported_remote>
/dev/tbstreamX/mntThunderbolt transport achieves a median 1.21x more throughput compared
to FD transport under same conditions, and the advantage grows with
concurrency: 1.03-1.09x at 1-2 threads, 1.14-1.27x at 4, and 1.34- 2.28x
at 8-16.Quoted 5 lines
As an example, 4K random reads, 4 worker threads. FD transport achieves
~53k IOPS, Thunderbolt transport ~66k (+24.7%). 4K random writes follow:
FD ~28k IOPS, Thunderbolt ~33k (+19.4%).
Quoted 5 lines
Thanks for the patches
We've kept adding new transports for 9p lately but maintenance is becoming a burden so let me push back a bit: is the increased performance really worth it over trans=fd ?
From the data I've collected, yes. trans=thunderbolt is at worst on par with trans=fd and with increasing amount of threads, trans=fd lags behind.
Thunderbolt transport also offers busy-poll support, which boosts performance significantly at low thread counts. It cannot be used by trans=fd due to its design around polling.
And regarding maintenance, this transport is simple and much smaller than existing ones.
Quoted 10 lines
If this could be used to bringup a system with a root filesystem like it
was done for trans=usbg I'd see the point, but otherwise the simpler usage could be addressed with a simple mount.9p helper, and at this point I'd consider usb4stream to be used for perhaps one-shot copy and
not care too much about 4k random IOs (so less affected by latency if msize is large enough, and for a one-shot backup it doesn't matter too much if it takes 6 instead of 5 minutes)
In case of one-shot backup, I think my drag&drop scenario from cover- letter fits it well. Assuming single thread copy, both transports achieve similar results, but with busy-poll enabled, trans=thunderbolt cuts about 1/3rd of copy time:
Copy from 9P client to a server, using trans=fd, takes 22m29s while trans=thunderbolt + busy-poll takes 14m50s (~1.5x faster). Reverse direction, same improvement: reducing copy time from 41m07s to 26m56s. All done on default msize.
Quoted 6 lines
If you can convince me this is worth it and can take care of the transport for the forseable future I'm not dead set to refuse this, but
I can't say I'm convinced right now, especially as I can't even test this (I don't own two computers with working usb-c...)
I would be happy to maintain Thunderbolt transport.
Quoted 2 lines
Thanks,
Hi,
Quoted 66 lines · Alan Borzeszkowski
Hi,
Quoted 35 lines · Dominique Martinet
Alan Borzeszkowski wrote on Thu, Sep 24, 2026 at 06:23:30PM +0200:
Quoted 28 lines
This series adds trans=thunderbolt, a 9P transport over the Thunderbolt/USB4 DMA tunnels exposed by the tbstream character devices
(USB4STREAM). It's designed for simple host-to-host file sharing over
single Thunderbolt/USB4 cable.Today the only practical way to use 9P over a USB4 link is trans=fd which, due to its design, cannot fully utilize USB4STREAM capabilities.
Thunderbolt transport offers a simpler mount (no fd redirection required),
busy-poll support and substantial throughput increase compared to FD
transport.User may mount 9P export with following command:
mount -t 9p -o trans=thunderbolt,aname=<exported_remote>
/dev/tbstreamX/mntThunderbolt transport achieves a median 1.21x more throughput compared
to FD transport under same conditions, and the advantage grows with
concurrency: 1.03-1.09x at 1-2 threads, 1.14-1.27x at 4, and 1.34- 2.28x
at 8-16.Quoted 5 lines
As an example, 4K random reads, 4 worker threads. FD transport achieves
~53k IOPS, Thunderbolt transport ~66k (+24.7%). 4K random writes follow:
FD ~28k IOPS, Thunderbolt ~33k (+19.4%).Quoted 7 lines
Thanks for the patches
We've kept adding new transports for 9p lately but maintenance is becoming a burden so let me push back a bit: is the increased performance really worth it over trans=fd ?
From the data I've collected, yes. trans=thunderbolt is at worst on par
with trans=fd and with increasing amount of threads, trans=fd lags behind.
Thunderbolt transport also offers busy-poll support, which boosts performance significantly at low thread counts. It cannot be used by trans=fd due to its design around polling.
And regarding maintenance, this transport is simple and much smaller than existing ones.
Quoted 10 lines
If this could be used to bringup a system with a root filesystem like it
was done for trans=usbg I'd see the point, but otherwise the simpler usage could be addressed with a simple mount.9p helper, and at this point I'd consider usb4stream to be used for perhaps one-shot copy and
not care too much about 4k random IOs (so less affected by latency if msize is large enough, and for a one-shot backup it doesn't matter too much if it takes 6 instead of 5 minutes)
Quoted 8 lines
In case of one-shot backup, I think my drag&drop scenario from cover- letter fits it well. Assuming single thread copy, both transports achieve similar results, but with busy-poll enabled, trans=thunderbolt cuts about 1/3rd of copy time:
Copy from 9P client to a server, using trans=fd, takes 22m29s while trans=thunderbolt + busy-poll takes 14m50s (~1.5x faster). Reverse direction, same improvement: reducing copy time from 41m07s to 26m56s. All done on default msize.
That sounds like a good reason to include it IMHO. Also I like the simplicity - no need to run a separate descriptor feeding process :)
Quoted 7 lines
Quoted 5 lines
If you can convince me this is worth it and can take care of the transport for the forseable future I'm not dead set to refuse this, but
I can't say I'm convinced right now, especially as I can't even test this (I don't own two computers with working usb-c...)I would be happy to maintain Thunderbolt transport.
If Dominique is okay with this, I suggest to send v2 with a MAINTAINERS update as well.
Dominique Martinet
maintainerMika Westerberg wrote on Mon, Nov 09, 2026 at 05:52:36PM +0100:
Quoted 11 lines
Quoted 8 lines
In case of one-shot backup, I think my drag&drop scenario from cover- letter fits it well. Assuming single thread copy, both transports achieve similar results, but with busy-poll enabled, trans=thunderbolt cuts about 1/3rd of copy time:
Copy from 9P client to a server, using trans=fd, takes 22m29s while trans=thunderbolt + busy-poll takes 14m50s (~1.5x faster). Reverse direction, same improvement: reducing copy time from 41m07s to 26m56s. All done on default msize.That sounds like a good reason to include it IMHO. Also I like the simplicity - no need to run a separate descriptor feeding process :)
I'm sorry but I'm just not convinced it's useful enough to warrant the effort to review this from my point of view given my lack of time for linux work:
- most of the speed benefit comes from busy-poll, can't this be made to work for all fd consumers somehow? (it could be an ioctl before passing the fd to the mount call, or it could reuse e.g. the existing NAPI config with network over usb4stream if that's more practical; in particular I recall some drivers supporting a hybrid mode that'd busy-poll for x ns/ms then fall back to waiting for the irq, that'd get you the best of both worlds as a sane default)
- for simplicity it looks like mounting from boot without initrd isn't a goal, so this can all be hidden in a userspace wrapper. 9p has historically always been pretty bare, we're not even doing dns resolution that has been a basic feature available for nfs since forever.
You can look at this mount.9P helper for inspiration:
https://github.com/nfs-ganesha/nfs-ganesha/blob/V15.2/src/tools/mount.9P
Quoted 4 lines
Quoted 1 line
I would be happy to maintain Thunderbolt transport.
If Dominique is okay with this, I suggest to send v2 with a
MAINTAINERSupdate as well.
OTOH if you're going to maintain this I have no reason to block, I can just say I'm not reviewing in depth and pass the ball to Linus or someone else higher up the stack to decide...
Signature · 1 line
Dominique Martinet | Asmadeus