* [PATCH v3 3/8] memblock tests: add labels to verbose output for generic alloc tests
2022-08-27 5:42 [PATCH v3 0/8] memblock tests: update and extend memblock simulator Rebecca Mckeever
@ 2022-08-27 5:42 ` Rebecca Mckeever
2022-08-28 2:45 ` [PATCH v3 0/8] memblock tests: update and extend memblock simulator Huang, Shaoqin
2022-08-30 10:13 ` Mike Rapoport
2 siblings, 0 replies; 4+ messages in thread
From: Rebecca Mckeever @ 2022-08-27 5:42 UTC (permalink / raw)
To: Mike Rapoport, linux-mm, linux-kernel; +Cc: David Hildenbrand, Rebecca Mckeever
Generic tests for memblock_alloc*() functions do not use separate
functions for testing top-down and bottom-up allocation directions.
Therefore, the function name that is displayed in the verbose testing
output does not include the allocation direction.
Add an additional prefix when running generic tests for
memblock_alloc*() functions that indicates which allocation direction is
set. The prefix will be displayed when the tests are run in verbose mode.
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Rebecca Mckeever <remckee0@gmail.com>
---
tools/testing/memblock/tests/alloc_api.c | 36 +++++++------------
.../memblock/tests/alloc_helpers_api.c | 12 +++----
tools/testing/memblock/tests/alloc_nid_api.c | 36 +++++++------------
tools/testing/memblock/tests/common.h | 16 +++++++++
4 files changed, 44 insertions(+), 56 deletions(-)
diff --git a/tools/testing/memblock/tests/alloc_api.c b/tools/testing/memblock/tests/alloc_api.c
index c97da91a98d6..de3405634f8a 100644
--- a/tools/testing/memblock/tests/alloc_api.c
+++ b/tools/testing/memblock/tests/alloc_api.c
@@ -751,10 +751,8 @@ static int alloc_after_check(void)
static int alloc_in_between_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_in_between_generic_check();
- memblock_set_bottom_up(true);
- alloc_in_between_generic_check();
+ run_top_down(alloc_in_between_generic_check);
+ run_bottom_up(alloc_in_between_generic_check);
return 0;
}
@@ -773,10 +771,8 @@ static int alloc_second_fit_check(void)
static int alloc_small_gaps_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_small_gaps_generic_check();
- memblock_set_bottom_up(true);
- alloc_small_gaps_generic_check();
+ run_top_down(alloc_small_gaps_generic_check);
+ run_bottom_up(alloc_small_gaps_generic_check);
return 0;
}
@@ -784,10 +780,8 @@ static int alloc_small_gaps_check(void)
static int alloc_all_reserved_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_all_reserved_generic_check();
- memblock_set_bottom_up(true);
- alloc_all_reserved_generic_check();
+ run_top_down(alloc_all_reserved_generic_check);
+ run_bottom_up(alloc_all_reserved_generic_check);
return 0;
}
@@ -795,10 +789,8 @@ static int alloc_all_reserved_check(void)
static int alloc_no_space_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_no_space_generic_check();
- memblock_set_bottom_up(true);
- alloc_no_space_generic_check();
+ run_top_down(alloc_no_space_generic_check);
+ run_bottom_up(alloc_no_space_generic_check);
return 0;
}
@@ -806,10 +798,8 @@ static int alloc_no_space_check(void)
static int alloc_limited_space_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_limited_space_generic_check();
- memblock_set_bottom_up(true);
- alloc_limited_space_generic_check();
+ run_top_down(alloc_limited_space_generic_check);
+ run_bottom_up(alloc_limited_space_generic_check);
return 0;
}
@@ -817,10 +807,8 @@ static int alloc_limited_space_check(void)
static int alloc_no_memory_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_no_memory_generic_check();
- memblock_set_bottom_up(true);
- alloc_no_memory_generic_check();
+ run_top_down(alloc_no_memory_generic_check);
+ run_bottom_up(alloc_no_memory_generic_check);
return 0;
}
diff --git a/tools/testing/memblock/tests/alloc_helpers_api.c b/tools/testing/memblock/tests/alloc_helpers_api.c
index f1c7d6f170b6..06577bd0e349 100644
--- a/tools/testing/memblock/tests/alloc_helpers_api.c
+++ b/tools/testing/memblock/tests/alloc_helpers_api.c
@@ -357,10 +357,8 @@ static int alloc_from_bottom_up_min_addr_cap_check(void)
static int alloc_from_simple_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_from_simple_generic_check();
- memblock_set_bottom_up(true);
- alloc_from_simple_generic_check();
+ run_top_down(alloc_from_simple_generic_check);
+ run_bottom_up(alloc_from_simple_generic_check);
return 0;
}
@@ -368,10 +366,8 @@ static int alloc_from_simple_check(void)
static int alloc_from_misaligned_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_from_misaligned_generic_check();
- memblock_set_bottom_up(true);
- alloc_from_misaligned_generic_check();
+ run_top_down(alloc_from_misaligned_generic_check);
+ run_bottom_up(alloc_from_misaligned_generic_check);
return 0;
}
diff --git a/tools/testing/memblock/tests/alloc_nid_api.c b/tools/testing/memblock/tests/alloc_nid_api.c
index a069534c459e..9324d706ee3a 100644
--- a/tools/testing/memblock/tests/alloc_nid_api.c
+++ b/tools/testing/memblock/tests/alloc_nid_api.c
@@ -1142,10 +1142,8 @@ static int alloc_try_nid_cap_min_check(void)
static int alloc_try_nid_min_reserved_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_try_nid_min_reserved_generic_check();
- memblock_set_bottom_up(true);
- alloc_try_nid_min_reserved_generic_check();
+ run_top_down(alloc_try_nid_min_reserved_generic_check);
+ run_bottom_up(alloc_try_nid_min_reserved_generic_check);
return 0;
}
@@ -1153,10 +1151,8 @@ static int alloc_try_nid_min_reserved_check(void)
static int alloc_try_nid_max_reserved_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_try_nid_max_reserved_generic_check();
- memblock_set_bottom_up(true);
- alloc_try_nid_max_reserved_generic_check();
+ run_top_down(alloc_try_nid_max_reserved_generic_check);
+ run_bottom_up(alloc_try_nid_max_reserved_generic_check);
return 0;
}
@@ -1164,10 +1160,8 @@ static int alloc_try_nid_max_reserved_check(void)
static int alloc_try_nid_exact_address_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_try_nid_exact_address_generic_check();
- memblock_set_bottom_up(true);
- alloc_try_nid_exact_address_generic_check();
+ run_top_down(alloc_try_nid_exact_address_generic_check);
+ run_bottom_up(alloc_try_nid_exact_address_generic_check);
return 0;
}
@@ -1175,10 +1169,8 @@ static int alloc_try_nid_exact_address_check(void)
static int alloc_try_nid_reserved_full_merge_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_try_nid_reserved_full_merge_generic_check();
- memblock_set_bottom_up(true);
- alloc_try_nid_reserved_full_merge_generic_check();
+ run_top_down(alloc_try_nid_reserved_full_merge_generic_check);
+ run_bottom_up(alloc_try_nid_reserved_full_merge_generic_check);
return 0;
}
@@ -1186,10 +1178,8 @@ static int alloc_try_nid_reserved_full_merge_check(void)
static int alloc_try_nid_reserved_all_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_try_nid_reserved_all_generic_check();
- memblock_set_bottom_up(true);
- alloc_try_nid_reserved_all_generic_check();
+ run_top_down(alloc_try_nid_reserved_all_generic_check);
+ run_bottom_up(alloc_try_nid_reserved_all_generic_check);
return 0;
}
@@ -1197,10 +1187,8 @@ static int alloc_try_nid_reserved_all_check(void)
static int alloc_try_nid_low_max_check(void)
{
test_print("\tRunning %s...\n", __func__);
- memblock_set_bottom_up(false);
- alloc_try_nid_low_max_generic_check();
- memblock_set_bottom_up(true);
- alloc_try_nid_low_max_generic_check();
+ run_top_down(alloc_try_nid_low_max_generic_check);
+ run_bottom_up(alloc_try_nid_low_max_generic_check);
return 0;
}
diff --git a/tools/testing/memblock/tests/common.h b/tools/testing/memblock/tests/common.h
index 93e559780890..c53f9c365714 100644
--- a/tools/testing/memblock/tests/common.h
+++ b/tools/testing/memblock/tests/common.h
@@ -100,4 +100,20 @@ static inline void test_pass_pop(void)
prefix_pop();
}
+static inline void run_top_down(int (*func)())
+{
+ memblock_set_bottom_up(false);
+ prefix_push("top-down");
+ func();
+ prefix_pop();
+}
+
+static inline void run_bottom_up(int (*func)())
+{
+ memblock_set_bottom_up(true);
+ prefix_push("bottom-up");
+ func();
+ prefix_pop();
+}
+
#endif
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v3 0/8] memblock tests: update and extend memblock simulator
2022-08-27 5:42 [PATCH v3 0/8] memblock tests: update and extend memblock simulator Rebecca Mckeever
2022-08-27 5:42 ` [PATCH v3 3/8] memblock tests: add labels to verbose output for generic alloc tests Rebecca Mckeever
@ 2022-08-28 2:45 ` Huang, Shaoqin
2022-08-30 10:13 ` Mike Rapoport
2 siblings, 0 replies; 4+ messages in thread
From: Huang, Shaoqin @ 2022-08-28 2:45 UTC (permalink / raw)
To: Rebecca Mckeever, Mike Rapoport, linux-mm, linux-kernel; +Cc: David Hildenbrand
All patches looks good to me.
Reviewed-by: Shaoqin Huang <shaoqin.huang@intel.com>
Thanks your effort for doing this.
On 8/27/2022 1:42 PM, Rebecca Mckeever wrote:
> These patches update existing tests in memblock simulator, add
> additional tests for memblock functions that are already being tested,
> and add test coverage for additional memblock functions.
>
> Updated tests for:
> - memblock_alloc()
> - memblock_alloc_try_nid()
> - memblock_alloc_from()
>
> The updates to memblock_alloc() tests include the addition of an assert
> that checks whether the entire chunk of allocated memory is cleared. For
> memblock_alloc_try_nid() and memblock_alloc_from(), the assert that checks
> whether the allocated memory is cleared now checks the entire chunk of
> allocated memory instead of just the first byte. To make this more robust,
> setup_memblock() and dummy_physical_memory_init() fill the entire MEM_SIZE
> simulated physical memory with nonzero values by calling fill_memblock().
> setup_memblock() is called at the beginning of most tests for
> memblock_alloc() functions.
>
> Additional tests for:
> - memblock_add()
> - memblock_reserve()
> - memblock_remove()
> - memblock_free()
> - memblock_alloc()
>
> Introducing test coverage for:
> - memblock_alloc_raw()
> - memblock_alloc_try_nid_raw()
> - memblock_set_bottom_up()
> - memblock_bottom_up()
> - memblock_trim_memory()
>
> The tests for the memblock_alloc_*raw() functions test both top-down and
> bottom-up allocation directions. To add coverage for memblock_alloc_raw(),
> the alloc_api was updated so that it runs through all the existing tests
> twice: once for memblock_alloc() and once for memblock_alloc_raw(). When
> the tests run memblock_alloc_raw(), they test that the entire memory
> region is nonzero instead of testing that it is zero.
>
> Similarly, the alloc_nid_api was updated to run through its tests twice:
> once for memblock_alloc_try_nid() and once for
> memblock_alloc_try_nid_raw(). When the tests run
> memblock_alloc_try_nid_raw(), they test that the entire memory region is
> nonzero instead of testing that it is zero.
>
> The patch set also adds labels to verbose output for generic
> memblock_alloc*() tests that indicate which allocation direction is set.
> The function names of those tests do not include this information.
>
> ---
> Changelog
>
> v2 -> v3
> Based on feedback from Mike Rapoport:
> PATCH 1:
> - tests/common.h:
> + Move (char *) cast inside ASSERT_MEM_EQ().
> PATCH 5:
> - tests/common.h:
> + Move (char *) cast inside ASSERT_MEM_NE().
>
> Based on feedback from David Hildenbrand:
> PATCH 5:
> - tests/common.h:
> + Add comments in enum test_flags and rename its values.
> + Rename verify_mem_content() to assert_mem_content().
> PATCH 5, PATCH 6:
> - Update commit message to explain that the memory region is initialized
> to nonzero and should remain unchanged when running
> memblock_alloc_*raw().
> - tests/alloc_api.c, tests/alloc_nid_api.c:
> + Remove func_testing array.
> + get_func_testing():
> * Rename to get_memblock_alloc_*name().
> * Remove else.
> + Remove else in run_memblock_alloc*().
> PATCH 7:
> - Commit message:
> + Change "region unalign" to "unaligned region".
> + Change "region unaligned" to "unaligned region that is unaligned"
> - tests/basic_api.c:
> + Change phys_addr_t alignment to const phys_addr_t alignment.
>
> Based on feedback from Shaoqin Huang:
> PATCH 8:
> - tests/basic_api.c:
> + Change "trimmed at the base" to "trimmed at the end" in
> memblock_trim_memory_unaligned_end_check().
>
> v1 -> v2
> Updates based on feedback from Shaoqin Huang:
> PATCH 1:
> - tests/alloc_api.c:
> + Remove fill_memblock() from alloc_no_memory_generic_check().
> - tests/common.c, tests/common.h:
> + Change fill_memblock() to file static.
> PATCH 3:
> - Shaoqin Huang and I discussed using run_top_down() and run_bottom_up()
> even for functions with `top_down` and `bottom_up` in the name to
> maintain a consistent output style. However, this would make the output
> more redundant, so no changes were made.
> PATCH 4:
> - tests/basic_api.c:
> + Rename instances of r1_size and r2_size to
> new_r1_size and new_r2_size.
> PATCH 5, PATCH 6:
> - tests/alloc_api.c, tests/alloc_nid_api.c, tests/common.h:
> + Change verify_mem_content() to a common function defined in
> common.h.
> PATCH 8:
> - tests/basic_api.c:
> + Rename instances of r2_base and r2_size to
> new_r2_base and new_r2_size.
> ---
>
> Rebecca Mckeever (8):
> memblock tests: update tests to check if memblock_alloc zeroed memory
> memblock tests: update zeroed memory check for memblock_alloc_* tests
> memblock tests: add labels to verbose output for generic alloc tests
> memblock tests: add additional tests for basic api and memblock_alloc
> memblock tests: update alloc_api to test memblock_alloc_raw
> memblock tests: update alloc_nid_api to test
> memblock_alloc_try_nid_raw
> memblock tests: add tests for memblock_*bottom_up functions
> memblock tests: add tests for memblock_trim_memory
>
> tools/testing/memblock/tests/alloc_api.c | 168 +++-
> .../memblock/tests/alloc_helpers_api.c | 20 +-
> tools/testing/memblock/tests/alloc_nid_api.c | 252 +++---
> tools/testing/memblock/tests/basic_api.c | 767 ++++++++++++++++++
> tools/testing/memblock/tests/common.c | 7 +
> tools/testing/memblock/tests/common.h | 55 ++
> 6 files changed, 1082 insertions(+), 187 deletions(-)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 0/8] memblock tests: update and extend memblock simulator
2022-08-27 5:42 [PATCH v3 0/8] memblock tests: update and extend memblock simulator Rebecca Mckeever
2022-08-27 5:42 ` [PATCH v3 3/8] memblock tests: add labels to verbose output for generic alloc tests Rebecca Mckeever
2022-08-28 2:45 ` [PATCH v3 0/8] memblock tests: update and extend memblock simulator Huang, Shaoqin
@ 2022-08-30 10:13 ` Mike Rapoport
2 siblings, 0 replies; 4+ messages in thread
From: Mike Rapoport @ 2022-08-30 10:13 UTC (permalink / raw)
To: Rebecca Mckeever; +Cc: linux-mm, linux-kernel, David Hildenbrand
On Sat, Aug 27, 2022 at 12:42:42AM -0500, Rebecca Mckeever wrote:
> These patches update existing tests in memblock simulator, add
> additional tests for memblock functions that are already being tested,
> and add test coverage for additional memblock functions.
>
> Rebecca Mckeever (8):
> memblock tests: update tests to check if memblock_alloc zeroed memory
> memblock tests: update zeroed memory check for memblock_alloc_* tests
> memblock tests: add labels to verbose output for generic alloc tests
> memblock tests: add additional tests for basic api and memblock_alloc
> memblock tests: update alloc_api to test memblock_alloc_raw
> memblock tests: update alloc_nid_api to test
> memblock_alloc_try_nid_raw
> memblock tests: add tests for memblock_*bottom_up functions
> memblock tests: add tests for memblock_trim_memory
>
> tools/testing/memblock/tests/alloc_api.c | 168 +++-
> .../memblock/tests/alloc_helpers_api.c | 20 +-
> tools/testing/memblock/tests/alloc_nid_api.c | 252 +++---
> tools/testing/memblock/tests/basic_api.c | 767 ++++++++++++++++++
> tools/testing/memblock/tests/common.c | 7 +
> tools/testing/memblock/tests/common.h | 55 ++
> 6 files changed, 1082 insertions(+), 187 deletions(-)
Applied, thanks!
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 4+ messages in thread