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 19BD1ECAAD3 for ; Fri, 2 Sep 2022 00:08:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F1CD8D0005; Thu, 1 Sep 2022 20:08:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A1378D0002; Thu, 1 Sep 2022 20:08:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46A128D0005; Thu, 1 Sep 2022 20:08:32 -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 365578D0002 for ; Thu, 1 Sep 2022 20:08:32 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 06138AACAD for ; Fri, 2 Sep 2022 00:08:32 +0000 (UTC) X-FDA: 79865208864.20.E2B9150 Received: from mail-oa1-f66.google.com (mail-oa1-f66.google.com [209.85.160.66]) by imf31.hostedemail.com (Postfix) with ESMTP id AC29A20061 for ; Fri, 2 Sep 2022 00:08:31 +0000 (UTC) Received: by mail-oa1-f66.google.com with SMTP id 586e51a60fabf-1225219ee46so1234632fac.2 for ; Thu, 01 Sep 2022 17:08:31 -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=cd8UXaLR0IicU4AOk7UKJgay4GHu8DwVdf9UBh0pUjw=; b=VLY2dHKFKuStaRf/vcdP3v7LBWyLM8VbbuIYYXLg53mzURdKtBlgcFRhC9Gn4tzPTD nxovJiu6z8JZ5IcWYUF4e5OinMpZnxVmDLtQKtL+WDBrMjJPtNzbRAVZZqBm0krZJy2d 3COZLiG+ApTGino+6KM8VXfMN0OH0y8HH4pYP/4iHUyPLgBQJnQpnSxsRB+lzYR5aWHP CkJH16U+amfBINLvq1mDGyroLmX55kfJoOBsFOVnIuGGqwyf8EHQQQOcvkmt55ZE30zM M9lerPvWV+cO7Pu4ihplIWrQ+44v+OGe79rlQh1aPgj7gb8lebgxbjRNxEkN+nsUNQEt W6ow== 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=cd8UXaLR0IicU4AOk7UKJgay4GHu8DwVdf9UBh0pUjw=; b=j551jzxa7ClY/Tte5Sa4PL7Kn0eDpkp6tEFYIwTO+s4pCbXzMKai6OKbwHXFEEBH8w jn9JRi5w7h7tyyShCtuAB4O9KNB0I8b0i9pCUAKfEdnaeVrUXpaMXpsAZleTjLPW0fhQ woTUbrqGH7V8vtSo45TvVV53FzPHqRR9JdXBbrjsIuLxpTeSV3tsma7jVPvkqQkeeJuc 9VHM/CP+b2WHkVwoLHF0mjKoAukmSG2EkEfb3Qousc/QEFYj5rnHgvxRP9sposRv3aKQ /bPICD3+ZG4qUBEfhwXuBnIFrii+kX6LdryLka6nrZiAdVXmQaMfgfVRH28VFH5bQ5BN 1rIQ== X-Gm-Message-State: ACgBeo3lDhYgv54g8rbFkoyjrVphgYkcFu13y5m6MWEqk24eWIvnSvM7 EhwIYHAT5TrTLAFYbuhnYdY= X-Google-Smtp-Source: AA6agR73nHNG1fLa3SjmOoM1nkt+XEbOuHf17niOI92pG+PiGn3TIPZFWorZGTTuVm5JcUa5REj5zg== X-Received: by 2002:a05:6870:8984:b0:10d:d981:151f with SMTP id f4-20020a056870898400b0010dd981151fmr895003oaq.212.1662077310915; Thu, 01 Sep 2022 17:08:30 -0700 (PDT) Received: from sophie (static-198-54-128-70.cust.tzulo.com. [198.54.128.70]) by smtp.gmail.com with ESMTPSA id r22-20020a4abf16000000b0044ae10c5974sm170816oop.34.2022.09.01.17.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 17:08:30 -0700 (PDT) Date: Thu, 1 Sep 2022 19:08:28 -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: <20220902000828.GB17689@sophie> References: <0cfb3c69ba6ca9ff55e1fc2528d18d108416ba57.1660897864.git.remckee0@gmail.com> <329ab669-620c-ba9e-3c57-9cb90d55b942@redhat.com> <20220831034909.GA16092@sophie> <7c83950c-6a83-e35b-0060-79b5df3bda56@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7c83950c-6a83-e35b-0060-79b5df3bda56@redhat.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662077311; a=rsa-sha256; cv=none; b=g8FkRvZDKHDPBIwktNNI0ZU/KUC6sVoTdB3N+P4QlQGaJwfMhbtkFOSoV/1W9VLibgUo9/ MozPA7CnT+PY7NLvpAgzejBGchB4Bg8cmviYWHW4QD67ZEra+tkZrXFjg49O5ngot0fKEL W/XQpvYRlT/R3f0AiRiuxTsUqza7Blg= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=VLY2dHKF; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf31.hostedemail.com: domain of remckee0@gmail.com designates 209.85.160.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=1662077311; 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=cd8UXaLR0IicU4AOk7UKJgay4GHu8DwVdf9UBh0pUjw=; b=zE/rzwJBFFqKu1ls64a8ALLIuIqWxQoZ812G+vtvnzMDs4ndC+1ROWlPTV/LvaegWR6B3B 6M+x+zKBCFEe7ISvXH62HrabxtGts+XYTtuVswhbLZ4wTyP/lZUE0rWjtb6VLm4ei7x0a4 4AB2xuFOc9/GdWEviL8cN0ZSi7jWCj4= X-Stat-Signature: y37noicyr7z5ck84oe595c6xs3jggciy X-Rspamd-Queue-Id: AC29A20061 X-Rspam-User: Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=VLY2dHKF; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf31.hostedemail.com: domain of remckee0@gmail.com designates 209.85.160.66 as permitted sender) smtp.mailfrom=remckee0@gmail.com X-Rspamd-Server: rspam08 X-HE-Tag: 1662077311-610440 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 Thu, Sep 01, 2022 at 10:06:48AM +0200, David Hildenbrand wrote: > On 31.08.22 05:49, 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. > > Independent of the suggestion from Mike, I wonder if we should really > care about (eventual) MEM_SIZE changes for now if not caring simplifies > the current code. > Maybe not. I'm going to try Mike's suggestion, but I will keep this in mind if the code seems too complicated. > -- > Thanks, > > David / dhildenb > Thanks, Rebecca