linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Rebecca Mckeever <remckee0@gmail.com>,
	Mike Rapoport <rppt@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] memblock tests: add simulation of physical memory with multiple NUMA nodes
Date: Tue, 30 Aug 2022 13:17:56 +0200	[thread overview]
Message-ID: <329ab669-620c-ba9e-3c57-9cb90d55b942@redhat.com> (raw)
In-Reply-To: <0cfb3c69ba6ca9ff55e1fc2528d18d108416ba57.1660897864.git.remckee0@gmail.com>

On 19.08.22 11:05, Rebecca Mckeever wrote:
> Add functions setup_numa_memblock_generic() and setup_numa_memblock()
> for setting up a memory layout with multiple NUMA nodes in a previously
> allocated dummy physical memory. These functions can be used in place of
> setup_memblock() in tests that need to simulate a NUMA system.
> 
> setup_numa_memblock_generic():
> - allows for setting up a custom memory layout by specifying the amount
>   of memory in each node, the number of nodes, and a factor that will be
>   used to scale the memory in each node
> 
> setup_numa_memblock():
> - allows for setting up a default memory layout
> 
> Introduce constant MEM_FACTOR, which is used to scale the default memory
> layout based on MEM_SIZE.
> 
> Set CONFIG_NODES_SHIFT to 4 when building with NUMA=1 to allow for up to
> 16 NUMA nodes.
> 
> Signed-off-by: Rebecca Mckeever <remckee0@gmail.com>
> ---
>  .../testing/memblock/scripts/Makefile.include |  2 +-
>  tools/testing/memblock/tests/common.c         | 38 +++++++++++++++++++
>  tools/testing/memblock/tests/common.h         |  9 ++++-
>  3 files changed, 47 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/memblock/scripts/Makefile.include b/tools/testing/memblock/scripts/Makefile.include
> index aa6d82d56a23..998281723590 100644
> --- a/tools/testing/memblock/scripts/Makefile.include
> +++ b/tools/testing/memblock/scripts/Makefile.include
> @@ -3,7 +3,7 @@
>  
>  # Simulate CONFIG_NUMA=y
>  ifeq ($(NUMA), 1)
> -	CFLAGS += -D CONFIG_NUMA
> +	CFLAGS += -D CONFIG_NUMA -D CONFIG_NODES_SHIFT=4
>  endif
>  
>  # Use 32 bit physical addresses.
> diff --git a/tools/testing/memblock/tests/common.c b/tools/testing/memblock/tests/common.c
> index eec6901081af..15d8767dc70c 100644
> --- a/tools/testing/memblock/tests/common.c
> +++ b/tools/testing/memblock/tests/common.c
> @@ -34,6 +34,10 @@ static const char * const help_opts[] = {
>  
>  static int verbose;
>  
> +static const phys_addr_t node_sizes[] = {
> +	SZ_4K, SZ_1K, SZ_2K, SZ_2K, SZ_1K, SZ_1K, SZ_4K, SZ_1K
> +};
> +
>  /* sets global variable returned by movable_node_is_enabled() stub */
>  bool movable_node_enabled;
>  
> @@ -72,6 +76,40 @@ void setup_memblock(void)
>  	fill_memblock();
>  }
>  
> +/**
> + * setup_numa_memblock_generic:
> + * Set up a memory layout with multiple NUMA nodes in a previously allocated
> + * dummy physical memory.
> + * @nodes: an array containing the amount of memory in each node
> + * @node_cnt: the size of @nodes
> + * @factor: a factor that will be used to scale the memory in each node
> + *
> + * The nids will be set to 0 through node_cnt - 1.
> + */
> +void setup_numa_memblock_generic(const phys_addr_t nodes[],
> +				 int node_cnt, int factor)
> +{
> +	phys_addr_t base;
> +	int flags;
> +
> +	reset_memblock_regions();
> +	base = (phys_addr_t)memory_block.base;
> +	flags = (movable_node_is_enabled()) ? MEMBLOCK_NONE : MEMBLOCK_HOTPLUG;
> +
> +	for (int i = 0; i < node_cnt; i++) {
> +		phys_addr_t size = factor * nodes[i];

I'm a bit lost why we need the factor if we already provide sizes in the
array.

Can you enlighten me? :)

Why can't we just stick to the sizes in the array?

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2022-08-30 11:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1660897864.git.remckee0@gmail.com>
2022-08-19  9:05 ` [PATCH v2 1/4] memblock tests: add simulation of physical memory with multiple NUMA nodes Rebecca Mckeever
2022-08-30 11:17   ` David Hildenbrand [this message]
2022-08-31  3:49     ` Rebecca Mckeever
2022-08-31 15:12       ` Mike Rapoport
2022-09-01 22:53         ` Rebecca Mckeever
2022-09-01  8:06       ` David Hildenbrand
2022-09-02  0:08         ` Rebecca Mckeever
2022-08-31 15:15   ` Mike Rapoport
2022-09-02  0:14     ` Rebecca Mckeever
     [not found] ` <957966f06474e3885796247ad1beaa6b3841ebd1.1660897864.git.remckee0@gmail.com>
2022-08-30 11:56   ` [PATCH v2 2/4] memblock tests: add top-down NUMA tests for memblock_alloc_try_nid* David Hildenbrand
2022-09-02  0:37     ` Rebecca Mckeever

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=329ab669-620c-ba9e-3c57-9cb90d55b942@redhat.com \
    --to=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=remckee0@gmail.com \
    --cc=rppt@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).