net/af_xdp: shared UMEM support
cover net/af_xdp: shared UMEM support
This RFC integrates shared UMEM support into the AF_XDP PMD. It is based on the WIP kernel series [1] by Magnus Karlsson.
Detailed information on the shared UMEM feature can be found in the final patch in the aforementioned series.
Support for the kernel feature can eventually be detected in DPDK by querying the LINUX_KERNEL_VERSION. As of now the feature is not yet merged upstream, so for this RFC it is assumed the user is using a patched version of v5.8.
Shared UMEM is only available for zero copy mode.
In order to share UMEM information between PMDs, the ethdevs wishing to share must be tracked somehow. The method chosen to do so is similar to methods used in the vHost [2] and vDPA drivers, where pointers to the ethdevs are maintained in an internal list. Proposals for alternate solutions are welcome.
Performance data to follow with the v1.
[1] https://patchwork.ozlabs.org/project/netdev/cover/[email protected]/
[2] https://git.dpdk.org/dpdk/commit/?id=ee584e9710b9abd60ee9faef664e106dcea10085
Ciara Loftus (1):
net/af_xdp: shared UMEM support
doc/guides/nics/af_xdp.rst | 5 +- drivers/net/af_xdp/rte_eth_af_xdp.c | 315 ++++++++++++++++++++++------ 2 files changed, 252 insertions(+), 68 deletions(-)
Signature · 1 line
2.17.1
RFC PATCH 1/1 net/af_xdp: shared UMEM support
A future kernel will introduce the ability to efficiently share a UMEM between AF_XDP sockets bound to different queue ids on the same or different devices. This patch integrates that functionality into the AF_XDP PMD.
A PMD will attempt to share a UMEM with others if the shared_umem=1 vdev arg is set. UMEMs can only be shared across PMDs with the same mempool, up to a limited number of PMDs goverened by the size of the given mempool.
The benefit of sharing UMEM across PMDs is a saving in memory due to not having to register the UMEM multiple times.
--- doc/guides/nics/af_xdp.rst | 5 +- drivers/net/af_xdp/rte_eth_af_xdp.c | 315 ++++++++++++++++++++++------ 2 files changed, 252 insertions(+), 68 deletions(-)
doc/guides/nics/af_xdp.rst +4 -1
@@ -1,5 +1,5 @@ .. SPDX-License-Identifier: BSD-3-Clause - Copyright(c) 2019 Intel Corporation. + Copyright(c) 2020 Intel Corporation. AF_XDP Poll Mode Driver ==========================
@@ -32,6 +32,8 @@ The following options can be provided to set up an af_xdp port in DPDK. * ``iface`` - name of the Kernel interface to attach to (required); * ``start_queue`` - starting netdev queue id (optional, default 0); * ``queue_count`` - total netdev queue number (optional, default 1); +* ``shared_umem`` - PMD will attempt to share UMEM with others (optional, + default 0); Prerequisites -------------
@@ -45,6 +47,7 @@ This is a Linux-specific PMD, thus the following prerequisites apply: * A Kernel bound interface to attach to; * For need_wakeup feature, it requires kernel version later than v5.3-rc1; * For PMD zero copy, it requires kernel version later than v5.4-rc1; +* For shared_umem, it requires kernel version later than v5.TBD; Set up an af_xdp interface -----------------------------
drivers/net/af_xdp/rte_eth_af_xdp.c +248 -67
603 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 13 lines · Ciara Loftus
A future kernel will introduce the ability to efficiently share a UMEM between
AF_XDPsockets bound to different queue ids on the same or different devices. This patch integrates that functionality into theAF_XDPPMD.A PMD will attempt to share a UMEM with others if the shared_umem=1 vdev arg is set. UMEMs can only be shared across PMDs with the same mempool, up to a limited number of PMDs goverened by the size of the given mempool.
The benefit of sharing UMEM across PMDs is a saving in memory due to not having to register the UMEM multiple times.
Signed-off-by Ciara Loftus <[email protected]>
<...>
Quoted 16 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +2
-1@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright(c) 2019 Intel Corporation. +* Copyright(c) 2020 Intel Corporation. */ #include <unistd.h> #include <errno.h> @@ -15,6 +15,7 @@#include <linux/if_link.h> #include <linux/ethtool.h> #include <linux/sockios.h> +#include <linux/version.h> #include "af_xdp_deps.h" #include <bpf/xsk.h>
drivers/net/af_xdp/rte_eth_af_xdp.c line 45
Quoted 8 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +5
-0@@ -37,6 +38,11 @@#include <rte_mbuf.h> #include <rte_malloc.h> #include <rte_ring.h> +#include <rte_spinlock.h> + +#if KERNEL_VERSION (5 ,7 ,0 ) <LINUX_VERSION_CODE +#define ETH_AF_XDP_SHARED_UMEM 1 +#endif
I think better to separate these version checks from the actual code, what do you think creating a compat.h under 'net/af_xdp' and move above logic there?
<...>
Quoted 6 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +0
-2@@ -888,9 +1048,15 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq, cfg.bind_flags |=XDP_USE_NEED_WAKEUP ;#endif - ret = xsk_socket__create(&rxq->xsk, internals->if_name, - rxq->xsk_queue_idx, rxq->umem->umem, &rxq->rx,
drivers/net/af_xdp/rte_eth_af_xdp.c xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq, · line 1059
Quoted 10 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +9
-1- &txq->tx, &cfg); +if (!internals->shared_umem_configured) { + ret =xsk_socket__create (&rxq->xsk, internals->if_name, + rxq->xsk_queue_idx, rxq->umem->umem, &rxq->rx, + &txq->tx, &cfg); + }else { + ret =xsk_socket__create_shared (&rxq->xsk, internals->if_name, + rxq->xsk_queue_idx, rxq->umem->umem, &rxq->rx, + &txq->tx, &rxq->fq, &rxq->cq, &cfg); + }
Is the above dependency (ETH_AF_XDP_SHARED_UMEM) for the kernel 'af_xdp' code, or for 'libbpf.so'?
The 'xsk_socket__create_shared()' API is not available in the latest 'libbpf.so', I wonder if the kernel version check is to align with the correct 'libbpf.so' version.
If not how the dependent version of the 'libbpf.so' managed for DPDK?
Quoted 36 lines · Ciara Loftus
Quoted 6 lines
A future kernel will introduce the ability to efficiently share a UMEM between
AF_XDPsockets bound to different queue ids on the same or different devices. This patch integrates that functionality into theAF_XDPPMD.A PMD will attempt to share a UMEM with others if the shared_umem=1
vdev
Quoted 1 line
arg is set. UMEMs can only be shared across PMDs with the same
mempool, up
Quoted 6 lines
to a limited number of PMDs goverened by the size of the given mempool.
The benefit of sharing UMEM across PMDs is a saving in memory due to not having to register the UMEM multiple times.
Signed-off-by Ciara Loftus <[email protected]><...>
Quoted 15 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +2
-1@@ -1,5 +1,5 @@/* SPDX-License-Identifier: BSD-3-Clause -* Copyright(c) 2019 Intel Corporation. +* Copyright(c) 2020 Intel Corporation. */ #include <unistd.h> #include <errno.h> @@ -15,6 +15,7 @@#include <linux/if_link.h> #include <linux/ethtool.h> #include <linux/sockios.h> +#include <linux/version.h> #include "af_xdp_deps.h" #include <bpf/xsk.h>
Quoted 13 lines
drivers/net/af_xdp/rte_eth_af_xdp.c line 45
Quoted 9 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +5
-0@@ -37,6 +38,11 @@#include <rte_mbuf.h> #include <rte_malloc.h> #include <rte_ring.h> +#include <rte_spinlock.h> + +#if KERNEL_VERSION (5 ,7 ,0 ) <LINUX_VERSION_CODE +#define ETH_AF_XDP_SHARED_UMEM 1 +#endif I think better to separate these version checks from the actual code, what do you think creating a
compat.hunder 'net/af_xdp' and move above logic there?
Good suggestion. Much cleaner. I'll implement this.
Quoted 28 lines
<...>
Review xsk_configure(struct pmd_internals *internals,
Quoted 1 line
(quoted diff) +0
-0@@ -888,9 +1048,15 @@ xsk_configure(struct pmd_internals *internals,struct
pkt_rx_queue*rxq,drivers/net/af_xdp/rte_eth_af_xdp.c xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
Quoted 9 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +3
-3cfg.bind_flags |=XDP_USE_NEED_WAKEUP ;#endif - ret =xsk_socket__create (&rxq->xsk, internals->if_name, - rxq->xsk_queue_idx, rxq->umem->umem, &rxq->rx, - &txq->tx, &cfg); +if (!internals->shared_umem_configured) { + ret = xsk_socket__create(&rxq->xsk, internals->if_name, + rxq->xsk_queue_idx, rxq->umem->umem,
&rxq->rx,Review xsk_configure(struct pmd_internals *internals, · line 1058
Quoted 5 lines
(quoted diff) +4
-0+ &txq->tx, &cfg); + } else { + ret = xsk_socket__create_shared(&rxq->xsk, internals- if_name, + rxq->xsk_queue_idx, rxq->umem->umem,
&rxq->rx,drivers/net/af_xdp/rte_eth_af_xdp.c xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq, · line 1059
Quoted 2 lines
drivers/net/af_xdp/rte_eth_af_xdp.c +2
-0+ &txq->tx, &rxq->fq, &rxq->cq, &cfg); + }Is the above dependency (
ETH_AF_XDP_SHARED_UMEM) for the kernel 'af_xdp' code,
or for 'libbpf.so'?
Quoted 4 lines
The '
xsk_socket__create_shared()' API is not available in the latest 'libbpf.so', I wonder if the kernel version check is to align with the correct 'libbpf.so' version.
If not how the dependent version of the 'libbpf.so' managed for DPDK?
Good point.
For the RFC I'm assuming the user is using libbpf packaged with the kernel both with appropriate support.
In the next RFC/v1 I'll introduce a check for both the correct libbpf version and underlying kernel support, as both are required.
Thanks,
Ciara
Quoted 9 lines · Ciara Loftus
This RFC integrates shared UMEM support into the
AF_XDPPMD. It is based on the WIP kernel series [1] by Magnus Karlsson.Detailed information on the shared UMEM feature can be found in the final patch in the aforementioned series.
Support for the kernel feature can eventually be detected in DPDK by querying the
LINUX_KERNEL_VERSION. As of now the feature is not yet merged upstream, so for this RFC it is assumed the user is using a patched version of v5.8.
Hi Ciara,
I don't see this feature in kernel in 5.9.0-rc2, is there any update in the kernel side?
Quoted 20 lines
Shared UMEM is only available for zero copy mode.
In order to share UMEM information between PMDs, the ethdevs wishing to share must be tracked somehow. The method chosen to do so is similar to methods used in the vHost [2] and vDPA drivers, where pointers to the ethdevs are maintained in an internal list. Proposals for alternate solutions are welcome.
Performance data to follow with the v1.
[1] https://patchwork.ozlabs.org/project/netdev/cover/[email protected]/
[2] https://git.dpdk.org/dpdk/commit/?id=ee584e9710b9abd60ee9faef664e106dcea10085Ciara Loftus (1):
net/af_xdp: shared UMEM supportdoc/guides/nics/af_xdp.rst | 5 +- drivers/net/af_xdp/rte_eth_af_xdp.c | 315 ++++++++++++++++++++++------ 2 files changed, 252 insertions(+), 68 deletions(-)
Quoted 12 lines · Ciara Loftus
Quoted 1 line
This RFC integrates shared UMEM support into the
AF_XDPPMD. It isbased on the
Quoted 3 lines
WIP kernel series [1] by Magnus Karlsson.
Detailed information on the shared UMEM feature can be found in the final
patch
Quoted 3 lines
in the aforementioned series.
Support for the kernel feature can eventually be detected in DPDK by
querying
Quoted 8 lines
Quoted 1 line
the
LINUX_KERNEL_VERSION. As of now the feature is not yet mergedupstream, so
Quoted 1 line
for this RFC it is assumed the user is using a patched version of v5.8.
Hi Ciara,
I don't see this feature in kernel in 5.9.0-rc2, is there any update in the kernel side?
Hi Ferruh,
Some performance quirks have been identified with the latest version of the kernel patch. Once those are resolved we should expect a new revision, hopefully within the 5.9 window.
Thanks,
Ciara
Quoted 28 lines
Quoted 5 lines
Shared UMEM is only available for zero copy mode.
In order to share UMEM information between PMDs, the ethdevs wishing
to share
Quoted 1 line
must be tracked somehow. The method chosen to do so is similar to
methods used
Quoted 1 line
in the vHost [2] and vDPA drivers, where pointers to the ethdevs are
maintained
Quoted 5 lines
in an internal list. Proposals for alternate solutions are welcome.
Performance data to follow with the v1.
[1] https://patchwork.ozlabs.org/project/netdev/cover/1595307848-
Quoted 1 line
[2]
https://git.dpdk.org/dpdk/commit/?id=ee584e9710b9abd60ee9faef664e106
dcea10085Quoted 6 lines
Ciara Loftus (1):
net/af_xdp: shared UMEM supportdoc/guides/nics/af_xdp.rst | 5 +- drivers/net/af_xdp/rte_eth_af_xdp.c | 315 ++++++++++++++++++++++------
Quoted 2 lines
2 files changed, 252 insertions(+), 68 deletions(-)