Skip to content

RFC netgpu: networking between NIC and GPU/CPU.

Jonathan Lemon netdev oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest21 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/21mm: add {add|release}_memory_pagesinclude/linux/memory_hotplug.h mm/memory_hotplug.c+67 -20 replies
2/21mm: Allow DMA mapping of pages which are not onlineinclude/linux/dma-mapping.h include/linux/mmzone.h+9 -20 replies
3/21tcp: Pad TCP options out to a fixed sizenet/ipv4/tcp_output.c+16 -00 replies
4/21mlx5: add definitions for header split and netgpudrivers/net/ethernet/mellanox/mlx5/core/en.h drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h+23 -20 replies
5/21mlx5/xsk: check that xsk does not conflict with netgpudrivers/net/ethernet/mellanox/mlx5/core/en/xsk/umem.c drivers/net/ethernet/mellanox/mlx5/core/en/xsk/umem.h+6 -00 replies
6/21mlx5: add header_split flagdrivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c drivers/net/ethernet/mellanox/mlx5/core/en_main.c+52 -86 replies
7/21mlx5: remove the umem parameter from mlx5e_open_channeldrivers/net/ethernet/mellanox/mlx5/core/en_main.c+24 -110 replies
8/21misc: add shqueue.h for prototypinginclude/uapi/misc/shqueue.h+205 -00 replies
9/21include: add definitions for netgpuinclude/net/netgpu.h+65 -00 replies
10/21mlx5: add netgpu queue functionsdrivers/net/ethernet/mellanox/mlx5/core/Makefile drivers/net/ethernet/mellanox/mlx5/core/en/netgpu/setup.c drivers/net/ethernet/mellanox/mlx5/core/en/netgpu/setup.h+519 -10 replies
11/21skbuff: add a zc_netgpu bitflaginclude/linux/skbuff.h net/core/skbuff.c+3 -10 replies
12/21mlx5: hook up the netgpu channel functionsdrivers/net/ethernet/mellanox/mlx5/core/en/netgpu/setup.c drivers/net/ethernet/mellanox/mlx5/core/en_main.c drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 more+97 -70 replies
13/21netdevice: add SETUP_NETGPU to the netdev_bpf structureinclude/linux/netdevice.h+6 -00 replies
14/21kernel: export free_uidkernel/user.c+1 -00 replies
15/21netgpu: add network/gpu dma moduledrivers/misc/Kconfig drivers/misc/Makefile drivers/misc/netgpu/Kconfig +3 more+1582 -00 replies
16/21lib: have __zerocopy_sg_from_iter get netgpu pages for a skinclude/linux/uio.h lib/iov_iter.c net/core/datagram.c+54 -10 replies
17/21net/core: add the SO_REGISTER_DMA socket optioninclude/uapi/asm-generic/socket.h net/core/sock.c+28 -00 replies
18/21tcp: add MSG_NETDMA flag for sendmsg()include/linux/socket.h net/ipv4/tcp.c+9 -00 replies
19/21core: add page recycling logic for netgpu pagesnet/core/skbuff.c+25 -20 replies
20/21core/skbuff: use skb_zdata for testing whether skb is zerocopyinclude/linux/skbuff.h net/core/skbuff.c+35 -50 replies
21/21mlx5: add XDP_SETUP_NETGPU hookdrivers/net/ethernet/mellanox/mlx5/core/en_main.c+3 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 00/21] netgpu: networking between NIC and GPU/CPU.

This series is a working RFC proof-of-concept that implements DMA zero-copy between the NIC and a GPU device for the data path, while keeping the protocol processing on the host CPU.

This also works for zero-copy send/recv to host (CPU) memory.

Current limitations:
- mlx5 only, header splitting is at a fixed offset.
- currently only TCP protocol delivery is performed.
- not optimized (hey, it works!)
- TX completion notification is planned, but not in this patchset.
- one socket per device
- not compatible with xsk (re-uses same datastructures)
- not compatible with bpf payload inspection
- x86 !iommu only; liberties are taken with PA addresses.

The next section provides a brief overview of how things work, for this phase 0 proof of concept.

A transport context is created on a device, which sets up the datapath, and the device queues. Only specialized RX queues are needed, the standard TX queues are used for packet transmission.

Memory areas which participate in zero-copy transmission are registered with the context. These areas can be used as either RX packet buffers or TX data areas (or both). The memory can come from either malloc/mmap or cudaMalloc(). The latter call provides a handle to the userspace application, but the memory region is only accessible to the GPU.

A socket is created and registered with the context, which sets SOCK_ZEROCOPY, and is bound to the device with SO_BINDTODEVICE.

Asymmetrical data paths are possible (zc TX, normal RX), and vice versa, but the curreent PoC sets things up for symmetrical transport. The application needs to provide the RX buffers to the receive queue, similar to AF_XDP.

Once things are set up, data is sent to the network with sendmsg(). The iovecs provided contain an address in the region previously registered. The normal protocol stack processing constructs the packet, but the data is not touched by the stack. In this phase, the application is not notified when the protocol processing is complete and the data area is safe to modify again.

