numam-dpdk/lib
Anatoly Burakov 66cc45e293 mem: replace memseg with memseg lists
Before, we were aggregating multiple pages into one memseg, so the
number of memsegs was small. Now, each page gets its own memseg,
so the list of memsegs is huge. To accommodate the new memseg list
size and to keep the under-the-hood workings sane, the memseg list
is now not just a single list, but multiple lists. To be precise,
each hugepage size available on the system gets one or more memseg
lists, per socket.

In order to support dynamic memory allocation, we reserve all
memory in advance (unless we're in 32-bit legacy mode, in which
case we do not preallocate memory). As in, we do an anonymous
mmap() of the entire maximum size of memory per hugepage size, per
socket (which is limited to either RTE_MAX_MEMSEG_PER_TYPE pages or
RTE_MAX_MEM_MB_PER_TYPE megabytes worth of memory, whichever is the
smaller one), split over multiple lists (which are limited to
either RTE_MAX_MEMSEG_PER_LIST memsegs or RTE_MAX_MEM_MB_PER_LIST
megabytes per list, whichever is the smaller one). There is also
a global limit of CONFIG_RTE_MAX_MEM_MB megabytes, which is mainly
used for 32-bit targets to limit amounts of preallocated memory,
but can be used to place an upper limit on total amount of VA
memory that can be allocated by DPDK application.

So, for each hugepage size, we get (by default) up to 128G worth
of memory, per socket, split into chunks of up to 32G in size.
The address space is claimed at the start, in eal_common_memory.c.
The actual page allocation code is in eal_memalloc.c (Linux-only),
and largely consists of copied EAL memory init code.

Pages in the list are also indexed by address. That is, in order
to figure out where the page belongs, one can simply look at base
address for a memseg list. Similarly, figuring out IOVA address
of a memzone is a matter of finding the right memseg list, getting
offset and dividing by page size to get the appropriate memseg.

This commit also removes rte_eal_dump_physmem_layout() call,
according to deprecation notice [1], and removes that deprecation
notice as well.

On 32-bit targets due to limited VA space, DPDK will no longer
spread memory to different sockets like before. Instead, it will
(by default) allocate all of the memory on socket where master
lcore is. To override this behavior, --socket-mem must be used.

The rest of the changes are really ripple effects from the memseg
change - heap changes, compile fixes, and rewrites to support
fbarray-backed memseg lists. Due to earlier switch to _walk()
functions, most of the changes are simple fixes, however some
of the _walk() calls were switched to memseg list walk, where
it made sense to do so.

Additionally, we are also switching locks from flock() to fcntl().
Down the line, we will be introducing single-file segments option,
and we cannot use flock() locks to lock parts of the file. Therefore,
we will use fcntl() locks for legacy mem as well, in case someone is
unfortunate enough to accidentally start legacy mem primary process
alongside an already working non-legacy mem-based primary process.

[1] http://dpdk.org/dev/patchwork/patch/34002/

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Tested-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Tested-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Tested-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
2018-04-11 19:55:39 +02:00
..
librte_acl build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_bbdev bbdev: fix exported dynamic log type 2018-02-06 18:51:44 +01:00
librte_bitratestats bitratestats: fix library version in meson build 2018-03-28 00:07:35 +02:00
librte_cfgfile build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_cmdline convert snprintf to strlcpy 2018-04-04 17:33:08 +02:00
librte_compat compat: relicense some files 2018-02-06 23:13:47 +01:00
librte_cryptodev cryptodev: fix library version in meson build 2018-03-28 00:07:35 +02:00
librte_distributor build: set compat lib as universal dependency 2018-01-30 21:59:00 +01:00
librte_eal mem: replace memseg with memseg lists 2018-04-11 19:55:39 +02:00
librte_efd build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_ether ethdev: use contiguous allocation for DMA memory 2018-04-11 19:44:53 +02:00
librte_eventdev eventdev: fix library version in meson build 2018-03-28 00:07:35 +02:00
librte_flow_classify flow_classify: remove void pointer cast 2018-03-30 14:08:43 +02:00
librte_gro build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_gso build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_hash hash: fix missing spinlock unlock in add key 2018-04-10 23:35:40 +02:00
librte_ip_frag build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_jobstats build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_kni kni: set initial value for MTU 2018-02-01 01:03:26 +01:00
librte_kvargs kvargs: fix syntax in comments 2018-03-28 00:43:22 +02:00
librte_latencystats ethdev: return named opaque type instead of void pointer 2018-03-30 14:08:44 +02:00
librte_lpm lpm: fix allocation of an existing object 2018-02-01 00:35:06 +01:00
librte_mbuf mbuf: fix truncated strncpy 2018-04-04 17:34:20 +02:00
librte_member build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_mempool mem: replace memseg with memseg lists 2018-04-11 19:55:39 +02:00
librte_meter meter: fix library version in meson build 2018-03-28 00:07:35 +02:00
librte_metrics metrics: fix potential missing string termination 2018-04-04 17:33:08 +02:00
librte_net align SPDX Mellanox copyrights 2018-04-11 01:47:47 +02:00
librte_pci pci: use z specifier to format size_t 2018-04-04 13:43:33 +02:00
librte_pdump convert snprintf to strlcpy 2018-04-04 17:33:08 +02:00
librte_pipeline pipeline: add port in action APIs 2018-04-04 12:26:07 +02:00
librte_port build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_power build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_rawdev rawdev: add self test 2018-01-31 15:35:56 +01:00
librte_reorder build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_ring lib: remove unused map symbols 2018-02-13 14:55:01 +01:00
librte_sched build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_security build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_table table: remove incorrect check for ACL 2018-04-04 12:26:20 +02:00
librte_timer build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
librte_vhost vhost: avoid populate guest memory 2018-03-30 17:25:45 +02:00
Makefile rawdev: introduce raw device library 2018-01-31 15:35:01 +01:00
meson.build build: detect micro-arch on ARM 2018-01-30 21:59:00 +01:00