[v5,0/8] Windows basic memory management
mbox series

Message ID 20200525003720.6410-1-dmitry.kozliuk@gmail.com
Headers show
Series
  • Windows basic memory management
Related show

Message

Dmitry Kozlyuk May 25, 2020, 12:37 a.m. UTC
Note: cover letter updated for v5.

This patchset implements basic MM with the following features:

* Hugepages are dynamically allocated in user-mode.
* Only 2MB hugepages are supported.
* IOVA is always PA, obtained through kernel-mode driver.
* No 32-bit support (presumably not demanded).
* Ni multi-process support (it is forcefully disabled).
* No-huge mode for testing without IOVA is available.

Testing revealed Windows Server 2019 does not allow allocating hugepage
memory at a reserved address, despite advertised API.  So allocator has
to temporary free the region to be allocated.  This creates in inherent
race condition. This issue is being discussed with Microsoft privately.

New EAL public functions for memory mapping are introduced to mitigate
OS differences in DPDK libraries and applications: rte_mem_map,
rte_mem_unmap, rte_mem_lock, rte_get_page_size.

To support common MM routines, internal wrappers for low-level memory
reservation and file management are introduced. These changes affect
Linux and FreeBSD EAL. Shared code is placed unded /unix/ subdirectory
(suggested by Thomas).

To avoid code duplication between Linux and Windows EAL, common code
for EALs supporting dynamic memory allocation is extracted
(discussed with Anatoly Burakov in v4 thread). This is a separate
patch to ease the review, but it can be merged with the previous one.

EAL tracepoints save size_t values as long, which is invalid on Windows.
New size_t emitter for tracepoints is introduced (suggested by Jerin
Jacob to Fady Bader, see [1]). Also, to avoid workaround in every file
using the tracepoints, stubs are added to Windows EAL.

Entire <sys/queue.h> is imported from FreeBSD, replacing existing
partial import. There is already a license exception for this file.
The file is imported as-is, so it causes a bunch of checkpatch warnings.

[1]: http://mails.dpdk.org/archives/dev/2020-May/168076.html

---

v5:
    * Fix allocation and deallocation on Windows Server (Fady Bader).
    * Replace remaining VirtualFree with VirtualFreeEx (Ranjit Menon).
    * Fix errors in eal_get_virtual_area (Anatoly Burakov).
    * Fix error handling and documentation for rte_mem_lock (Anatoly Burakov).
    * Extract common code for EALs w/dynamic allocation (Anatoly Burakov).
    * Use POSIX value for rte_errno after rte_mem_unmap() on Windows.
    * Add stubs to use tracing functions without workarounds.

v4:

    * Rebase on ToT, drop patches merged into master.
    * Rearrange patches to split Windows code (Jerin).
    * Fix Linux and FreeBSD build with make (Ophir).
    * Use int instead of enum to hold a set of flags (Anatoly).
    * Rename eal_mem_reserve items and fix their description (Anatoly).
    * Add eal_mem_set_dump() wrapper around madvise (Anatoly).
    * Don't claim Windows Server 2016 support due to lack of API (Tal).
    * Replace enum rte_page_sizes with a set of #defines (Jerin).
    * Fix documentation, SPDX tags, logging (Thomas).

v3:

    * Fix Linux build on and aarch64 and 32-bit x86 (reported by CI).
    * Fix logic and error handling while allocating segments.
    * Fix Unix rte_mem_map(): return NULL on failure.
    * Fix some checkpatch.sh issues:
        * Do not return positive errno, use DWORD for GetLastError().
        * Make dpdk-kmods source files non-executable.
    * Improve GSG for Windows Server (suggested by Ranjit Menon).

v2:

    * Rebase on ToT. Move all new code shared between Linux and FreeBSD
      to /unix/ subdirectory, also factor out some existing code there.
    * Improve description of Clang issue with rte_page_sizes on Windows.
      Restore -fstrict-enum for EAL. Check running, not target compiler.
    * Use EAL prefix for private facilities instead if RTE.
    * Improve documentation comments for new functions.
    * Remove co-installer for virt2phys. Add a typecast for clarity.
    * Document virt2phys in user guide, improve its own README.
    * Explicitly and forcefully disable multi-process.


