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 3BE41ECAAD1 for ; Thu, 1 Sep 2022 08:06:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B68296B0072; Thu, 1 Sep 2022 04:06:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B179A6B0073; Thu, 1 Sep 2022 04:06:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B83C8D0001; Thu, 1 Sep 2022 04:06:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 891D06B0072 for ; Thu, 1 Sep 2022 04:06:53 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5FDB6C0A30 for ; Thu, 1 Sep 2022 08:06:53 +0000 (UTC) X-FDA: 79862785506.02.2C5B92E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 0A63220045 for ; Thu, 1 Sep 2022 08:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662019612; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dqPVrtOwWGCqcYDkakHKdTas6tpFK8zIdpjFxy7YvEE=; b=ROLrzLRMhqE2EUWS7+oIMNIQUhrdNajs1H4WC1Cm373az7O5XspEhsiojeLL2vzV3rgpMk tQtSVELrUSDievVaM7ayYrVdeG9DQwr/mXYLN6m8RXXZAK8nj95eFENRwPO0VXdrDv3hIv IErUtUDpKBPiAjz5yCUMe1Z4/5MUSBA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-46-QCkPALwwP0Wa15NIuYE0WQ-1; Thu, 01 Sep 2022 04:06:51 -0400 X-MC-Unique: QCkPALwwP0Wa15NIuYE0WQ-1 Received: by mail-wr1-f72.google.com with SMTP id u15-20020adfa18f000000b00226d4b62f10so2345909wru.9 for ; Thu, 01 Sep 2022 01:06:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=dqPVrtOwWGCqcYDkakHKdTas6tpFK8zIdpjFxy7YvEE=; b=Ts1CsZawMs9o+NHD4sluLX/JKaa2sVkYJ6gsgYVUaCX0WiKL+mbmK9cgWoI8xh2nzu yBSEHso0bxmewvittmrboWWLUdadwFDxNpSo0dQ0kEsFilzuKmsPsltW3ytQ8Eiy2j5Z qfuLSWSfRoymf6KzXYH2Y6wgtFC4D7CJX8V68sHbbp3gc4e43ksYZj50EMNpr1okXIZc DMZE1TQj5kVTweMwWS24gMKrpNNMD0V8LFjY5uA6jfya8dt561FDS6LNgMYQVjPhI4kj xak4K41Fk7sTj+0JxxD6SynfATEMAcTY4kPNQ+jaSvzJGHZu4OuZqOwCHCy8GUjp1h9J WnNg== X-Gm-Message-State: ACgBeo0fTNrmRSIXZLVA5MoTiKR6NIVkMNhr8KLD3cRiUib51Cyav17Y o03TpvaMLHMzjrqjIbL6Hx1w8MNTmyyaIhTZkozjrfkgwcJQ5ZZHqlWkRI+7MGKxjoFwDn58a1I 5PVc+wJPerTE= X-Received: by 2002:a05:600c:358e:b0:3a5:f19d:28db with SMTP id p14-20020a05600c358e00b003a5f19d28dbmr4477730wmq.76.1662019610223; Thu, 01 Sep 2022 01:06:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR56CdGBcdfAUEu62KyI3cxizpsi0lfGeFDK2oviALHqdX9dLBLxRg/MEJEONW33aP8AvHXgiQ== X-Received: by 2002:a05:600c:358e:b0:3a5:f19d:28db with SMTP id p14-20020a05600c358e00b003a5f19d28dbmr4477716wmq.76.1662019609965; Thu, 01 Sep 2022 01:06:49 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:9e00:fec0:7e96:15cb:742? (p200300cbc7079e00fec07e9615cb0742.dip0.t-ipconnect.de. [2003:cb:c707:9e00:fec0:7e96:15cb:742]) by smtp.gmail.com with ESMTPSA id o5-20020a05600c510500b003a5f2cc2f1dsm5100452wms.42.2022.09.01.01.06.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Sep 2022 01:06:49 -0700 (PDT) Message-ID: <7c83950c-6a83-e35b-0060-79b5df3bda56@redhat.com> Date: Thu, 1 Sep 2022 10:06:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH v2 1/4] memblock tests: add simulation of physical memory with multiple NUMA nodes To: Rebecca Mckeever Cc: Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <0cfb3c69ba6ca9ff55e1fc2528d18d108416ba57.1660897864.git.remckee0@gmail.com> <329ab669-620c-ba9e-3c57-9cb90d55b942@redhat.com> <20220831034909.GA16092@sophie> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220831034909.GA16092@sophie> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ROLrzLRM; spf=pass (imf03.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662019613; a=rsa-sha256; cv=none; b=OzLr4HxneU083CrBHobbl+Wxr+WxA+HBWMqjiphzgn6atYoCrhruGlcVSafG/uKI/Om5+C XP0DB2aVGj/R5LTwBoDTsa/MH5aImbLx7SZHcOEGUrrZXl4J2MGs09xnPcvtjG33BwJYTN zF4U9LWWccgpcnwjsHDHk1a1De0FsFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662019613; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dqPVrtOwWGCqcYDkakHKdTas6tpFK8zIdpjFxy7YvEE=; b=IYPFkmC5TLtGq086F6atwVnKfpzllFTzooP0Stu8amxaszOtv6Y323gG5XWen4Fz4sjJku HxM4u8RkwBcxKMw8jwpZVH/mxYZIG/B4d2spiBnw8Tb1YEANkzGmMxH7cURCImNjKdfVxP np0P0vax3t7icdUYwS50BCuaqqWnr3c= Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ROLrzLRM; spf=pass (imf03.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Stat-Signature: 9kmztket58uss3wh6xk9pkqjypkczzrk X-Rspamd-Queue-Id: 0A63220045 X-Rspamd-Server: rspam09 X-HE-Tag: 1662019612-30112 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 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. -- Thanks, David / dhildenb