From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8683FECAAD4 for ; Wed, 31 Aug 2022 15:12:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F41CA8D0002; Wed, 31 Aug 2022 11:12:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ECB5B8D0001; Wed, 31 Aug 2022 11:12:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D45758D0002; Wed, 31 Aug 2022 11:12:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C2F748D0001 for ; Wed, 31 Aug 2022 11:12:29 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8EB10A4935 for ; Wed, 31 Aug 2022 15:12:29 +0000 (UTC) X-FDA: 79860229218.11.68C67F7 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf03.hostedemail.com (Postfix) with ESMTP id E947220041 for ; Wed, 31 Aug 2022 15:12:28 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6F234B81F65; Wed, 31 Aug 2022 15:12:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC4E2C433C1; Wed, 31 Aug 2022 15:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661958746; bh=LN5ft900VWcZqbmOX1GAJNvSpMmYcn2WjpWnuStpoSU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YDmEfym11ZKNej3wZ6h1qUB+Mq8zW3YIH3w7dqMB7ehFABHcEG+IDKG+0UMFqGMNw br5L75qpluKqzbUqVcAc65WA8SgJF1+zQeyljTHkA7SmWQ+Ax3r0FD70LUUmKX7CHH sC2vM656DB9mIQsIaSqb+8HzZjEkGxkc/A7MgnI5hSqtYST6kVnXowTZ3hNjGVhQ1B N3AWZghne/xW12qPVwbNr+YWtlVmBZ0DHGD2yVDuJydEwdm1m51zoi//uko3p4Vt6I +Dm16SYMUAtWnTGirGGqyVTEzKsnFn7ZC8xx+hpNopaRa04/54T1yPlPwM6+5wgVVn wXbVoBlnMexgQ== Date: Wed, 31 Aug 2022 18:12:10 +0300 From: Mike Rapoport To: Rebecca Mckeever Cc: David Hildenbrand , 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 Message-ID: References: <0cfb3c69ba6ca9ff55e1fc2528d18d108416ba57.1660897864.git.remckee0@gmail.com> <329ab669-620c-ba9e-3c57-9cb90d55b942@redhat.com> <20220831034909.GA16092@sophie> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220831034909.GA16092@sophie> ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YDmEfym1; spf=pass (imf03.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661958749; a=rsa-sha256; cv=none; b=KSxcgkSjZlyJy+arp0nyfiJop3x/s1djsChqvezzoQGkGcuUNSlVxJ54Nzl5OugF7Fn0zp 71bJPzOkkP7RnG6bGxhRz7l+Z+YIzpua6mg71AHqJVRJ77UOJWr67aW+ap69v96YvssZzE YXcHYki3oRXmkrhJ9876eYnnpRjtyBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661958749; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5XcCmI9re7XBGFr+uDvHq0lL8D/6frmNBu3nr7ySRvs=; b=W6BH/Bjgh6Sb1Oi4h9+lOav0Mq+ZFYV4vjhCAQztIECWOser8RfFvSdXiO/s/Gmf1XQjKX 1O8gBbxb/SB71gRKy5hMP3yweDNqbat8xf0nPnbWxyVvA9eOSAQI/sni4KJpCDgESMzseh r0GSIX27pRG5HiVsxwNwVUPdaHmyPJc= Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YDmEfym1; spf=pass (imf03.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Stat-Signature: 8cpy5zrrdei6r9h7cay9z1igfjqru9af X-Rspamd-Queue-Id: E947220041 X-Rspamd-Server: rspam09 X-HE-Tag: 1661958748-685484 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Aug 30, 2022 at 10:49:09PM -0500, Rebecca Mckeever wrote: > On Tue, Aug 30, 2022 at 01:17:56PM +0200, David Hildenbrand wrote: > > 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 > > > --- > > > .../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? > > > Without the factor, some of the tests will break if we increase MEM_SIZE > in the future (which we may need to do). I could rewrite them so that the > factor is not needed, but I thought the code would be over-complicated if > I did. What if we make nodes[] to represent the fraction of the memory rather than a node size? Then the factor won't be required. > Thanks, > Rebecca -- Sincerely yours, Mike.