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 EA563ECAAD8 for ; Wed, 31 Aug 2022 03:49:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0375E8D0001; Tue, 30 Aug 2022 23:49:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F28466B0072; Tue, 30 Aug 2022 23:49:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF06A8D0001; Tue, 30 Aug 2022 23:49:12 -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 CD2806B0071 for ; Tue, 30 Aug 2022 23:49:12 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 63C83C02C3 for ; Wed, 31 Aug 2022 03:49:12 +0000 (UTC) X-FDA: 79858507344.17.6642A63 Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by imf29.hostedemail.com (Postfix) with ESMTP id 0C89D12005F for ; Wed, 31 Aug 2022 03:49:11 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id c9so9971347qkk.6 for ; Tue, 30 Aug 2022 20:49:11 -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; bh=gk0iaSJZd5YzOd+2zJ3o0BDcK8HeEHtmeUyCb8yUhwg=; b=QyPzKIVt2x781/58vuUJd2IpLRwDNMhuuv/u/in2ftPzeonWhYG6Lgvb4rxm+lgy7h p7+c05xoW4aoU1QQuBsrFW+R0xTD7YyOzdcKc0eo+WcKtOYL4of2yicINzeJdsxTsICb c93wO3BOziIlFkfZaV39mlAiZcagm6QYzYHcVcwVOU/rAacNdOG8lA/sCpHRWay8qOpj UIE1n5qYGg5ANrt/9yc6EUv0t512o7Wr8HZoCcZVD8onj4D2kIqMMYGh4yWsgEVZd5do kU6CUtsTKDcYZLggSiamKsbJlEKbCj1YTkl6CpyM2Cz5DZPw0llUBFDcFZvTMoykmhbn 3ASg== 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; bh=gk0iaSJZd5YzOd+2zJ3o0BDcK8HeEHtmeUyCb8yUhwg=; b=VT1pwguX7hWBzwx97jL57xSKTxvY8oQFpGR+eqsLJdDw1j6bZKhZn6qLjJWsv6pSYV hV7EKrP7bFwNoqg+hBAW2hU8H2LChrYchMPLxOGp0Ah/UCM9CcgAcL4r173KLNLt0ite U5QX+lXDBFSeQKyEkItQrrhzBWwktIgUW3CtA1GESHC5KZKTnnBbLB14i2xSq6QnNs+c pQFraxNvbxMIuJ6Go2ZVnk2oTFORkALYDJfSrJfRAybWjE/+0hvJJuSGEvLTfwtwtPqY iSPNEUGyPWPZZIH67arKddBfVZulGv2RGokvZpFxoYx16P1nfpftCl2S7ghfElOYq9Qg NUgQ== X-Gm-Message-State: ACgBeo3jJR+ROVLAf4eMdw/bnjB/OHPGwB/WwQ+cA+9lOdoSmGpmCM5j UjJ2Ug4lUIKbweZhNpKu3LA= X-Google-Smtp-Source: AA6agR61z5dsBNHuUN1y8570X5NV/YX276IXuHchR3IZ3zRLEhosUC8KLcvp8jOb9LoJeGZxmDYFQg== X-Received: by 2002:a05:620a:4502:b0:6b4:6c2f:e7b7 with SMTP id t2-20020a05620a450200b006b46c2fe7b7mr14502233qkp.11.1661917751176; Tue, 30 Aug 2022 20:49:11 -0700 (PDT) Received: from sophie ([45.134.140.172]) by smtp.gmail.com with ESMTPSA id u6-20020a05620a430600b006b893d135basm9012602qko.86.2022.08.30.20.49.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 20:49:10 -0700 (PDT) Date: Tue, 30 Aug 2022 22:49:09 -0500 From: Rebecca Mckeever To: David Hildenbrand Cc: Mike Rapoport , 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: <20220831034909.GA16092@sophie> References: <0cfb3c69ba6ca9ff55e1fc2528d18d108416ba57.1660897864.git.remckee0@gmail.com> <329ab669-620c-ba9e-3c57-9cb90d55b942@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <329ab669-620c-ba9e-3c57-9cb90d55b942@redhat.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661917752; a=rsa-sha256; cv=none; b=A/6m83TQdtHoTshxoUeK0kke0P3FddORlaTxuS/tfQkiaNBdFzWo9+j++209uBjLXKRk0X m+IV0LYOKYWUf0aIRv8/FQodIxBBmCI3dtJEnJSIy5q6lsBVEpm2D6ufI7saGNfgxK65es y1KxEJOr7veFRDdYv086Ev/6qIVdLFE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QyPzKIVt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of remckee0@gmail.com designates 209.85.222.193 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=1661917752; 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=gk0iaSJZd5YzOd+2zJ3o0BDcK8HeEHtmeUyCb8yUhwg=; b=XwFA/bNxcSWOkSXlvNJE+AKUlI5didFqpNccktgopvjP/VUwuilmNPDqUz9W+aePpsRzaP bRDIBNDbkTkjxY9K6ygx8dq7b5cPY2OHaE7amYSSEiM6MW9TCBSvKh3tU4kO5jfAHpM9FH cV/r1H7D/vJvgHmttiaLFnoI2rBdi/8= Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QyPzKIVt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of remckee0@gmail.com designates 209.85.222.193 as permitted sender) smtp.mailfrom=remckee0@gmail.com X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: 8scrtqrd3h6beg8eybhxi5cidauzk41g X-Rspamd-Queue-Id: 0C89D12005F X-HE-Tag: 1661917751-879815 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 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. > -- > Thanks, > > David / dhildenb > Thanks, Rebecca