From: Mike Rapoport <rppt@kernel.org>
To: Claudio Migliorelli <claudio.migliorelli@mail.polimi.it>
Cc: remckee0@gmail.com, david@redhat.com, shaoqin.huang@intel.com,
karolinadrobnik@gmail.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] Add tests for memblock_alloc_node()
Date: Tue, 7 Mar 2023 15:11:43 +0200 [thread overview]
Message-ID: <ZAc4D3+qfMVwpZr7@kernel.org> (raw)
In-Reply-To: <ea5e938e-6b74-b188-af59-4b94b18bc0@mail.polimi.it>
On Sat, Feb 25, 2023 at 07:07:11PM +0100, Claudio Migliorelli wrote:
> This test is aimed at verifying the memblock_alloc_node() to work as
> expected, so setting the correct NUMA node for the new allocated
> region. The memblock_alloc_node() is called directly without using any
> stub. The core check is between the requested NUMA node and the `nid`
> field inside the memblock_region structure. These two are supposed to
> be equal for the test to succeed.
>
> Signed-off-by: Claudio Migliorelli <claudio.migliorelli@mail.polimi.it>
Applied, thanks!
> ---
> Changelog:
> ----------
> v3:
> - Fixed errors related to "<stdin>:188: trailing whitespace"
> that caused a failure when applying the patch
> v2:
> - Use the memblock_alloc_node() directly without mimicking it
> ---
> tools/testing/memblock/tests/alloc_nid_api.c | 40 ++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> diff --git a/tools/testing/memblock/tests/alloc_nid_api.c b/tools/testing/memblock/tests/alloc_nid_api.c
> index 49ef68cccd6f..49bb416d34ff 100644
> --- a/tools/testing/memblock/tests/alloc_nid_api.c
> +++ b/tools/testing/memblock/tests/alloc_nid_api.c
> @@ -2494,6 +2494,35 @@ static int alloc_nid_numa_split_all_reserved_generic_check(void)
> return 0;
> }
>
> +/*
> + * A simple test that tries to allocate a memory region through the
> + * memblock_alloc_node() on a NUMA node with id `nid`. Expected to have the
> + * correct NUMA node set for the new region.
> + */
> +static int alloc_node_on_correct_nid(void)
> +{
> + int nid_req = 2;
> + void *allocated_ptr = NULL;
> +#ifdef CONFIG_NUMA
> + struct memblock_region *req_node = &memblock.memory.regions[nid_req];
> +#endif
> + phys_addr_t size = SZ_512;
> +
> + PREFIX_PUSH();
> + setup_numa_memblock(node_fractions);
> +
> + allocated_ptr = memblock_alloc_node(size, SMP_CACHE_BYTES, nid_req);
> +
> + ASSERT_NE(allocated_ptr, NULL);
> +#ifdef CONFIG_NUMA
> + ASSERT_EQ(nid_req, req_node->nid);
> +#endif
> +
> + test_pass_pop();
> +
> + return 0;
> +}
> +
> /* Test case wrappers for NUMA tests */
> static int alloc_nid_numa_simple_check(void)
> {
> @@ -2632,6 +2661,15 @@ static int alloc_nid_numa_split_all_reserved_check(void)
> return 0;
> }
>
> +static int alloc_node_numa_on_correct_nid(void)
> +{
> + test_print("\tRunning %s...\n", __func__);
> + run_top_down(alloc_node_on_correct_nid);
> + run_bottom_up(alloc_node_on_correct_nid);
> +
> + return 0;
> +}
> +
> int __memblock_alloc_nid_numa_checks(void)
> {
> test_print("Running %s NUMA tests...\n",
> @@ -2652,6 +2690,8 @@ int __memblock_alloc_nid_numa_checks(void)
> alloc_nid_numa_reserved_full_merge_check();
> alloc_nid_numa_split_all_reserved_check();
>
> + alloc_node_numa_on_correct_nid();
> +
> return 0;
> }
>
> --
> 2.38.3
>
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2023-03-07 13:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-25 18:07 [PATCH v3] Add tests for memblock_alloc_node() Claudio Migliorelli
2023-03-07 13:11 ` Mike Rapoport [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZAc4D3+qfMVwpZr7@kernel.org \
--to=rppt@kernel.org \
--cc=claudio.migliorelli@mail.polimi.it \
--cc=david@redhat.com \
--cc=karolinadrobnik@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=remckee0@gmail.com \
--cc=shaoqin.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.