Commit b8dcef87 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull memblock updates from Mike Rapoport:

 - An optimization in memblock_add_range() to reduce array traversals

 - Improvements to the memblock test suite

* tag 'memblock-v5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock:
  memblock test: Modify the obsolete description in README
  memblock tests: fix compilation errors
  memblock tests: change build options to run-time options
  memblock tests: remove completed TODO items
  memblock tests: set memblock_debug to enable memblock_dbg() messages
  memblock tests: add verbose output to memblock tests
  memblock tests: Makefile: add arguments to control verbosity
  memblock: avoid some repeat when add new range
parents 15886321 04d94909
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -597,6 +597,17 @@ static int __init_memblock memblock_add_range(struct memblock_type *type,
		type->total_size = size;
		return 0;
	}

	/*
	 * The worst case is when new range overlaps all existing regions,
	 * then we'll need type->cnt + 1 empty regions in @type. So if
	 * type->cnt * 2 + 1 is less than type->max, we know
	 * that there is enough empty regions in @type, and we can insert
	 * regions directly.
	 */
	if (type->cnt * 2 + 1 < type->max)
		insert = true;

repeat:
	/*
	 * The following is executed twice.  Once with %false @insert and
+1 −2
Original line number Diff line number Diff line
@@ -45,9 +45,8 @@ help:
	@echo  '  clean		  - Remove generated files and symlinks in the directory'
	@echo  ''
	@echo  'Configuration:'
	@echo  '  make MEMBLOCK_DEBUG=1     - enable memblock_dbg() messages'
	@echo  '  make NUMA=1               - simulate enabled NUMA'
	@echo  '  make MOVABLE_NODE=1       - override `movable_node_is_enabled`'
	@echo  '                              definition to simulate movable NUMA nodes'
	@echo  '  make 32BIT_PHYS_ADDR_T=1  - Use 32 bit physical addresses'

vpath %.c ../../lib
+14 −3
Original line number Diff line number Diff line
@@ -33,12 +33,23 @@ To run the tests, build the main target and run it:

$ make && ./main

A successful run produces no output. It is also possible to override different
configuration parameters. For example, to simulate enabled NUMA, use:
A successful run produces no output. It is possible to control the behavior
by passing options from command line. For example, to include verbose output,
append the `-v` options when you run the tests:

$ ./main -v

This will print information about which functions are being tested and the
number of test cases that passed.

For the full list of options from command line, see `./main --help`.

It is also possible to override different configuration parameters to change
the test functions. For example, to simulate enabled NUMA, use:

$ make NUMA=1

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

Project structure
=================
+3 −11
Original line number Diff line number Diff line
TODO
=====

1. Add verbose output (e.g., what is being tested and how many tests cases are
   passing)

2. Add flags to Makefile:
   + verbosity level
   + enable memblock_dbg() messages (i.e. pass "-D CONFIG_DEBUG_MEMORY_INIT"
     flag)

3. Add tests trying to memblock_add() or memblock_reserve() 129th region.
1. Add tests trying to memblock_add() or memblock_reserve() 129th region.
   This will trigger memblock_double_array(), make sure it succeeds.
   *Important:* These tests require valid memory ranges, use dummy physical
                memory block from common.c to implement them. It is also very
                likely that the current MEM_SIZE won't be enough for these
                test cases. Use realloc to adjust the size accordingly.

4. Add test cases using this functions (implement them for both directions):
2. Add test cases using this functions (implement them for both directions):
   + memblock_alloc_raw()
   + memblock_alloc_exact_nid_raw()
   + memblock_alloc_try_nid_raw()

5. Add tests for memblock_alloc_node() to check if the correct NUMA node is set
3. Add tests for memblock_alloc_node() to check if the correct NUMA node is set
   for the new region
+11 −0
Original line number Diff line number Diff line
@@ -2,6 +2,17 @@
#ifndef _MM_INTERNAL_H
#define _MM_INTERNAL_H

/*
 * Enable memblock_dbg() messages
 */
#ifdef MEMBLOCK_DEBUG
static int memblock_debug = 1;
#endif

#define pr_warn_ratelimited(fmt, ...)    printf(fmt, ##__VA_ARGS__)

bool mirrored_kernelcore = false;

struct page {};

void memblock_free_pages(struct page *page, unsigned long pfn,
Loading