For RX, packets undergo the usual protocol processing and are delivered up to the socket receive queue. At this point, the skb data fragments are delivered to the application as iovecs through an AF_XDP style queue. The application can poll for readability, but does not use read() to receive the data.

The initial application used is iperf3, a modified version with the userspace library is available at:
https://github.com/jlemon/iperf
https://github.com/jlemon/netgpu

Running "iperf3 -s -z --dport 8888" (host memory) on a 12Gbps link:
11.3 Gbit/sec receive
10.8 Gbit/sec tramsmit

Running "iperf3 -s -z --dport 8888 --gpu" on a 25Gbps link:
22.5 Gbit/sec receive
12.6 Gbit/sec transmit (!!!)

For the GPU runs, the Intel PCI monitoring tools were used to confirm that the host PCI bus was mostly idle. The TX performance needs further investigation.

Comments welcome. The next phase of the work will clean up the interface, adding completion notifications, and a flexible queue creation mechanism.
--
Jonathan

Jonathan Lemon (21):
mm: add {add|release}_memory_pages
mm: Allow DMA mapping of pages which are not online
tcp: Pad TCP options out to a fixed size
mlx5: add definitions for header split and netgpu mlx5/xsk: check that xsk does not conflict with netgpu
mlx5: add header_split flag
mlx5: remove the umem parameter from mlx5e_open_channel
misc: add shqueue.h for prototyping
include: add definitions for netgpu
mlx5: add netgpu queue functions
skbuff: add a zc_netgpu bitflag
mlx5: hook up the netgpu channel functions
netdevice: add SETUP_NETGPU to the netdev_bpf structure
kernel: export free_uid
netgpu: add network/gpu dma module
lib: have __zerocopy_sg_from_iter get netgpu pages for a sk net/core: add the SO_REGISTER_DMA socket option
tcp: add MSG_NETDMA flag for sendmsg()
core: add page recycling logic for netgpu pages core/skbuff: use skb_zdata for testing whether skb is zerocopy
mlx5: add XDP_SETUP_NETGPU hook

 drivers/misc/Kconfig                          |    1 +
 drivers/misc/Makefile                         |    1 +
 drivers/misc/netgpu/Kconfig                   |   10 +
 drivers/misc/netgpu/Makefile                  |   11 +
 drivers/misc/netgpu/nvidia.c                  | 1516 +++++++++++++++++
 .../net/ethernet/mellanox/mlx5/core/Makefile  |    3 +-
 drivers/net/ethernet/mellanox/mlx5/core/en.h  |   22 +-
 .../mellanox/mlx5/core/en/netgpu/setup.c      |  475 ++++++
 .../mellanox/mlx5/core/en/netgpu/setup.h      |   42 +
 .../net/ethernet/mellanox/mlx5/core/en/txrx.h |    3 +
 .../ethernet/mellanox/mlx5/core/en/xsk/umem.c |    3 +
 .../ethernet/mellanox/mlx5/core/en/xsk/umem.h |    3 +
 .../ethernet/mellanox/mlx5/core/en_ethtool.c  |   15 +
 .../net/ethernet/mellanox/mlx5/core/en_main.c |  118 +-
 .../net/ethernet/mellanox/mlx5/core/en_rx.c   |   52 +-
 .../net/ethernet/mellanox/mlx5/core/en_txrx.c |   15 +-
 include/linux/dma-mapping.h                   |    4 +-
 include/linux/memory_hotplug.h                |    4 +
 include/linux/mmzone.h                        |    7 +
 include/linux/netdevice.h                     |    6 +
 include/linux/skbuff.h                        |   27 +-
 include/linux/socket.h                        |    1 +
 include/linux/uio.h                           |    4 +
 include/net/netgpu.h                          |   65 +
 include/uapi/asm-generic/socket.h             |    2 +
 include/uapi/misc/netgpu.h                    |   43 +
 include/uapi/misc/shqueue.h                   |  205 +++
 kernel/user.c                                 |    1 +
 lib/iov_iter.c                                |   45 +
 mm/memory_hotplug.c                           |   65 +-
 net/core/datagram.c                           |    6 +-
 net/core/skbuff.c                             |   44 +-
 net/core/sock.c                               |   26 +
 net/ipv4/tcp.c                                |    8 +
 net/ipv4/tcp_output.c                         |   16 +
 35 files changed, 2828 insertions(+), 41 deletions(-)
 create mode 100644 drivers/misc/netgpu/Kconfig
 create mode 100644 drivers/misc/netgpu/Makefile
 create mode 100644 drivers/misc/netgpu/nvidia.c
 create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/netgpu/setup.c
 create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/netgpu/setup.h
 create mode 100644 include/net/netgpu.h
 create mode 100644 include/uapi/misc/netgpu.h
 create mode 100644 include/uapi/misc/shqueue.h
Signature · 1 line
2.24.1