Commit ca1dcc6d authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'memblock-v5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock

Pull memblock test suite updates from Mike Rapoport:
 "Comment updates for memblock test suite

  Update comments in the memblock tests so that they will have
  consistent style"

* tag 'memblock-v5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock:
  memblock tests: remove completed TODO item
  memblock tests: update style of comments for memblock_free_*() functions
  memblock tests: update style of comments for memblock_remove_*() functions
  memblock tests: update style of comments for memblock_reserve_*() functions
  memblock tests: update style of comments for memblock_add_*() functions
parents 690b2549 000605cd
...@@ -23,6 +23,3 @@ TODO ...@@ -23,6 +23,3 @@ TODO
5. Add tests for memblock_alloc_node() to check if the correct NUMA node is set 5. Add tests for memblock_alloc_node() to check if the correct NUMA node is set
for the new region for the new region
6. Update comments in tests/basic_api.c to match the style used in
tests/alloc_*.c
...@@ -26,8 +26,8 @@ static int memblock_initialization_check(void) ...@@ -26,8 +26,8 @@ static int memblock_initialization_check(void)
/* /*
* A simple test that adds a memory block of a specified base address * A simple test that adds a memory block of a specified base address
* and size to the collection of available memory regions (memblock.memory). * and size to the collection of available memory regions (memblock.memory).
* It checks if a new entry was created and if region counter and total memory * Expect to create a new entry. The region counter and total memory get
* were correctly updated. * updated.
*/ */
static int memblock_add_simple_check(void) static int memblock_add_simple_check(void)
{ {
...@@ -53,10 +53,10 @@ static int memblock_add_simple_check(void) ...@@ -53,10 +53,10 @@ static int memblock_add_simple_check(void)
} }
/* /*
* A simple test that adds a memory block of a specified base address, size * A simple test that adds a memory block of a specified base address, size,
* NUMA node and memory flags to the collection of available memory regions. * NUMA node and memory flags to the collection of available memory regions.
* It checks if the new entry, region counter and total memory size have * Expect to create a new entry. The region counter and total memory get
* expected values. * updated.
*/ */
static int memblock_add_node_simple_check(void) static int memblock_add_node_simple_check(void)
{ {
...@@ -87,9 +87,15 @@ static int memblock_add_node_simple_check(void) ...@@ -87,9 +87,15 @@ static int memblock_add_node_simple_check(void)
/* /*
* A test that tries to add two memory blocks that don't overlap with one * A test that tries to add two memory blocks that don't overlap with one
* another. It checks if two correctly initialized entries were added to the * another:
* collection of available memory regions (memblock.memory) and if this *
* change was reflected in memblock.memory's total size and region counter. * | +--------+ +--------+ |
* | | r1 | | r2 | |
* +--------+--------+--------+--------+--+
*
* Expect to add two correctly initialized entries to the collection of
* available memory regions (memblock.memory). The total size and
* region counter fields get updated.
*/ */
static int memblock_add_disjoint_check(void) static int memblock_add_disjoint_check(void)
{ {
...@@ -124,11 +130,21 @@ static int memblock_add_disjoint_check(void) ...@@ -124,11 +130,21 @@ static int memblock_add_disjoint_check(void)
} }
/* /*
* A test that tries to add two memory blocks, where the second one overlaps * A test that tries to add two memory blocks r1 and r2, where r2 overlaps
* with the beginning of the first entry (that is r1.base < r2.base + r2.size). * with the beginning of r1 (that is r1.base < r2.base + r2.size):
* After this, it checks if two entries are merged into one region that starts *
* at r2.base and has size of two regions minus their intersection. It also * | +----+----+------------+ |
* verifies the reported total size of the available memory and region counter. * | | |r2 | r1 | |
* +----+----+----+------------+----------+
* ^ ^
* | |
* | r1.base
* |
* r2.base
*
* Expect to merge the two entries into one region that starts at r2.base
* and has size of two regions minus their intersection. The total size of
* the available memory is updated, and the region counter stays the same.
*/ */
static int memblock_add_overlap_top_check(void) static int memblock_add_overlap_top_check(void)
{ {
...@@ -162,12 +178,21 @@ static int memblock_add_overlap_top_check(void) ...@@ -162,12 +178,21 @@ static int memblock_add_overlap_top_check(void)
} }
/* /*
* A test that tries to add two memory blocks, where the second one overlaps * A test that tries to add two memory blocks r1 and r2, where r2 overlaps
* with the end of the first entry (that is r2.base < r1.base + r1.size). * with the end of r1 (that is r2.base < r1.base + r1.size):
* After this, it checks if two entries are merged into one region that starts *
* at r1.base and has size of two regions minus their intersection. It verifies * | +--+------+----------+ |
* that memblock can still see only one entry and has a correct total size of * | | | r1 | r2 | |
* the available memory. * +--+--+------+----------+--------------+
* ^ ^
* | |
* | r2.base
* |
* r1.base
*
* Expect to merge the two entries into one region that starts at r1.base
* and has size of two regions minus their intersection. The total size of
* the available memory is updated, and the region counter stays the same.
*/ */
static int memblock_add_overlap_bottom_check(void) static int memblock_add_overlap_bottom_check(void)
{ {
...@@ -201,11 +226,19 @@ static int memblock_add_overlap_bottom_check(void) ...@@ -201,11 +226,19 @@ static int memblock_add_overlap_bottom_check(void)
} }
/* /*
* A test that tries to add two memory blocks, where the second one is * A test that tries to add two memory blocks r1 and r2, where r2 is
* within the range of the first entry (that is r1.base < r2.base && * within the range of r1 (that is r1.base < r2.base &&
* r2.base + r2.size < r1.base + r1.size). It checks if two entries are merged * r2.base + r2.size < r1.base + r1.size):
* into one region that stays the same. The counter and total size of available *
* memory are expected to not be updated. * | +-------+--+-----------------------+
* | | |r2| r1 |
* +---+-------+--+-----------------------+
* ^
* |
* r1.base
*
* Expect to merge two entries into one region that stays the same.
* The counter and total size of available memory are not updated.
*/ */
static int memblock_add_within_check(void) static int memblock_add_within_check(void)
{ {
...@@ -236,8 +269,8 @@ static int memblock_add_within_check(void) ...@@ -236,8 +269,8 @@ static int memblock_add_within_check(void)
} }
/* /*
* A simple test that tries to add the same memory block twice. The counter * A simple test that tries to add the same memory block twice. Expect
* and total size of available memory are expected to not be updated. * the counter and total size of available memory to not be updated.
*/ */
static int memblock_add_twice_check(void) static int memblock_add_twice_check(void)
{ {
...@@ -270,11 +303,11 @@ static int memblock_add_checks(void) ...@@ -270,11 +303,11 @@ static int memblock_add_checks(void)
return 0; return 0;
} }
/* /*
* A simple test that marks a memory block of a specified base address * A simple test that marks a memory block of a specified base address
* and size as reserved and to the collection of reserved memory regions * and size as reserved and to the collection of reserved memory regions
* (memblock.reserved). It checks if a new entry was created and if region * (memblock.reserved). Expect to create a new entry. The region counter
* counter and total memory size were correctly updated. * and total memory size are updated.
*/ */
static int memblock_reserve_simple_check(void) static int memblock_reserve_simple_check(void)
{ {
...@@ -297,10 +330,15 @@ static int memblock_reserve_simple_check(void) ...@@ -297,10 +330,15 @@ static int memblock_reserve_simple_check(void)
} }
/* /*
* A test that tries to mark two memory blocks that don't overlap as reserved * A test that tries to mark two memory blocks that don't overlap as reserved:
* and checks if two entries were correctly added to the collection of reserved *
* memory regions (memblock.reserved) and if this change was reflected in * | +--+ +----------------+ |
* memblock.reserved's total size and region counter. * | |r1| | r2 | |
* +--------+--+------+----------------+--+
*
* Expect to add two entries to the collection of reserved memory regions
* (memblock.reserved). The total size and region counter for
* memblock.reserved are updated.
*/ */
static int memblock_reserve_disjoint_check(void) static int memblock_reserve_disjoint_check(void)
{ {
...@@ -335,13 +373,22 @@ static int memblock_reserve_disjoint_check(void) ...@@ -335,13 +373,22 @@ static int memblock_reserve_disjoint_check(void)
} }
/* /*
* A test that tries to mark two memory blocks as reserved, where the * A test that tries to mark two memory blocks r1 and r2 as reserved,
* second one overlaps with the beginning of the first (that is * where r2 overlaps with the beginning of r1 (that is
* r1.base < r2.base + r2.size). * r1.base < r2.base + r2.size):
* It checks if two entries are merged into one region that starts at r2.base *
* and has size of two regions minus their intersection. The test also verifies * | +--------------+--+--------------+ |
* that memblock can still see only one entry and has a correct total size of * | | r2 | | r1 | |
* the reserved memory. * +--+--------------+--+--------------+--+
* ^ ^
* | |
* | r1.base
* |
* r2.base
*
* Expect to merge two entries into one region that starts at r2.base and
* has size of two regions minus their intersection. The total size of the
* reserved memory is updated, and the region counter is not updated.
*/ */
static int memblock_reserve_overlap_top_check(void) static int memblock_reserve_overlap_top_check(void)
{ {
...@@ -375,13 +422,22 @@ static int memblock_reserve_overlap_top_check(void) ...@@ -375,13 +422,22 @@ static int memblock_reserve_overlap_top_check(void)
} }
/* /*
* A test that tries to mark two memory blocks as reserved, where the * A test that tries to mark two memory blocks r1 and r2 as reserved,
* second one overlaps with the end of the first entry (that is * where r2 overlaps with the end of r1 (that is
* r2.base < r1.base + r1.size). * r2.base < r1.base + r1.size):
* It checks if two entries are merged into one region that starts at r1.base *
* and has size of two regions minus their intersection. It verifies that * | +--------------+--+--------------+ |
* memblock can still see only one entry and has a correct total size of the * | | r1 | | r2 | |
* reserved memory. * +--+--------------+--+--------------+--+
* ^ ^
* | |
* | r2.base
* |
* r1.base
*
* Expect to merge two entries into one region that starts at r1.base and
* has size of two regions minus their intersection. The total size of the
* reserved memory is updated, and the region counter is not updated.
*/ */
static int memblock_reserve_overlap_bottom_check(void) static int memblock_reserve_overlap_bottom_check(void)
{ {
...@@ -415,12 +471,21 @@ static int memblock_reserve_overlap_bottom_check(void) ...@@ -415,12 +471,21 @@ static int memblock_reserve_overlap_bottom_check(void)
} }
/* /*
* A test that tries to mark two memory blocks as reserved, where the second * A test that tries to mark two memory blocks r1 and r2 as reserved,
* one is within the range of the first entry (that is * where r2 is within the range of r1 (that is
* (r1.base < r2.base) && (r2.base + r2.size < r1.base + r1.size)). * (r1.base < r2.base) && (r2.base + r2.size < r1.base + r1.size)):
* It checks if two entries are merged into one region that stays the *
* same. The counter and total size of available memory are expected to not be * | +-----+--+---------------------------|
* updated. * | | |r2| r1 |
* +-+-----+--+---------------------------+
* ^ ^
* | |
* | r2.base
* |
* r1.base
*
* Expect to merge two entries into one region that stays the same. The
* counter and total size of available memory are not updated.
*/ */
static int memblock_reserve_within_check(void) static int memblock_reserve_within_check(void)
{ {
...@@ -452,7 +517,7 @@ static int memblock_reserve_within_check(void) ...@@ -452,7 +517,7 @@ static int memblock_reserve_within_check(void)
/* /*
* A simple test that tries to reserve the same memory block twice. * A simple test that tries to reserve the same memory block twice.
* The region counter and total size of reserved memory are expected to not * Expect the region counter and total size of reserved memory to not
* be updated. * be updated.
*/ */
static int memblock_reserve_twice_check(void) static int memblock_reserve_twice_check(void)
...@@ -485,13 +550,21 @@ static int memblock_reserve_checks(void) ...@@ -485,13 +550,21 @@ static int memblock_reserve_checks(void)
return 0; return 0;
} }
/* /*
* A simple test that tries to remove the first entry of the array of * A simple test that tries to remove a region r1 from the array of
* available memory regions. By "removing" a region we mean overwriting it * available memory regions. By "removing" a region we mean overwriting it
* with the next region in memblock.memory. To check this is the case, the * with the next region r2 in memblock.memory:
* test adds two memory blocks and verifies that the value of the latter *
* was used to erase r1 region. It also checks if the region counter and * | ...... +----------------+ |
* total size were updated to expected values. * | : r1 : | r2 | |
* +--+----+----------+----------------+--+
* ^
* |
* rgn.base
*
* Expect to add two memory blocks r1 and r2 and then remove r1 so that
* r2 is the first available region. The region counter and total size
* are updated.
*/ */
static int memblock_remove_simple_check(void) static int memblock_remove_simple_check(void)
{ {
...@@ -522,10 +595,21 @@ static int memblock_remove_simple_check(void) ...@@ -522,10 +595,21 @@ static int memblock_remove_simple_check(void)
return 0; return 0;
} }
/* /*
* A test that tries to remove a region that was not registered as available * A test that tries to remove a region r2 that was not registered as
* memory (i.e. has no corresponding entry in memblock.memory). It verifies * available memory (i.e. has no corresponding entry in memblock.memory):
* that array, regions counter and total size were not modified. *
* +----------------+
* | r2 |
* +----------------+
* | +----+ |
* | | r1 | |
* +--+----+------------------------------+
* ^
* |
* rgn.base
*
* Expect the array, regions counter and total size to not be modified.
*/ */
static int memblock_remove_absent_check(void) static int memblock_remove_absent_check(void)
{ {
...@@ -556,11 +640,23 @@ static int memblock_remove_absent_check(void) ...@@ -556,11 +640,23 @@ static int memblock_remove_absent_check(void)
} }
/* /*
* A test that tries to remove a region which overlaps with the beginning of * A test that tries to remove a region r2 that overlaps with the
* the already existing entry r1 (that is r1.base < r2.base + r2.size). It * beginning of the already existing entry r1
* checks if only the intersection of both regions is removed from the available * (that is r1.base < r2.base + r2.size):
* memory pool. The test also checks if the regions counter and total size are *
* updated to expected values. * +-----------------+
* | r2 |
* +-----------------+
* | .........+--------+ |
* | : r1 | rgn | |
* +-----------------+--------+--------+--+
* ^ ^
* | |
* | rgn.base
* r1.base
*
* Expect that only the intersection of both regions is removed from the
* available memory pool. The regions counter and total size are updated.
*/ */
static int memblock_remove_overlap_top_check(void) static int memblock_remove_overlap_top_check(void)
{ {
...@@ -596,11 +692,21 @@ static int memblock_remove_overlap_top_check(void) ...@@ -596,11 +692,21 @@ static int memblock_remove_overlap_top_check(void)
} }
/* /*
* A test that tries to remove a region which overlaps with the end of the * A test that tries to remove a region r2 that overlaps with the end of
* first entry (that is r2.base < r1.base + r1.size). It checks if only the * the already existing region r1 (that is r2.base < r1.base + r1.size):
* intersection of both regions is removed from the available memory pool. *
* The test also checks if the regions counter and total size are updated to * +--------------------------------+
* expected values. * | r2 |
* +--------------------------------+
* | +---+..... |
* | |rgn| r1 : |
* +-+---+----+---------------------------+
* ^
* |
* r1.base
*
* Expect that only the intersection of both regions is removed from the
* available memory pool. The regions counter and total size are updated.
*/ */
static int memblock_remove_overlap_bottom_check(void) static int memblock_remove_overlap_bottom_check(void)
{ {
...@@ -633,13 +739,23 @@ static int memblock_remove_overlap_bottom_check(void) ...@@ -633,13 +739,23 @@ static int memblock_remove_overlap_bottom_check(void)
} }
/* /*
* A test that tries to remove a region which is within the range of the * A test that tries to remove a region r2 that is within the range of
* already existing entry (that is * the already existing entry r1 (that is
* (r1.base < r2.base) && (r2.base + r2.size < r1.base + r1.size)). * (r1.base < r2.base) && (r2.base + r2.size < r1.base + r1.size)):
* It checks if the region is split into two - one that ends at r2.base and *
* second that starts at r2.base + size, with appropriate sizes. The test * +----+
* also checks if the region counter and total size were updated to * | r2 |
* expected values. * +----+
* | +-------------+....+---------------+ |
* | | rgn1 | r1 | rgn2 | |
* +-+-------------+----+---------------+-+
* ^
* |
* r1.base
*
* Expect that the region is split into two - one that ends at r2.base and
* another that starts at r2.base + r2.size, with appropriate sizes. The
* region counter and total size are updated.
*/ */
static int memblock_remove_within_check(void) static int memblock_remove_within_check(void)
{ {
...@@ -690,12 +806,19 @@ static int memblock_remove_checks(void) ...@@ -690,12 +806,19 @@ static int memblock_remove_checks(void)
} }
/* /*
* A simple test that tries to free a memory block that was marked earlier * A simple test that tries to free a memory block r1 that was marked
* as reserved. By "freeing" a region we mean overwriting it with the next * earlier as reserved. By "freeing" a region we mean overwriting it with
* entry in memblock.reserved. To check this is the case, the test reserves * the next entry r2 in memblock.reserved:
* two memory regions and verifies that the value of the latter was used to *
* erase r1 region. * | ...... +----+ |
* The test also checks if the region counter and total size were updated. * | : r1 : | r2 | |
* +--------------+----+-----------+----+-+
* ^
* |
* rgn.base
*
* Expect to reserve two memory regions and then erase r1 region with the
* value of r2. The region counter and total size are updated.
*/ */
static int memblock_free_simple_check(void) static int memblock_free_simple_check(void)
{ {
...@@ -726,10 +849,21 @@ static int memblock_free_simple_check(void) ...@@ -726,10 +849,21 @@ static int memblock_free_simple_check(void)
return 0; return 0;
} }
/* /*
* A test that tries to free a region that was not marked as reserved * A test that tries to free a region r2 that was not marked as reserved
* (i.e. has no corresponding entry in memblock.reserved). It verifies * (i.e. has no corresponding entry in memblock.reserved):
* that array, regions counter and total size were not modified. *
* +----------------+
* | r2 |
* +----------------+
* | +----+ |
* | | r1 | |
* +--+----+------------------------------+
* ^
* |
* rgn.base
*
* The array, regions counter and total size are not modified.
*/ */
static int memblock_free_absent_check(void) static int memblock_free_absent_check(void)
{ {
...@@ -760,11 +894,23 @@ static int memblock_free_absent_check(void) ...@@ -760,11 +894,23 @@ static int memblock_free_absent_check(void)
} }
/* /*
* A test that tries to free a region which overlaps with the beginning of * A test that tries to free a region r2 that overlaps with the beginning
* the already existing entry r1 (that is r1.base < r2.base + r2.size). It * of the already existing entry r1 (that is r1.base < r2.base + r2.size):
* checks if only the intersection of both regions is freed. The test also *
* checks if the regions counter and total size are updated to expected * +----+
* values. * | r2 |
* +----+
* | ...+--------------+ |
* | : | r1 | |
* +----+--+--------------+---------------+
* ^ ^
* | |
* | rgn.base
* |
* r1.base
*
* Expect that only the intersection of both regions is freed. The
* regions counter and total size are updated.
*/ */
static int memblock_free_overlap_top_check(void) static int memblock_free_overlap_top_check(void)
{ {
...@@ -798,10 +944,18 @@ static int memblock_free_overlap_top_check(void) ...@@ -798,10 +944,18 @@ static int memblock_free_overlap_top_check(void)
} }
/* /*
* A test that tries to free a region which overlaps with the end of the * A test that tries to free a region r2 that overlaps with the end of
* first entry (that is r2.base < r1.base + r1.size). It checks if only the * the already existing entry r1 (that is r2.base < r1.base + r1.size):
* intersection of both regions is freed. The test also checks if the *
* regions counter and total size are updated to expected values. * +----------------+
* | r2 |
* +----------------+
* | +-----------+..... |
* | | r1 | : |
* +----+-----------+----+----------------+
*
* Expect that only the intersection of both regions is freed. The
* regions counter and total size are updated.
*/ */
static int memblock_free_overlap_bottom_check(void) static int memblock_free_overlap_bottom_check(void)
{ {
...@@ -835,13 +989,23 @@ static int memblock_free_overlap_bottom_check(void) ...@@ -835,13 +989,23 @@ static int memblock_free_overlap_bottom_check(void)
} }
/* /*
* A test that tries to free a region which is within the range of the * A test that tries to free a region r2 that is within the range of the
* already existing entry (that is * already existing entry r1 (that is
* (r1.base < r2.base) && (r2.base + r2.size < r1.base + r1.size)). * (r1.base < r2.base) && (r2.base + r2.size < r1.base + r1.size)):
* It checks if the region is split into two - one that ends at r2.base and *
* second that starts at r2.base + size, with appropriate sizes. It is * +----+
* expected that the region counter and total size fields were updated t * | r2 |
* reflect that change. * +----+
* | +------------+....+---------------+
* | | rgn1 | r1 | rgn2 |
* +----+------------+----+---------------+
* ^
* |
* r1.base
*
* Expect that the region is split into two - one that ends at r2.base and
* another that starts at r2.base + r2.size, with appropriate sizes. The
* region counter and total size fields are updated.
*/ */
static int memblock_free_within_check(void) static int memblock_free_within_check(void)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment