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 2678CECAAD2 for ; Thu, 1 Sep 2022 22:53:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7AC1180079; Thu, 1 Sep 2022 18:53:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 75AD28000D; Thu, 1 Sep 2022 18:53:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FBA280079; Thu, 1 Sep 2022 18:53:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4C02B8000D for ; Thu, 1 Sep 2022 18:53:36 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 11FBD80383 for ; Thu, 1 Sep 2022 22:53:36 +0000 (UTC) X-FDA: 79865020032.03.618C7C0 Received: from mail-oa1-f68.google.com (mail-oa1-f68.google.com [209.85.160.68]) by imf23.hostedemail.com (Postfix) with ESMTP id BFA2814005A for ; Thu, 1 Sep 2022 22:53:35 +0000 (UTC) Received: by mail-oa1-f68.google.com with SMTP id 586e51a60fabf-11f11d932a8so886270fac.3 for ; Thu, 01 Sep 2022 15:53:35 -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=+ZQPG1GSM+Nn3h6KB6a2OhCHkqSdeVgCoGOQme1CXs4=; b=hK07d2O4pVl/l8Nf6xl55zgmm4/jxAJzG5Ye8/nf0IMBj3q0g0244nJGRCjWH5L1Hv 0MTo+x0IdztSW3JQXw4LQO0R7IOqhEUwNFZKWGICp7HxXfruPgZVZ+HTeKn5D3dWwxYB vTTKWpfbw70wudjbmbjiCnVtLM5aPZsTMrY++mQ++M4KmMHk12h322d2EPz7mWuYePMH Bq4RM5OJrC4audEyz9p0KULUZERK9wCipMewwGBko5Lkm6evXlHwQQOL9OMNCOkOnxaH VnEpeHUPbqdhuur/BXXvM3G6rx9JEHKJK2Ucl7THv3Xmo6WQdwxaE3YIR50MTrYb4r0k Csag== 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=+ZQPG1GSM+Nn3h6KB6a2OhCHkqSdeVgCoGOQme1CXs4=; b=gdTbNwhDzBN+b/BrIBkuTk4VR1cvpwbBl9phUKNWE/k0upPTqxjLJsRNUOSZgkkWyZ WGT5baQVtL6spJsEMXCusWGH1pQP0YYmEBkO7olQLYw5EV/1nvtR9W+2In7zSH6Bk9KY Qw44jtDJZPktrfdsmBwzq4/XrSB9o7jjdd31uqfKLM9Lx/AE4wqUXLznFRKLhgZFr6pA Di8b7hyClU5g/I8r9OjTMos42loecnXwLGh11bRqW3VGHhdNFVKqOA8FfpaphK6g8Tnf SoDbRAvHNHOafRPxNZkMaRG+4dBqhxvaORV+hOPcjBL7us9lXgAbdfBB2XxYicGY4DS6 0rwg== X-Gm-Message-State: ACgBeo3jM6LfBP2pNtHiQ2XbZdmUyCPxDh1qRwsdEFAi9vibNsyweCRE XKGvvWe1EH+8wkNRoWOEDgY= X-Google-Smtp-Source: AA6agR6Dkqc+qHDNAoVTIoKGh4lRvx5pxpl71iU8moUMeBKZcbDIE0txx51n0LOgp44cg0XI/Az3xw== X-Received: by 2002:a05:6870:f229:b0:114:25db:4000 with SMTP id t41-20020a056870f22900b0011425db4000mr792265oao.246.1662072814842; Thu, 01 Sep 2022 15:53:34 -0700 (PDT) Received: from sophie (static-198-54-128-70.cust.tzulo.com. [198.54.128.70]) by smtp.gmail.com with ESMTPSA id 188-20020a4a1dc5000000b0044565e7ab41sm125589oog.32.2022.09.01.15.53.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 15:53:34 -0700 (PDT) Date: Thu, 1 Sep 2022 17:53:32 -0500 From: Rebecca Mckeever To: Mike Rapoport 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: <20220901225332.GA17689@sophie> 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: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662072815; 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=+ZQPG1GSM+Nn3h6KB6a2OhCHkqSdeVgCoGOQme1CXs4=; b=oI33GYncM/mYyXeSIzBkn1c8fzxD/BFLR/FKliJggiQAd3tZbjCKn2EMc+C8rQeA2bNANG P+UPpA67BIdz+WNpDzsmadIXPymO+5itlVeaGjkNmqhfU/uHjDHHrxcg8UgEiwnE9FFpR9 OH1EPsvMpMfq/Duqkptg3ITNzEWs97o= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hK07d2O4; spf=pass (imf23.hostedemail.com: domain of remckee0@gmail.com designates 209.85.160.68 as permitted sender) smtp.mailfrom=remckee0@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662072815; a=rsa-sha256; cv=none; b=zQVECYcuLuc3V66O5yCyuG2Ig1erCZkuO8Ve+TPIlQ4dC9XUjQ4m8D/oXuj3n+mn4nC6bM stccrOk/cnpVLE7F6NBmTfJ7QxVUujBY31kHOV5QU1KdeBIbDjs381HOBYNVIM4cNB/BbE pQQotZrEGBRAyRciJ84r7LKnsIUhuMg= X-Stat-Signature: rtqsbosjdahtm8mr5yyeyotes4rt37he X-Rspamd-Queue-Id: BFA2814005A X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hK07d2O4; spf=pass (imf23.hostedemail.com: domain of remckee0@gmail.com designates 209.85.160.68 as permitted sender) smtp.mailfrom=remckee0@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-HE-Tag: 1662072815-946685 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 Wed, Aug 31, 2022 at 06:12:10PM +0300, Mike Rapoport wrote: > 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. > I think that will work. I'll try it. > > Thanks, > > Rebecca > > -- > Sincerely yours, > Mike. Thanks, Rebecca