Skip to content

Add tests for memblock allocation functions

Karolina Drobnik linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9memblock tests: Split up reset_memblock functiontools/testing/memblock/tests/basic_api.c tools/testing/memblock/tests/common.c tools/testing/memblock/tests/common.h+33 -320 replies
2/9memblock tests: Add simulation of physical memorytools/testing/memblock/tests/basic_api.c tools/testing/memblock/tests/basic_api.h tools/testing/memblock/tests/common.c +1 more+37 -20 replies
3/9memblock tests: Add memblock_alloc tests for top downtools/testing/memblock/Makefile tools/testing/memblock/main.c tools/testing/memblock/tests/alloc_api.c +1 more+441 -10 replies
4/9memblock tests: Add memblock_alloc tests for bottom uptools/testing/memblock/tests/alloc_api.c+318 -40 replies
5/9memblock tests: Add memblock_alloc_from tests for top downtools/testing/memblock/Makefile tools/testing/memblock/main.c tools/testing/memblock/tests/alloc_helpers_api.c +1 more+239 -10 replies
6/9memblock tests: Add memblock_alloc_from tests for bottom uptools/testing/memblock/tests/alloc_helpers_api.c+171 -40 replies
7/9memblock tests: Add memblock_alloc_try_nid tests for top downtools/testing/memblock/Makefile tools/testing/memblock/main.c tools/testing/memblock/tests/alloc_nid_api.c +1 more+692 -20 replies
8/9memblock tests: Add memblock_alloc_try_nid tests for bottom uptools/testing/memblock/tests/alloc_nid_api.c+492 -40 replies
9/9memblock tests: Add TODO and README filestools/testing/memblock/README tools/testing/memblock/TODO+142 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/9] Add tests for memblock allocation functions

Patches are on top of memblock/for-next.

This series adds test coverage for memblock allocation functions that return virtual addresses:
* memblock_alloc
* memblock_alloc_try_nid
* memblock_alloc_from

These tests are a part of memblock simulator, a user space test suite that uses the actual memblock code[1]. All the tests are run as one, monolithic test, that exercises both basic operations and allocation functions of memblock.

To simplify implementation of the memory allocation tests, reset_memblock() was split into two functions - reset_memblock_attributes() and reset_memblock_regions(). The former sets default values for region array names, allocation direction flag (bottom_up) and current memory limit. The latter only resets region arrays and corresponding counters.

In addition to these, the patch set introduces a data structure that simulates physical memory, test_memory. It is a simple wrapper around a pointer to the memory block allocated via malloc(), which is added to memblock as available memory. This is required because the tested functions interact with the memory before allocating it.

Patchset structure:
* Patch 1 splits reset_memblock() into two functions - reset_memblock_regions() and reset_memblock_attributes(), and updates basic API tests to use the new definitions
* Patch 2 adds test_memory struct and functions to add (or release) dummy physical memory
* Patches 3 - 8 add test cases for memblock_alloc, memblock_alloc_try_nid and memblock_alloc_from for both allocation directions (default top down and bottom up)
* Patch 9 adds README and TODO files

[1] https://lore.kernel.org/linux-mm/[email protected]/

Karolina Drobnik (9):
memblock tests: Split up reset_memblock function memblock tests: Add simulation of physical memory memblock tests: Add memblock_alloc tests for top down memblock tests: Add memblock_alloc tests for bottom up memblock tests: Add memblock_alloc_from tests for top down memblock tests: Add memblock_alloc_from tests for bottom up memblock tests: Add memblock_alloc_try_nid tests for top down memblock tests: Add memblock_alloc_try_nid tests for bottom up memblock tests: Add TODO and README files

 tools/testing/memblock/Makefile               |    3 +-
 tools/testing/memblock/README                 |  114 ++
 tools/testing/memblock/TODO                   |   28 +
 tools/testing/memblock/main.c                 |    7 +
 tools/testing/memblock/tests/alloc_api.c      |  742 +++++++++++
 tools/testing/memblock/tests/alloc_api.h      |    9 +
 .../memblock/tests/alloc_helpers_api.c        |  393 ++++++
 .../memblock/tests/alloc_helpers_api.h        |    9 +
 tools/testing/memblock/tests/alloc_nid_api.c  | 1167 +++++++++++++++++
 tools/testing/memblock/tests/alloc_nid_api.h  |    9 +
 tools/testing/memblock/tests/basic_api.c      |   49 +-
 tools/testing/memblock/tests/basic_api.h      |    1 -
 tools/testing/memblock/tests/common.c         |   33 +-
 tools/testing/memblock/tests/common.h         |   21 +-
 14 files changed, 2550 insertions(+), 35 deletions(-)
 create mode 100644 tools/testing/memblock/README
 create mode 100644 tools/testing/memblock/TODO
 create mode 100644 tools/testing/memblock/tests/alloc_api.c
 create mode 100644 tools/testing/memblock/tests/alloc_api.h
 create mode 100644 tools/testing/memblock/tests/alloc_helpers_api.c
 create mode 100644 tools/testing/memblock/tests/alloc_helpers_api.h
 create mode 100644 tools/testing/memblock/tests/alloc_nid_api.c
 create mode 100644 tools/testing/memblock/tests/alloc_nid_api.h

base-commit: f30b002ccfee8c60c8feb590e145c0b5e8fa4c67 --
2.30.2