Skip to contentSkip to conversation

memblock tests: update style of comments

PATCH Superseded Rebecca Mckeever 3 participants 9 messages Apr 20, 2022 – Apr 21, 2022

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover memblock tests: update style of comments

These patches update the style of comments for memblock_add_*() and memblock_reserve_*() functions to match the style of comments in tests/alloc_*.c and remove extra spaces in those comments to conform to Linux kernel coding style.

Rebecca Mckeever (3):
memblock tests: update style of comments for memblock_add_*()
functions
memblock tests: update style of comments for memblock_reserve_*()
functions
memblock tests: remove extra column of spaces in block comment

 tools/testing/memblock/tests/basic_api.c | 153 ++++++++++++++++-------
 1 file changed, 109 insertions(+), 44 deletions(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/3 memblock tests: update style of comments for memblock_add_*() functions

Update comments in memblock_add_*() 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.

---
 tools/testing/memblock/tests/basic_api.c | 75 +++++++++++++++++-------
 1 file changed, 54 insertions(+), 21 deletions(-)
tools/testing/memblock/tests/basic_api.c +54 -21
index fbc1ce160303..cdf112d25343 100644
@@ -26,8 +26,8 @@ static int memblock_initialization_check(void)
 /*
  * A simple test that adds a memory block of a specified base address
  * 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
- * were correctly updated.
+ * Expect to create a new entry. The region counter and total memory get
+ * updated.
  */
 static int memblock_add_simple_check(void)
 {
@@ -55,8 +55,8 @@ static int memblock_add_simple_check(void)
 /*
  * 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.
- * It checks if the new entry, region counter and total memory size have
- * expected values.
+ * Expect to create a new entry. The region counter and total memory get
+ * updated.
  */
 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
- * another. It checks if two correctly initialized entries were added to the
- * collection of available memory regions (memblock.memory) and if this
- * change was reflected in memblock.memory's total size and region counter.
+ * another:
+ *
+ *  |        +--------+        +--------+  |
+ *  |        |   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)
 {
@@ -125,10 +131,20 @@ static int memblock_add_disjoint_check(void)
 
 /*
  * A test that tries to add two memory blocks, where the second one overlaps
- * with the beginning of the first entry (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.
+ * with the beginning of the first entry (that is r1.base < r2.base + r2.size):
+ *
+ *  |    +----+----+------------+          |
+ *  |    |   r|2   |   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)
 {
@@ -163,11 +179,20 @@ static int memblock_add_overlap_top_check(void)
 
 /*
  * A test that tries to add two memory blocks, where the second one overlaps
- * with the end of the first entry (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
- * the available memory.
+ * with the end of the first entry (that is r2.base < r1.base + r1.size):
+ *
+ *  |  +--+------+----------+              |
+ *  |  |  | r1   | r2       |              |
+ *  +--+--+------+----------+--------------+
+ *     ^  ^
+ *     |  |
+ *     |  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)
 {
@@ -203,9 +228,17 @@ static int memblock_add_overlap_bottom_check(void)
 /*
  * A test that tries to add two memory blocks, where the second one is
  * within the range of the first entry (that is 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.base + r2.size < r1.base + r1.size).
+ *
+ *  |   +-------+--+-----------------------+
+ *  |   |       |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)
 {
@@ -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
- * and total size of available memory are expected to not be updated.
+ * A simple test that tries to add the same memory block twice. Expect
+ * the counter and total size of available memory to not be updated.
  */
 static int memblock_add_twice_check(void)
 {
Signature · 1 line
2.32.0
#4 lore raw

PATCH 2/3 memblock tests: update style of comments for memblock_reserve_*() functions

In reply to Rebecca Mckeever

Update comments in memblock_reserve_*() 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.

---
 tools/testing/memblock/tests/basic_api.c | 70 +++++++++++++++++-------
 1 file changed, 51 insertions(+), 19 deletions(-)
tools/testing/memblock/tests/basic_api.c +51 -19
index cdf112d25343..834d8705ff8a 100644
@@ -306,8 +306,8 @@ static int memblock_add_checks(void)
  /*
   * 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
-  * (memblock.reserved). It checks if a new entry was created and if region
-  * counter and total memory size were correctly updated.
+  * (memblock.reserved). Expect to create a new entry. The region counter
+  * and total memory size are updated.
   */
 static int memblock_reserve_simple_check(void)
 {
@@ -330,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
- * 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.
+ * A test that tries to mark two memory blocks that don't overlap as reserved:
+ *
+ *  |        +--+      +----------------+  |
+ *  |        |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)
 {
@@ -370,11 +375,20 @@ static int memblock_reserve_disjoint_check(void)
 /*
  * A test that tries to mark two memory blocks as reserved, where the
  * second one overlaps with the beginning of the first (that is
- * 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
- * the reserved memory.
+ * r1.base < r2.base + r2.size):
+ *
+ *  |  +--------------+--+--------------+  |
+ *  |  |       r2     |  |     r1       |  |
+ *  +--+--------------+--+--------------+--+
+ *     ^              ^
+ *     |              |
+ *     |              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)
 {
@@ -411,10 +425,19 @@ static int memblock_reserve_overlap_top_check(void)
  * A test that tries to mark two memory blocks as reserved, where the
  * second one overlaps with the end of the first entry (that is
  * 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
- * reserved memory.
+ *
+ *  |  +--------------+--+--------------+  |
+ *  |  |       r1     |  |     r2       |  |
+ *  +--+--------------+--+--------------+--+
+ *     ^              ^
+ *     |              |
+ *     |              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)
 {
@@ -451,9 +474,18 @@ static int memblock_reserve_overlap_bottom_check(void)
  * A test that tries to mark two memory blocks as reserved, where the second
  * one is within the range of the first entry (that is
  * (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)
 {
@@ -485,7 +517,7 @@ static int memblock_reserve_within_check(void)
 
 /*
  * 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.
  */
 static int memblock_reserve_twice_check(void)
Signature · 1 line
2.32.0
#6 lore raw

PATCH 3/3 memblock tests: remove extra column of spaces in block comment

In reply to Rebecca Mckeever

Remove extra space at the beginning of each line in block comment for consistency and to conform to Linux kernel coding style.

---
 tools/testing/memblock/tests/basic_api.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/memblock/tests/basic_api.c +6 -6
index 834d8705ff8a..05448a25f1f9 100644
@@ -303,12 +303,12 @@ static int memblock_add_checks(void)
 	return 0;
 }
 
- /*
-  * 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
-  * (memblock.reserved). Expect to create a new entry. The region counter
-  * and total memory size are updated.
-  */
+/*
+ * 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
+ * (memblock.reserved). Expect to create a new entry. The region counter
+ * and total memory size are updated.
+ */
 static int memblock_reserve_simple_check(void)
 {
 	struct memblock_region *rgn;
Signature · 1 line
2.32.0
#7 lore raw

Re: [PATCH 3/3] memblock tests: remove extra column of spaces in block comment

Quoted 21 lines · Rebecca Mckeever

Remove extra space at the beginning of each line in block comment for consistency and to conform to Linux kernel coding style.

---
 tools/testing/memblock/tests/basic_api.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/memblock/tests/basic_api.c +0 -5
index 834d8705ff8a..05448a25f1f9 100644
@@ -303,12 +303,12 @@ static int memblock_add_checks(void)
 	return 0;
 }
 
- /*
-  * 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
-  * (memblock.reserved). Expect to create a new entry. The region counter
-  * and total memory size are updated.

tools/testing/memblock/tests/basic_api.c static int memblock_add_checks(void) · line 314

Quoted 10 lines
tools/testing/memblock/tests/basic_api.c +6 -1
-  */
+/*
+ * 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
+ * (memblock.reserved). Expect to create a new entry. The region counter
+ * and total memory size are updated.
+ */
 static int memblock_reserve_simple_check(void)
 {
 	struct memblock_region *rgn;

I'd pull this patch to the front, so you don't end up modifying a wrong style in patch #2. You could also just squash this patch into patch #2 and mention it in the patch description.

Signature · 3 lines
Thanks,

David / dhildenb
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] memblock tests: update style of comments for memblock_add_*() functions

In reply to Rebecca Mckeever
Quoted 128 lines · Rebecca Mckeever

Update comments in memblock_add_*() 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.

---
 tools/testing/memblock/tests/basic_api.c | 75 +++++++++++++++++-------
 1 file changed, 54 insertions(+), 21 deletions(-)
tools/testing/memblock/tests/basic_api.c +52 -19
index fbc1ce160303..cdf112d25343 100644
@@ -26,8 +26,8 @@ static int memblock_initialization_check(void)
 /*
  * A simple test that adds a memory block of a specified base address
  * 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
- * were correctly updated.
+ * Expect to create a new entry. The region counter and total memory get
+ * updated.
  */
 static int memblock_add_simple_check(void)
 {
@@ -55,8 +55,8 @@ static int memblock_add_simple_check(void)
 /*
  * 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.
- * It checks if the new entry, region counter and total memory size have
- * expected values.
+ * Expect to create a new entry. The region counter and total memory get
+ * updated.
  */
 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
- * another. It checks if two correctly initialized entries were added to the
- * collection of available memory regions (memblock.memory) and if this
- * change was reflected in memblock.memory's total size and region counter.
+ * another:
+ *
+ *  |        +--------+        +--------+  |
+ *  |        |   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)
 {
@@ -125,10 +131,20 @@ static int memblock_add_disjoint_check(void)
 
 /*
  * A test that tries to add two memory blocks, where the second one overlaps
- * with the beginning of the first entry (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.
+ * with the beginning of the first entry (that is r1.base < r2.base + r2.size):
+ *
+ *  |    +----+----+------------+          |
+ *  |    |   r|2   |   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)
 {
@@ -163,11 +179,20 @@ static int memblock_add_overlap_top_check(void)
 
 /*
  * A test that tries to add two memory blocks, where the second one overlaps
- * with the end of the first entry (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
- * the available memory.
+ * with the end of the first entry (that is r2.base < r1.base + r1.size):
+ *
+ *  |  +--+------+----------+              |
+ *  |  |  | r1   | r2       |              |
+ *  +--+--+------+----------+--------------+
+ *     ^  ^
+ *     |  |
+ *     |  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)
 {
@@ -203,9 +228,17 @@ static int memblock_add_overlap_bottom_check(void)
 /*
  * A test that tries to add two memory blocks, where the second one is
  * within the range of the first entry (that is 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.base + r2.size < r1.base + r1.size).
+ *
+ *  |   +-------+--+-----------------------+
+ *  |   |       |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)
 {

tools/testing/memblock/tests/basic_api.c static int memblock_add_within_check(void) · line 276

Quoted 10 lines
tools/testing/memblock/tests/basic_api.c +2 -2
@@ -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
- * and total size of available memory are expected to not be updated.
+ * A simple test that tries to add the same memory block twice. Expect
+ * the counter and total size of available memory to not be updated.
  */
 static int memblock_add_twice_check(void)
 {
Signature · 3 lines
Thanks,

David / dhildenb
Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] memblock tests: update style of comments for memblock_reserve_*() functions

In reply to Rebecca Mckeever
Quoted 15 lines · Rebecca Mckeever

Update comments in memblock_reserve_*() 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.

---
 tools/testing/memblock/tests/basic_api.c | 70 +++++++++++++++++-------
 1 file changed, 51 insertions(+), 19 deletions(-)
tools/testing/memblock/tests/basic_api.c +0 -0
index cdf112d25343..834d8705ff8a 100644

tools/testing/memblock/tests/basic_api.c static int memblock_add_checks(void) · line 311

Quoted 8 lines
tools/testing/memblock/tests/basic_api.c +2 -2
@@ -306,8 +306,8 @@ static int memblock_add_checks(void)
  /*
   * 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
-  * (memblock.reserved). It checks if a new entry was created and if region
-  * counter and total memory size were correctly updated.
+  * (memblock.reserved). Expect to create a new entry. The region counter
+  * and total memory size are updated.
   */

As mentioned in reply to patch #3, we try avoiding introducing "more wrong style" and cleanup afterwards. Cleanup first or along the way.

Quoted 95 lines
tools/testing/memblock/tests/basic_api.c +48 -16
 static int memblock_reserve_simple_check(void)
 {
@@ -330,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
- * 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.
+ * A test that tries to mark two memory blocks that don't overlap as reserved:
+ *
+ *  |        +--+      +----------------+  |
+ *  |        |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)
 {
@@ -370,11 +375,20 @@ static int memblock_reserve_disjoint_check(void)
 /*
  * A test that tries to mark two memory blocks as reserved, where the
  * second one overlaps with the beginning of the first (that is
- * 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
- * the reserved memory.
+ * r1.base < r2.base + r2.size):
+ *
+ *  |  +--------------+--+--------------+  |
+ *  |  |       r2     |  |     r1       |  |
+ *  +--+--------------+--+--------------+--+
+ *     ^              ^
+ *     |              |
+ *     |              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)
 {
@@ -411,10 +425,19 @@ static int memblock_reserve_overlap_top_check(void)
  * A test that tries to mark two memory blocks as reserved, where the
  * second one overlaps with the end of the first entry (that is
  * 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
- * reserved memory.
+ *
+ *  |  +--------------+--+--------------+  |
+ *  |  |       r1     |  |     r2       |  |
+ *  +--+--------------+--+--------------+--+
+ *     ^              ^
+ *     |              |
+ *     |              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)
 {
@@ -451,9 +474,18 @@ static int memblock_reserve_overlap_bottom_check(void)
  * A test that tries to mark two memory blocks as reserved, where the second
  * one is within the range of the first entry (that is
  * (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)
 {

tools/testing/memblock/tests/basic_api.c static int memblock_reserve_within_check(void) · line 523

Quoted 8 lines
tools/testing/memblock/tests/basic_api.c +1 -1
@@ -485,7 +517,7 @@ static int memblock_reserve_within_check(void)
 
 /*
  * 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.
  */
 static int memblock_reserve_twice_check(void)

Apart from that

Signature · 3 lines
Thanks,

David / dhildenb
maintainer
#3 lore raw

Re: [PATCH 1/3] memblock tests: update style of comments for memblock_add_*() functions

In reply to David Hildenbrand
Quoted 21 lines · David Hildenbrand
Quoted 20 lines · Rebecca Mckeever

Update comments in memblock_add_*() 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.

---
 tools/testing/memblock/tests/basic_api.c | 75 +++++++++++++++++-------
 1 file changed, 54 insertions(+), 21 deletions(-)
tools/testing/memblock/tests/basic_api.c +0 -2
index fbc1ce160303..cdf112d25343 100644
@@ -26,8 +26,8 @@ static int memblock_initialization_check(void)
 /*
  * A simple test that adds a memory block of a specified base address
  * 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
- * were correctly updated.
Quoted 8 lines

tools/testing/memblock/tests/basic_api.c static int memblock_add_simple_check(void) · line 56

Quoted 8 lines
tools/testing/memblock/tests/basic_api.c +2 -0
+ * Expect to create a new entry. The region counter and total memory get
+ * updated.
  */
 static int memblock_add_simple_check(void)
 {
@@ -55,8 +55,8 @@ static int memblock_add_simple_check(void)
 /*
  * A simple test that adds a memory block of a specified base address, size

Can you please add coma after size ... ^

Quoted 8 lines
Quoted 8 lines
tools/testing/memblock/tests/basic_api.c +2 -2
  * 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
- * expected values.
+ * Expect to create a new entry. The region counter and total memory get
+ * updated.
  */
 static int memblock_add_node_simple_check(void)
 {

...

Quoted 13 lines

tools/testing/memblock/tests/basic_api.c static int memblock_add_disjoint_check(void) · line 138

Quoted 13 lines
tools/testing/memblock/tests/basic_api.c +5 -4
@@ -125,10 +131,20 @@ static int memblock_add_disjoint_check(void)
 
 /*
  * A test that tries to add two memory blocks, where the second one overlaps
- * with the beginning of the first entry (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.
+ * with the beginning of the first entry (that is r1.base < r2.base + r2.size):
+ *
+ *  |    +----+----+------------+          |
+ *  |    |   r|2   |   r1       |          |
+ *  +----+----+----+------------+----------+

I'd move | separator outside the block name, e.g

	*  |    +----+----+------------+          |
	*  |    |   | r2  |   r1       |          |
	*  +----+----+----+------------+----------+

but no strong feelings about this :)

Quoted 11 lines
Quoted 11 lines
tools/testing/memblock/tests/basic_api.c +9 -0
+ *       ^    ^
+ *       |    |
+ *       |    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)

...

Quoted 8 lines
Signature · 3 lines
Thanks,

David / dhildenb
Signature · 2 lines
Sincerely yours,
Mike.
maintainer
#8 lore raw

Re: [PATCH 3/3] memblock tests: remove extra column of spaces in block comment

In reply to David Hildenbrand
Quoted 28 lines · David Hildenbrand
Quoted 27 lines · Rebecca Mckeever

Remove extra space at the beginning of each line in block comment for consistency and to conform to Linux kernel coding style.

---
 tools/testing/memblock/tests/basic_api.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/memblock/tests/basic_api.c +5 -6
index 834d8705ff8a..05448a25f1f9 100644
@@ -303,12 +303,12 @@ static int memblock_add_checks(void)
 	return 0;
 }
 
- /*
-  * 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
-  * (memblock.reserved). Expect to create a new entry. The region counter
-  * and total memory size are updated.
-  */
+/*
+ * 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
+ * (memblock.reserved). Expect to create a new entry. The region counter
+ * and total memory size are updated.
Quoted 8 lines

tools/testing/memblock/tests/basic_api.c static int memblock_add_checks(void) · line 314

Quoted 4 lines
tools/testing/memblock/tests/basic_api.c +1 -0
+ */
 static int memblock_reserve_simple_check(void)
 {
 	struct memblock_region *rgn;

I'd pull this patch to the front, so you don't end up modifying a wrong style in patch #2. You could also just squash this patch into patch #2 and mention it in the patch description.

Let's squash this into patch 2.

Quoted 5 lines
Signature · 3 lines
Thanks,

David / dhildenb
Signature · 2 lines
Sincerely yours,
Mike.