Dmitry Kozlyuk (11):
  eal: replace rte_page_sizes with a set of constants
  eal: introduce internal wrappers for file operations
  eal: introduce memory management wrappers
  eal/mem: extract common code for memseg list initialization
  eal/mem: extract common code for dynamic memory allocation
  trace: add size_t field emitter
  eal/windows: add tracing support stubs
  eal/windows: replace sys/queue.h with a complete one from FreeBSD
  eal/windows: improve CPU and NUMA node detection
  eal/windows: initialize hugepage info
  eal/windows: implement basic memory management

 config/meson.build                            |  12 +-
 doc/guides/windows_gsg/build_dpdk.rst         |  20 -
 doc/guides/windows_gsg/index.rst              |   1 +
 doc/guides/windows_gsg/run_apps.rst           |  95 +++
 lib/librte_eal/common/eal_common_dynmem.c     | 498 ++++++++++++
 lib/librte_eal/common/eal_common_fbarray.c    |  58 +-
 lib/librte_eal/common/eal_common_memory.c     | 152 +++-
 lib/librte_eal/common/eal_common_thread.c     |   5 +-
 lib/librte_eal/common/eal_private.h           | 228 +++++-
 lib/librte_eal/common/meson.build             |  16 +
 lib/librte_eal/common/rte_malloc.c            |   9 +
 lib/librte_eal/freebsd/Makefile               |   5 +
 lib/librte_eal/freebsd/eal_memory.c           |  94 +--
 lib/librte_eal/include/rte_eal_trace.h        |   8 +-
 lib/librte_eal/include/rte_memory.h           | 111 ++-
 lib/librte_eal/include/rte_trace_point.h      |   1 +
 lib/librte_eal/linux/Makefile                 |   5 +
 lib/librte_eal/linux/eal_memalloc.c           |   5 +-
 lib/librte_eal/linux/eal_memory.c             | 605 +--------------
 lib/librte_eal/meson.build                    |   4 +
 lib/librte_eal/rte_eal_exports.def            | 119 +++
 lib/librte_eal/rte_eal_version.map            |   6 +
 lib/librte_eal/unix/eal_unix.c                |  51 ++
 lib/librte_eal/unix/eal_unix_memory.c         | 152 ++++
 lib/librte_eal/unix/meson.build               |   7 +
 lib/librte_eal/windows/eal.c                  | 190 +++++
 lib/librte_eal/windows/eal_hugepages.c        | 108 +++
 lib/librte_eal/windows/eal_lcore.c            | 185 +++--
 lib/librte_eal/windows/eal_memalloc.c         | 442 +++++++++++
 lib/librte_eal/windows/eal_memory.c           | 710 ++++++++++++++++++
 lib/librte_eal/windows/eal_mp.c               | 103 +++
 lib/librte_eal/windows/eal_windows.h          |  85 +++
 lib/librte_eal/windows/include/meson.build    |   1 +
 lib/librte_eal/windows/include/rte_os.h       |   9 +
 .../windows/include/rte_virt2phys.h           |  34 +
 lib/librte_eal/windows/include/rte_windows.h  |   2 +
 lib/librte_eal/windows/include/sys/queue.h    | 663 ++++++++++++++--
 lib/librte_eal/windows/include/unistd.h       |   3 +
 lib/librte_eal/windows/meson.build            |   6 +
 lib/librte_mempool/rte_mempool_trace.h        |  10 +-
 40 files changed, 3903 insertions(+), 915 deletions(-)
 create mode 100644 doc/guides/windows_gsg/run_apps.rst
 create mode 100644 lib/librte_eal/common/eal_common_dynmem.c
 create mode 100644 lib/librte_eal/unix/eal_unix.c
 create mode 100644 lib/librte_eal/unix/eal_unix_memory.c
 create mode 100644 lib/librte_eal/unix/meson.build
 create mode 100644 lib/librte_eal/windows/eal_hugepages.c
 create mode 100644 lib/librte_eal/windows/eal_memalloc.c
 create mode 100644 lib/librte_eal/windows/eal_memory.c
 create mode 100644 lib/librte_eal/windows/eal_mp.c
 create mode 100644 lib/librte_eal/windows/include/rte_virt2phys.h