Please NOTE that this series is meant to illustrate an idea/approach and start
discussion on the topic.

Current implemetation allows reserving/creating memzones but not the opposite
(unreserve/delete). This affects mempools and other memzone based objects.

>From my point of view, implementing unreserve functionality for memzones would
look like malloc over memsegs.
Thus, this approach moves malloc inside eal (which in turn removes a circular
dependency), where malloc heaps are composed of memsegs.
We keep both malloc and memzone APIs as they are, but memzones allocate its
memory by calling malloc_heap_alloc (there would be some ABI changes, see 
below).
Some extra functionality is required in malloc to allow for boundary constrained
memory requests.
In summary, currently malloc is based on memzones, and with this approach
memzones are based on malloc.

An alternative would be to move malloc internals (malloc_heap, malloc_elem)
to the eal, but keeping the malloc library as is, where malloc is based on
memzones. This way we could avoid ABI changes while keeping the existing
circular dependency between malloc and eal.

TODOs:
 - Implement memzone_unreserve, simply call rte_malloc_free.
 - Implement mempool_delete, simply call rte_memzone_unreserve.
 - Init heaps with all available memsegs at once.
 - Review symbols in version map.

ABI changes:
 - Removed support for rte_memzone_reserve_xxxx with len=0 (not needed?).
 - Removed librte_malloc as single library (linker script as work around?).

IDEAS FOR FUTURE WORK:
 - More control over requested memory, ie. shared/private, phys_contig, etc.
   One of the goals would be trying to reduce the need of physically contiguous
   memory when not required.
 - Attach/unattach hugepages at runtime (faster VM migration).
 - Improve malloc algorithm? ie. jemalloc (or any other).


Any comments/toughts and/or different approaches are welcome.


Sergio Gonzalez Monroy (2):
  eal: move librte_malloc to eal/common
  eal: memzone allocated by malloc

 config/common_bsdapp                            |   9 +-
 config/common_linuxapp                          |   9 +-
 lib/Makefile                                    |   1 -
 lib/librte_acl/Makefile                         |   2 +-
 lib/librte_eal/bsdapp/eal/Makefile              |   4 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  18 ++
 lib/librte_eal/common/Makefile                  |   1 +
 lib/librte_eal/common/eal_common_memzone.c      | 233 ++--------------
 lib/librte_eal/common/include/rte_malloc.h      | 342 ++++++++++++++++++++++++
 lib/librte_eal/common/include/rte_malloc_heap.h |   4 +-
 lib/librte_eal/common/include/rte_memory.h      |   1 +
 lib/librte_eal/common/malloc_elem.c             | 342 ++++++++++++++++++++++++
 lib/librte_eal/common/malloc_elem.h             | 192 +++++++++++++
 lib/librte_eal/common/malloc_heap.c             | 287 ++++++++++++++++++++
 lib/librte_eal/common/malloc_heap.h             |  70 +++++
 lib/librte_eal/common/rte_malloc.c              | 259 ++++++++++++++++++
 lib/librte_eal/linuxapp/eal/Makefile            |   4 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  18 ++
 lib/librte_hash/Makefile                        |   2 +-
 lib/librte_lpm/Makefile                         |   2 +-
 lib/librte_malloc/Makefile                      |  52 ----
 lib/librte_malloc/malloc_elem.c                 | 320 ----------------------
 lib/librte_malloc/malloc_elem.h                 | 190 -------------
 lib/librte_malloc/malloc_heap.c                 | 209 ---------------
 lib/librte_malloc/malloc_heap.h                 |  70 -----
 lib/librte_malloc/rte_malloc.c                  | 260 ------------------
 lib/librte_malloc/rte_malloc.h                  | 342 ------------------------
 lib/librte_malloc/rte_malloc_version.map        |  19 --
 lib/librte_mempool/Makefile                     |   2 -
 lib/librte_pmd_af_packet/Makefile               |   1 -
 lib/librte_pmd_bond/Makefile                    |   1 -
 lib/librte_pmd_e1000/Makefile                   |   2 +-
 lib/librte_pmd_enic/Makefile                    |   2 +-
 lib/librte_pmd_fm10k/Makefile                   |   2 +-
 lib/librte_pmd_i40e/Makefile                    |   2 +-
 lib/librte_pmd_ixgbe/Makefile                   |   2 +-
 lib/librte_pmd_mlx4/Makefile                    |   1 -
 lib/librte_pmd_null/Makefile                    |   1 -
 lib/librte_pmd_pcap/Makefile                    |   1 -
 lib/librte_pmd_virtio/Makefile                  |   2 +-
 lib/librte_pmd_vmxnet3/Makefile                 |   2 +-
 lib/librte_pmd_xenvirt/Makefile                 |   2 +-
 lib/librte_port/Makefile                        |   1 -
 lib/librte_ring/Makefile                        |   3 +-
 lib/librte_table/Makefile                       |   1 -
 45 files changed, 1571 insertions(+), 1719 deletions(-)
 create mode 100644 lib/librte_eal/common/include/rte_malloc.h
 create mode 100644 lib/librte_eal/common/malloc_elem.c
 create mode 100644 lib/librte_eal/common/malloc_elem.h
 create mode 100644 lib/librte_eal/common/malloc_heap.c
 create mode 100644 lib/librte_eal/common/malloc_heap.h
 create mode 100644 lib/librte_eal/common/rte_malloc.c
 delete mode 100644 lib/librte_malloc/Makefile
 delete mode 100644 lib/librte_malloc/malloc_elem.c
 delete mode 100644 lib/librte_malloc/malloc_elem.h
 delete mode 100644 lib/librte_malloc/malloc_heap.c
 delete mode 100644 lib/librte_malloc/malloc_heap.h
 delete mode 100644 lib/librte_malloc/rte_malloc.c
 delete mode 100644 lib/librte_malloc/rte_malloc.h
 delete mode 100644 lib/librte_malloc/rte_malloc_version.map

-- 
1.9.3

Reply via email to