linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Karolina Drobnik <karolinadrobnik@gmail.com>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, mike.rapoport@gmail.com,
	linux-kernel@vger.kernel.org,
	Karolina Drobnik <karolinadrobnik@gmail.com>
Subject: [PATCH 00/16] Introduce memblock simulator
Date: Thu, 27 Jan 2022 14:21:18 +0100	[thread overview]
Message-ID: <cover.1643206612.git.karolinadrobnik@gmail.com> (raw)

Memblock is a boot time memory allocator, which allows managing memory
regions before the actual memory management is initialized. Because it is
used so early during the booting process, testing and debugging it is
difficult. As memblock has few kernel dependencies, it is possible to
simulate its runtime behaviour in userspace after stubbing a couple of
structs and functions.

This series of patches adds an initial version of a test suite for
memblock, which is a part of tools/testing infrastructure. Checks included
here test the basic functionality of memblock, which is memory regions
management - adding/removing available regions, marking them as reserved
or freeing them.

To run the tests, build the main target and run it:

$ make; ./main

A successful run produces no output. Also, It is possible to override
different configuration parameters. For example, to simulate enabled NUMA,
use:

$ make NUMA=1

For the full list of options, see `make help`.

The future work will include tests for memory allocation done via
memblock_alloc_* and memblock_phys_alloc_* family of functions. It will
also focus on improving the test suite by adding dedicated test targets
for each group of API functions and verbose output.

For a refresher on memblock, see Boot time memory management
documentation page[1] and "Getting to know memblock"[2] blog post.

Patchset structure:

* Patch 1 extracts stub definitions of kmalloc/kfree from the radix-tree
  testing suite, so they can be used in other tests, including memblock
  simulator
* Patches 2-4 update tools headers to include missing definitions needed
  by memblock (e.g. phys_addr_t typedef)
* Patches 5-9 add new files to tools/include, some with dummy/downsized
  definitions
* Patch 10 adds the basic project with local stubs that are closely
  connected to memblock
* Patch 11 adds a reset function, which is used as a part of the test
  setup. This functionality is needed, as memblock is reused in each check
* Patches 12-16 add basic test cases for the core memblock functionalities

[1] - https://www.kernel.org/doc/html/latest/core-api/boot-time-mm.html
[2] - https://insecuremode.com/post/2021/12/14/getting-to-know-memblock.html

Karolina Drobnik (16):
  tools: Move gfp.h and slab.h from radix-tree to lib
  tools/include: Add phys_addr_t to types.h
  tools/include: Add _RET_IP_ and math definitions to kernel.h
  tools/include: Update atomic.h header
  tools/include: Add mm.h file
  tools/include: Add cache.h stub
  tools/include: Add io.h stub
  tools/include: Add pfn.h stub
  tools/include: Add debugfs.h stub
  memblock tests: Add skeleton of the memblock simulator
  memblock tests: Add memblock reset function
  memblock tests: Add memblock_add tests
  memblock tests: Add memblock_reserve tests
  memblock tests: Add memblock_remove tests
  memblock tests: Add memblock_add_node test
  memblock tests: Add memblock_free tests

 MAINTAINERS                                   |   1 +
 tools/include/linux/atomic.h                  |   4 +
 tools/include/linux/cache.h                   |  10 +
 tools/include/linux/debugfs.h                 |   5 +
 tools/include/linux/gfp.h                     |  28 +
 tools/include/linux/io.h                      |   5 +
 tools/include/linux/kernel.h                  |   6 +
 tools/include/linux/mm.h                      |  42 +
 tools/include/linux/pfn.h                     |  10 +
 .../radix-tree => include}/linux/slab.h       |  25 +-
 tools/include/linux/types.h                   |   6 +
 tools/lib/slab.c                              |  38 +
 tools/testing/memblock/.gitignore             |   6 +
 tools/testing/memblock/Makefile               |  53 ++
 tools/testing/memblock/asm/dma.h              |   5 +
 tools/testing/memblock/internal.h             |  12 +
 tools/testing/memblock/lib/slab.c             |   9 +
 tools/testing/memblock/linux/init.h           |  34 +
 tools/testing/memblock/linux/kernel.h         |  12 +
 tools/testing/memblock/linux/kmemleak.h       |  18 +
 tools/testing/memblock/linux/memory_hotplug.h |  19 +
 tools/testing/memblock/linux/mmzone.h         |  35 +
 tools/testing/memblock/linux/printk.h         |  25 +
 tools/testing/memblock/main.c                 |   8 +
 tools/testing/memblock/mmzone.c               |  20 +
 .../testing/memblock/scripts/Makefile.include |  17 +
 tools/testing/memblock/tests/basic_api.c      | 896 ++++++++++++++++++
 tools/testing/memblock/tests/basic_api.h      |  10 +
 tools/testing/memblock/tests/common.c         |  27 +
 tools/testing/memblock/tests/common.h         |  15 +
 tools/testing/radix-tree/Makefile             |   3 +-
 tools/testing/radix-tree/linux.c              |  27 -
 tools/testing/radix-tree/linux/gfp.h          |  33 -
 33 files changed, 1396 insertions(+), 68 deletions(-)
 create mode 100644 tools/include/linux/cache.h
 create mode 100644 tools/include/linux/debugfs.h
 create mode 100644 tools/include/linux/io.h
 create mode 100644 tools/include/linux/mm.h
 create mode 100644 tools/include/linux/pfn.h
 rename tools/{testing/radix-tree => include}/linux/slab.h (61%)
 create mode 100644 tools/lib/slab.c
 create mode 100644 tools/testing/memblock/.gitignore
 create mode 100644 tools/testing/memblock/Makefile
 create mode 100644 tools/testing/memblock/asm/dma.h
 create mode 100644 tools/testing/memblock/internal.h
 create mode 100644 tools/testing/memblock/lib/slab.c
 create mode 100644 tools/testing/memblock/linux/init.h
 create mode 100644 tools/testing/memblock/linux/kernel.h
 create mode 100644 tools/testing/memblock/linux/kmemleak.h
 create mode 100644 tools/testing/memblock/linux/memory_hotplug.h
 create mode 100644 tools/testing/memblock/linux/mmzone.h
 create mode 100644 tools/testing/memblock/linux/printk.h
 create mode 100644 tools/testing/memblock/main.c
 create mode 100644 tools/testing/memblock/mmzone.c
 create mode 100644 tools/testing/memblock/scripts/Makefile.include
 create mode 100644 tools/testing/memblock/tests/basic_api.c
 create mode 100644 tools/testing/memblock/tests/basic_api.h
 create mode 100644 tools/testing/memblock/tests/common.c
 create mode 100644 tools/testing/memblock/tests/common.h
 delete mode 100644 tools/testing/radix-tree/linux/gfp.h

