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 07A8CECAAA1 for ; Tue, 6 Sep 2022 23:43:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52A138D0002; Tue, 6 Sep 2022 19:43:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D9A06B0073; Tue, 6 Sep 2022 19:43:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3792C8D0002; Tue, 6 Sep 2022 19:43:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 25DB86B0072 for ; Tue, 6 Sep 2022 19:43:11 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EFF9CA0FF9 for ; Tue, 6 Sep 2022 23:43:10 +0000 (UTC) X-FDA: 79883288940.25.BA63159 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf31.hostedemail.com (Postfix) with ESMTP id AAE0A20085 for ; Tue, 6 Sep 2022 23:43:10 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id i15-20020a17090a4b8f00b0020073b4ac27so6304711pjh.3 for ; Tue, 06 Sep 2022 16:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=/qu2n9BlVn7Hcbe1BO172p4KxMySv9JPsd+DqpGVTAU=; b=bMZjQCiygEcwxhJnXa9R9YZP7JXsM125Q0KenhaZn15zQhU9FrF7bsgd4LBLa7mZsr D9dsj3DLjoyN9yufdg1WnDe4N4JXU3qYJbPLXqxfSVBvmTIvTdJvW627WeWHvJQo6h7p Bvff4fbhgquyQh892WIxr5eqJrLRtnb/txmWbR+P/YfnqcwSGx3rROaJpsFGJrGr/man K/JT/ZzhW54VgS+b8c+NL7VFwQ13V8vOudEwGyKJI63vhrjLBFklscwuEVrQAEL8e+Xk aTZRxs6FchWNO7q0Xzv9hHZIw+Wy56xYLXyrkpP7vwhpjvOYfrtOB3JyII25C9y98Yfu aQTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=/qu2n9BlVn7Hcbe1BO172p4KxMySv9JPsd+DqpGVTAU=; b=veM+mz2bxdxo1VgkNYbuPpSMj1zFajOtht0ZE2MukfkpDT+KDMdeFrg/Uejwa1lRfL yiwqtwvPpXdCMVlQlFmIOABaSgDLXT82nNYuCPb8f8rAEtIsJxR4QqIPE1v27IJHDL5l BR0tiz/Wg1c9cZg13MsyEg2jbZ1yLPBsaE5COkb+8oKKXe/121V58uTAR7eFRRmBFq3T o8Zs/Y7wwaqQocUFbby6Hpx6ZjxR47eUJ1zMrecw9+oFL0Dvkgii86YKjBxqUkkZ8QBv zloivQDWvhHMPky3rOZWDKhV4CQVYru1uCS8nVWXg9/22k6qRcCaXoDH61JQCoNOlpi7 6BMw== X-Gm-Message-State: ACgBeo14ZwjH3NThgs+L0ugnH1WRpvT317khAHtic9myZ4v4S55LTXRm xxSj6uFohyz2LzDXVUBrebY= X-Google-Smtp-Source: AA6agR6e6bJhlmKpwxoAHPb43L8BCb+CSDaRKxAwiDg+TlnwBrniT4OcUn1qUKbTLCwSxNbTeAxMFw== X-Received: by 2002:a17:902:ebc8:b0:172:549d:e392 with SMTP id p8-20020a170902ebc800b00172549de392mr1055168plg.141.1662507789398; Tue, 06 Sep 2022 16:43:09 -0700 (PDT) Received: from sophie ([169.150.203.49]) by smtp.gmail.com with ESMTPSA id g1-20020a17090a708100b001fbb0f0b00fsm13269789pjk.35.2022.09.06.16.43.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 16:43:08 -0700 (PDT) Date: Tue, 6 Sep 2022 18:43:06 -0500 From: Rebecca Mckeever To: David Hildenbrand Cc: Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/4] memblock tests: add simulation of physical memory with multiple NUMA nodes Message-ID: <20220906234306.GA4053@sophie> References: <49b96ce88dece5b394d5dd4332c1572da917b30a.1662264560.git.remckee0@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662507790; a=rsa-sha256; cv=none; b=3CbUtk8Nyx5AqCBqkdHP1NgMdh7igrduMldT2jMnV2KVy9IOso0aSbvYU71RFvjrcjIUWt 9lBZLod6h+W2DotTp+kQ3QrPOKeTGsnNk6c87OVHhDXYgbrE56WrajanlZtX6+zyHT5HGq 2nCnMqRgeqcrEMWPuXqCYf9iRwh6E6g= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bMZjQCiy; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf31.hostedemail.com: domain of remckee0@gmail.com designates 209.85.216.66 as permitted sender) smtp.mailfrom=remckee0@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662507790; 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=/qu2n9BlVn7Hcbe1BO172p4KxMySv9JPsd+DqpGVTAU=; b=rpKyMaQvYlWnBB5zpcGpqqW6dfWkfIBykgF61KckCC39ZGwOqOO/GGebaLtvr+9p4ttfpH i4J7CWPTQ1EQ45cXeT8rOafHoX9l1FU+iNKO/tggtoEBM1a7ymqCbGlE+Q5Oo5RKIERgPa j18KNaUjXip4hEPOjbBGxfdtd9Bkifw= X-Rspam-User: Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bMZjQCiy; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf31.hostedemail.com: domain of remckee0@gmail.com designates 209.85.216.66 as permitted sender) smtp.mailfrom=remckee0@gmail.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: AAE0A20085 X-Stat-Signature: fhstdqsjeiw6ip5wzgu1mc51j1ke3cgi X-HE-Tag: 1662507790-795363 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Sep 06, 2022 at 03:17:46PM +0200, David Hildenbrand wrote: > On 04.09.22 06:21, Rebecca Mckeever wrote: > > Add function setup_numa_memblock() for setting up a memory layout with > > multiple NUMA nodes in a previously allocated dummy physical memory. > > This function can be used in place of setup_memblock() in tests that need > > to simulate a NUMA system. > > > > setup_numa_memblock(): > > - allows for setting up a memory layout by specifying the fraction of > > MEM_SIZE in each node > > > > 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 | 29 +++++++++++++++++++ > > tools/testing/memblock/tests/common.h | 4 ++- > > 3 files changed, 33 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..b6110df21b2a 100644 > > --- a/tools/testing/memblock/tests/common.c > > +++ b/tools/testing/memblock/tests/common.c > > @@ -72,6 +72,35 @@ void setup_memblock(void) > > fill_memblock(); > > } > > +/** > > + * setup_numa_memblock: > > + * Set up a memory layout with multiple NUMA nodes in a previously allocated > > + * dummy physical memory. > > + * @nodes: an array containing the denominators of the fractions of MEM_SIZE > > + * contained in each node (e.g., if nodes[0] = SZ_8, node 0 will > > + * contain 1/8th of MEM_SIZE) > > + * > > + * The nids will be set to 0 through NUMA_NODES - 1. > > + */ > > +void setup_numa_memblock(const phys_addr_t nodes[]) > > +{ > > + 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 < NUMA_NODES; i++) { > > + assert(nodes[i] <= MEM_SIZE && nodes[i] > 0); > > I think it would be even easier to get if this would just be a fraction. > E.g., instead of "1/8 * MEM_SIZE" just "1/8". All values have to add up to > 1. > > ... but then we'd have to mess with floats eventually, so I guess this makes > it easier to handle these fractions. > > > We could use "int" and simply specify the fraction in percent, like > > nodes[0] = 50; > nodes[1] = 25; > nodes[2] = 25; > > and everything has to add up to 100. > This would still be a float for 1/8th (12.5) and 1/16th (6.25). What if it was the "percent" of 256 (i.e., 0x100)? > > > + phys_addr_t size = MEM_SIZE / nodes[i]; > > > Hmmm, assuming a single node with "MEM_SIZE", we would get size=1. > For a single node of MEM_SIZE, nodes[0] would be 1. > Shouldn't this be "size = nodes[i]" > > ? No, not with the current implementation. The nodes array stores the denominator of the fraction that will be multiplied by MEM_SIZE to determine the size of that node (the numerator is always 1). So if the size of the node should be 1/8 * MEM_SIZE, the nodes array just stores the 8. I think the name of the array is misleading. Do you have any suggestions for a better name? > > -- > Thanks, > > David / dhildenb > Thanks, Rebecca