Skip to content

Commit 60bba7b

Browse files
remckeerppt
authored andcommitted
memblock tests: update style of comments for memblock_remove_*() functions
Update comments in memblock_remove_*() functions to match the style used in tests/alloc_*.c by rewording to make the expected outcome more apparent and, if more than one memblock is involved, adding a visual of the memory blocks. If the comment has an extra column of spaces, remove the extra space at the beginning of each line for consistency and to conform to Linux kernel coding style. Signed-off-by: Rebecca Mckeever <remckee0@gmail.com> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
1 parent e4f76c8 commit 60bba7b

File tree

1 file changed

+81
-30
lines changed

1 file changed

+81
-30
lines changed

tools/testing/memblock/tests/basic_api.c

Lines changed: 81 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -550,14 +550,22 @@ static int memblock_reserve_checks(void)
550550
return 0;
551551
}
552552

553-
/*
554-
* A simple test that tries to remove the first entry of the array of
555-
* available memory regions. By "removing" a region we mean overwriting it
556-
* with the next region in memblock.memory. To check this is the case, the
557-
* test adds two memory blocks and verifies that the value of the latter
558-
* was used to erase r1 region. It also checks if the region counter and
559-
* total size were updated to expected values.
560-
*/
553+
/*
554+
* A simple test that tries to remove a region r1 from the array of
555+
* available memory regions. By "removing" a region we mean overwriting it
556+
* with the next region r2 in memblock.memory:
557+
*
558+
* | ...... +----------------+ |
559+
* | : r1 : | r2 | |
560+
* +--+----+----------+----------------+--+
561+
* ^
562+
* |
563+
* rgn.base
564+
*
565+
* Expect to add two memory blocks r1 and r2 and then remove r1 so that
566+
* r2 is the first available region. The region counter and total size
567+
* are updated.
568+
*/
561569
static int memblock_remove_simple_check(void)
562570
{
563571
struct memblock_region *rgn;
@@ -587,11 +595,22 @@ static int memblock_remove_simple_check(void)
587595
return 0;
588596
}
589597

590-
/*
591-
* A test that tries to remove a region that was not registered as available
592-
* memory (i.e. has no corresponding entry in memblock.memory). It verifies
593-
* that array, regions counter and total size were not modified.
594-
*/
598+
/*
599+
* A test that tries to remove a region r2 that was not registered as
600+
* available memory (i.e. has no corresponding entry in memblock.memory):
601+
*
602+
* +----------------+
603+
* | r2 |
604+
* +----------------+
605+
* | +----+ |
606+
* | | r1 | |
607+
* +--+----+------------------------------+
608+
* ^
609+
* |
610+
* rgn.base
611+
*
612+
* Expect the array, regions counter and total size to not be modified.
613+
*/
595614
static int memblock_remove_absent_check(void)
596615
{
597616
struct memblock_region *rgn;
@@ -621,11 +640,23 @@ static int memblock_remove_absent_check(void)
621640
}
622641

623642
/*
624-
* A test that tries to remove a region which overlaps with the beginning of
625-
* the already existing entry r1 (that is r1.base < r2.base + r2.size). It
626-
* checks if only the intersection of both regions is removed from the available
627-
* memory pool. The test also checks if the regions counter and total size are
628-
* updated to expected values.
643+
* A test that tries to remove a region r2 that overlaps with the
644+
* beginning of the already existing entry r1
645+
* (that is r1.base < r2.base + r2.size):
646+
*
647+
* +-----------------+
648+
* | r2 |
649+
* +-----------------+
650+
* | .........+--------+ |
651+
* | : r1 | rgn | |
652+
* +-----------------+--------+--------+--+
653+
* ^ ^
654+
* | |
655+
* | rgn.base
656+
* r1.base
657+
*
658+
* Expect that only the intersection of both regions is removed from the
659+
* available memory pool. The regions counter and total size are updated.
629660
*/
630661
static int memblock_remove_overlap_top_check(void)
631662
{
@@ -661,11 +692,21 @@ static int memblock_remove_overlap_top_check(void)
661692
}
662693

663694
/*
664-
* A test that tries to remove a region which overlaps with the end of the
665-
* first entry (that is r2.base < r1.base + r1.size). It checks if only the
666-
* intersection of both regions is removed from the available memory pool.
667-
* The test also checks if the regions counter and total size are updated to
668-
* expected values.
695+
* A test that tries to remove a region r2 that overlaps with the end of
696+
* the already existing region r1 (that is r2.base < r1.base + r1.size):
697+
*
698+
* +--------------------------------+
699+
* | r2 |
700+
* +--------------------------------+
701+
* | +---+..... |
702+
* | |rgn| r1 : |
703+
* +-+---+----+---------------------------+
704+
* ^
705+
* |
706+
* r1.base
707+
*
708+
* Expect that only the intersection of both regions is removed from the
709+
* available memory pool. The regions counter and total size are updated.
669710
*/
670711
static int memblock_remove_overlap_bottom_check(void)
671712
{
@@ -698,13 +739,23 @@ static int memblock_remove_overlap_bottom_check(void)
698739
}
699740

700741
/*
701-
* A test that tries to remove a region which is within the range of the
702-
* already existing entry (that is
703-
* (r1.base < r2.base) && (r2.base + r2.size < r1.base + r1.size)).
704-
* It checks if the region is split into two - one that ends at r2.base and
705-
* second that starts at r2.base + size, with appropriate sizes. The test
706-
* also checks if the region counter and total size were updated to
707-
* expected values.
742+
* A test that tries to remove a region r2 that is within the range of
743+
* the already existing entry r1 (that is
744+
* (r1.base < r2.base) && (r2.base + r2.size < r1.base + r1.size)):
745+
*
746+
* +----+
747+
* | r2 |
748+
* +----+
749+
* | +-------------+....+---------------+ |
750+
* | | rgn1 | r1 | rgn2 | |
751+
* +-+-------------+----+---------------+-+
752+
* ^
753+
* |
754+
* r1.base
755+
*
756+
* Expect that the region is split into two - one that ends at r2.base and
757+
* another that starts at r2.base + r2.size, with appropriate sizes. The
758+
* region counter and total size are updated.
708759
*/
709760
static int memblock_remove_within_check(void)
710761
{

0 commit comments

Comments
 (0)