--
2.30.2



             reply	other threads:[~2022-01-27 13:22 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 13:21 Karolina Drobnik [this message]
2022-01-27 13:21 ` [PATCH 01/16] tools: Move gfp.h and slab.h from radix-tree to lib Karolina Drobnik
2022-01-27 13:28   ` Matthew Wilcox
2022-01-28 11:00     ` Karolina Drobnik
2022-01-27 13:36   ` Matthew Wilcox
2022-01-28 11:02     ` Karolina Drobnik
2022-01-28 17:30       ` Karolina Drobnik
2022-01-27 13:21 ` [PATCH 02/16] tools/include: Add phys_addr_t to types.h Karolina Drobnik
2022-01-27 13:21 ` [PATCH 03/16] tools/include: Add _RET_IP_ and math definitions to kernel.h Karolina Drobnik
2022-01-27 13:54   ` Matthew Wilcox
2022-01-28 11:05     ` Karolina Drobnik
2022-01-27 13:21 ` [PATCH 04/16] tools/include: Update atomic.h header Karolina Drobnik
2022-01-27 13:56   ` Matthew Wilcox
2022-01-28 11:08     ` Karolina Drobnik
2022-01-27 13:21 ` [PATCH 05/16] tools/include: Add mm.h file Karolina Drobnik
2022-01-27 13:21 ` [PATCH 06/16] tools/include: Add cache.h stub Karolina Drobnik
2022-01-27 14:00   ` Matthew Wilcox
2022-01-28 11:13     ` Karolina Drobnik
2022-01-28 13:10       ` Matthew Wilcox
2022-01-27 13:21 ` [PATCH 07/16] tools/include: Add io.h stub Karolina Drobnik
2022-01-27 14:09   ` Matthew Wilcox
2022-01-28 11:21     ` Karolina Drobnik
2022-01-30 16:10       ` Mike Rapoport
2022-01-30 17:53         ` Matthew Wilcox
2022-01-30 19:00           ` Mike Rapoport
2022-01-31 10:55           ` Karolina Drobnik
2022-01-31 13:30           ` Arnd Bergmann
2022-01-31 15:18             ` Mike Rapoport
2022-01-31 16:26               ` Arnd Bergmann
2022-01-31 10:54         ` Karolina Drobnik
2022-01-27 13:21 ` [PATCH 08/16] tools/include: Add pfn.h stub Karolina Drobnik
2022-01-27 13:21 ` [PATCH 09/16] tools/include: Add debugfs.h stub Karolina Drobnik
2022-01-27 13:21 ` [PATCH 10/16] memblock tests: Add skeleton of the memblock simulator Karolina Drobnik
2022-01-27 14:02   ` Matthew Wilcox
2022-01-27 14:06   ` Matthew Wilcox
2022-01-28 11:25     ` Karolina Drobnik
2022-01-28 13:11       ` Matthew Wilcox
2022-01-27 13:21 ` [PATCH 11/16] memblock tests: Add memblock reset function Karolina Drobnik
2022-01-27 13:21 ` [PATCH 12/16] memblock tests: Add memblock_add tests Karolina Drobnik
2022-01-27 13:21 ` [PATCH 13/16] memblock tests: Add memblock_reserve tests Karolina Drobnik
2022-01-27 13:21 ` [PATCH 14/16] memblock tests: Add memblock_remove tests Karolina Drobnik
2022-01-27 13:21 ` [PATCH 15/16] memblock tests: Add memblock_add_node test Karolina Drobnik
2022-01-27 13:21 ` [PATCH 16/16] memblock tests: Add memblock_free tests Karolina Drobnik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1643206612.git.karolinadrobnik@gmail.com \
    --to=karolinadrobnik@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.rapoport@gmail.com \
    --subject='Re: [PATCH 00/16] Introduce memblock simulator' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).