Skip to content

Support externally allocated memory in DPDK

Anatoly Burakov dpdk-dev 9 versions – Applied

Status from this message: Applied, thanks

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v9 Latest21 patches 2 repliesApplied
  2. v821 patches 4 repliesSuperseded
  3. v721 patches 0 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v621 patches14 repliesSuperseded
v521 patches3 repliesSuperseded
v420 patches2 repliesSuperseded
v320 patches2 repliesSuperseded
v220 patches2 repliesSuperseded
v116 patches6 repliesSuperseded

v9 -> v8 changes from the cover letter

- Rebase on latest master
- Minor cosmetic testpmd changes as per Bernard's feedback
- Pack structures better (Stephen's suggestion)
- Touch pages before finding their IOVA address

Patches in v9 Applied

#Subject and filesSizeRepliesApplied
1/21mem: add length to memseg listdoc/guides/rel_notes/release_18_11.rst drivers/bus/pci/linux/pci.c lib/librte_eal/bsdapp/eal/Makefile +7 more+22 -110 replies
2/21mem: allow memseg lists to be marked as externaldoc/guides/rel_notes/deprecation.rst doc/guides/rel_notes/release_18_11.rst drivers/bus/fslmc/fslmc_vfio.c +16 more+119 -380 replies
3/21malloc: index heaps using heap ID rather than NUMA nodeconfig/common_base config/rte_config.h doc/guides/rel_notes/release_18_11.rst +5 more+114 -440 replies
4/21mem: do not check for invalid socket IDdoc/guides/rel_notes/release_18_11.rst lib/librte_eal/common/eal_common_memzone.c lib/librte_eal/common/malloc_heap.c +1 more+13 -80 replies
5/21flow_classify: do not check for invalid socket IDlib/librte_flow_classify/rte_flow_classify.c+1 -20 replies
6/21pipeline: do not check for invalid socket IDlib/librte_pipeline/rte_pipeline.c+1 -20 replies
7/21sched: do not check for invalid socket IDlib/librte_sched/rte_sched.c+1 -10 replies
8/21malloc: add name to malloc heapsdoc/guides/rel_notes/release_18_11.rst lib/librte_eal/common/include/rte_malloc_heap.h lib/librte_eal/common/malloc_heap.c +1 more+21 -10 replies
9/21malloc: add function to query socket ID of named heaplib/librte_eal/common/include/rte_malloc.h lib/librte_eal/common/rte_malloc.c lib/librte_eal/rte_eal_version.map+52 -00 replies
10/21malloc: add function to check if socket is externallib/librte_eal/common/include/rte_malloc.h lib/librte_eal/common/rte_malloc.c lib/librte_eal/rte_eal_version.map +1 more+60 -30 replies
11/21malloc: allow creating malloc heapsdoc/guides/rel_notes/release_18_11.rst lib/librte_eal/common/include/rte_eal_memconfig.h lib/librte_eal/common/include/rte_malloc.h +4 more+117 -00 replies
12/21malloc: allow destroying heapslib/librte_eal/common/include/rte_malloc.h lib/librte_eal/common/malloc_heap.c lib/librte_eal/common/malloc_heap.h +2 more+107 -00 replies
13/21malloc: allow adding memory to named heapslib/librte_eal/common/include/rte_malloc.h lib/librte_eal/common/malloc_heap.c lib/librte_eal/common/malloc_heap.h +2 more+169 -00 replies
14/21malloc: allow removing memory from named heapslib/librte_eal/common/include/rte_malloc.h lib/librte_eal/common/malloc_heap.c lib/librte_eal/common/malloc_heap.h +2 more+125 -00 replies
15/21malloc: allow attaching to external memory chunkslib/librte_eal/common/include/rte_malloc.h lib/librte_eal/common/rte_malloc.c lib/librte_eal/rte_eal_version.map+112 -00 replies
16/21malloc: allow detaching from external memorylib/librte_eal/common/include/rte_malloc.h lib/librte_eal/common/rte_malloc.c lib/librte_eal/rte_eal_version.map+52 -70 replies
17/21malloc: enable event callbacks for external memorydrivers/bus/fslmc/fslmc_vfio.c drivers/net/virtio/virtio_user/virtio_user_dev.c lib/librte_eal/common/malloc_heap.c +2 more+51 -60 replies
18/21test: add unit tests for external memory supporttest/test/Makefile test/test/autotest_data.py test/test/meson.build +1 more+401 -40 replies
19/21app/testpmd: add support for external memoryapp/test-pmd/config.c app/test-pmd/parameters.c app/test-pmd/testpmd.c +2 more+369 -251 reply
20/21doc: add external memory feature to the release notesdoc/guides/rel_notes/release_18_11.rst+6 -00 replies
21/21doc: add external memory feature to programmer's guidedoc/guides/prog_guide/env_abstraction_layer.rst+37 -00 replies

Reviews trailers per patch

6 of 21 patches have a Reviewed-by or Acked-by.

PatchAndrew RybchenkoYongseok KohCristian DumitrescuShreyansh JainBernard Iremonger
1/21A-b
2/21A-b A-b
3/21
4/21
5/21A-b
6/21A-b
7/21A-b
8/21
9/21
10/21
11/21
12/21
13/21
14/21
15/21
16/21
17/21
18/21
19/21A-b
20/21
21/21

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v9 thread

Cover letter [PATCH v9 00/21] Support externally allocated memory in DPDK

This is a proposal to enable using externally allocated memory in DPDK.

In a nutshell, here is what is being done here:

- Index internal malloc heaps by NUMA node index, rather than NUMA node itself (external heaps will have ID's in order of creation)
- Add identifier string to malloc heap, to uniquely identify it
- Each new heap will receive a unique socket ID that will be used by allocator to decide from which heap (internal or external) to allocate requested amount of memory
- Allow creating named heaps and add/remove memory to/from those heaps
- Allocate memseg lists at runtime, to keep track of IOVA addresses of externally allocated memory
- If IOVA addresses aren't provided, use RTE_BAD_IOVA
- Allow malloc and memzones to allocate from external heaps
- Allow other data structures to allocate from externall heaps

The responsibility to ensure memory is accessible before using it is on the shoulders of the user - there is no checking done with regards to validity of the memory (nor could there be...).

The general approach is to create heap and add memory into it. For any other process wishing to use the same memory, said memory must first be attached (otherwise some things will not work).

A design decision was made to make multiprocess synchronization a manual process. Due to underlying issues with attaching to fbarrays in secondary processes, this design was deemed to be better because we don't want to fail to create external heap in the primary because something in the secondary has failed when in fact we may not eve have wanted this memory to be accessible in the secondary in the first place.

Using external memory in multiprocess is *hard*, because not only memory space needs to be preallocated, but it also needs to be attached in each process to allow other processes to access the page table. The attach API call may or may not succeed, depending on memory layout, for reasons similar to other multiprocess failures. This is treated as a "known issue" for this release.

v9 -> v8 changes:
- Rebase on latest master
- Minor cosmetic testpmd changes as per Bernard's feedback
- Pack structures better (Stephen's suggestion)
- Touch pages before finding their IOVA address

v8 -> v7 changes:
- Rebase on latest master
- More documentation on ABI changes

v7 -> v6 changes:
- Fixed missing IOVA address setup in testpmd
- Fixed MLX drivers as per Yongseok's comments
- Added a check for invalid heap idx on adding memory to heap

v6 -> v5 changes:
- Fixed documentation formatting as per Marko's comments

v5 -> v4 changes:
- All processes are now able to create and destroy malloc heaps
- Memory is automatically mapped for DMA on adding it to heap
- Mem event callbacks are triggered on adding/removing memory
- Fixed compile issues on FreeBSD
- Better documentation on API/ABI changes

v4 -> v3 changes:
- Dropped sample application in favor of new testpmd flag
- Added new flag to testpmd, with four options of mempool allocation
- Added new API to check if a socket ID belongs to an external heap
- Adjusted malloc and mempool code to not make any assumptions about IOVA-contiguousness when dealing with externally allocated memory

v3 -> v2 changes:
- Rebase on top of latest master
- Clarifications added to mempool code as per Andrew Rynchenko's comments

v2 -> v1 changes:
- Fixed NULL dereference on heap socket ID lookup
- Fixed memseg offset calculation on adding memory to heap
- Improved unit test to test for above bugfixes
- Restricted heap creation to primary processes only
- Added sample application
- Added documentation

RFC -> v1 changes:
- Removed the "named heaps" API, allocate using fake socket ID instead
- Added multiprocess support
- Everything is now thread-safe
- Numerous bugfixes and API improvements

Anatoly Burakov (21):
mem: add length to memseg list
mem: allow memseg lists to be marked as external
malloc: index heaps using heap ID rather than NUMA node
mem: do not check for invalid socket ID
flow_classify: do not check for invalid socket ID
pipeline: do not check for invalid socket ID
sched: do not check for invalid socket ID
malloc: add name to malloc heaps
malloc: add function to query socket ID of named heap
malloc: add function to check if socket is external
malloc: allow creating malloc heaps
malloc: allow destroying heaps
malloc: allow adding memory to named heaps
malloc: allow removing memory from named heaps
malloc: allow attaching to external memory chunks
malloc: allow detaching from external memory
malloc: enable event callbacks for external memory
test: add unit tests for external memory support app/testpmd: add support for external memory
doc: add external memory feature to the release notes
doc: add external memory feature to programmer's guide

 app/test-pmd/config.c                         |  21 +-
 app/test-pmd/parameters.c                     |  23 +-
 app/test-pmd/testpmd.c                        | 325 ++++++++++++-
 app/test-pmd/testpmd.h                        |  13 +-
 config/common_base                            |   1 +
 config/rte_config.h                           |   1 +
 .../prog_guide/env_abstraction_layer.rst      |  37 ++
 doc/guides/rel_notes/deprecation.rst          |  15 -
 doc/guides/rel_notes/release_18_11.rst        |  36 +-
 doc/guides/testpmd_app_ug/run_app.rst         |  12 +
 drivers/bus/fslmc/fslmc_vfio.c                |  13 +-
 drivers/bus/pci/linux/pci.c                   |   2 +-
 drivers/net/mlx5/mlx5.c                       |   4 +-
 drivers/net/virtio/virtio_user/vhost_kernel.c |   3 +
 .../net/virtio/virtio_user/virtio_user_dev.c  |   6 +
 lib/librte_eal/bsdapp/eal/Makefile            |   2 +-
 lib/librte_eal/bsdapp/eal/eal.c               |   3 +
 lib/librte_eal/bsdapp/eal/eal_memory.c        |   9 +-
 lib/librte_eal/common/eal_common_memory.c     |   8 +-
 lib/librte_eal/common/eal_common_memzone.c    |   8 +-
 .../common/include/rte_eal_memconfig.h        |  11 +-
 lib/librte_eal/common/include/rte_malloc.h    | 192 ++++++++
 .../common/include/rte_malloc_heap.h          |   3 +
 lib/librte_eal/common/include/rte_memory.h    |   9 +
 lib/librte_eal/common/malloc_elem.c           |  10 +-
 lib/librte_eal/common/malloc_heap.c           | 320 +++++++++++--
 lib/librte_eal/common/malloc_heap.h           |  17 +
 lib/librte_eal/common/rte_malloc.c            | 429 +++++++++++++++++-
 lib/librte_eal/linuxapp/eal/Makefile          |   2 +-
 lib/librte_eal/linuxapp/eal/eal.c             |  10 +-
 lib/librte_eal/linuxapp/eal/eal_memalloc.c    |  12 +-
 lib/librte_eal/linuxapp/eal/eal_memory.c      |   4 +-
 lib/librte_eal/linuxapp/eal/eal_vfio.c        |  27 +-
 lib/librte_eal/meson.build                    |   2 +-
 lib/librte_eal/rte_eal_version.map            |   8 +
 lib/librte_flow_classify/rte_flow_classify.c  |   3 +-
 lib/librte_mempool/rte_mempool.c              |  57 ++-
 lib/librte_pipeline/rte_pipeline.c            |   3 +-
 lib/librte_sched/rte_sched.c                  |   2 +-
 test/test/Makefile                            |   1 +
 test/test/autotest_data.py                    |  14 +-
 test/test/meson.build                         |   1 +
 test/test/test_external_mem.c                 | 389 ++++++++++++++++
 test/test/test_malloc.c                       |   3 +
 test/test/test_memzone.c                      |   3 +
 45 files changed, 1936 insertions(+), 138 deletions(-)
 create mode 100644 test/test/test_external_mem.c
Signature · 1 line
2.17.1