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 CEFEDECAAA1 for ; Tue, 30 Aug 2022 11:18:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD0396B0073; Tue, 30 Aug 2022 07:18:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7D0A6B0074; Tue, 30 Aug 2022 07:18:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1DEE940007; Tue, 30 Aug 2022 07:18:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A16136B0073 for ; Tue, 30 Aug 2022 07:18:01 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7AD7EC032A for ; Tue, 30 Aug 2022 11:18:01 +0000 (UTC) X-FDA: 79856009562.23.1C5CB5D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id AC495140018 for ; Tue, 30 Aug 2022 11:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661858280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZxmNIacuuwOoWBsLtTJD3DQdhsimDAChe/PhEh+YcZI=; b=IJLA3aDid3jwbCS3W6o76Z4/alrVKaTM1aNy7M63ugtmUnfL6yqVXRleXzYZZlVipZMauN kCsLX5A4o0Us8V0nTn2XpFa8k0SGo9qbv0ovbvfOl1xb993bqTem8JmagvsAO2WXkOw2KN JvLYSyScPE1LcyzOqM7W6ADIpeOjujk= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-645-O9tjiwXgMS-RF4V2x6kbXw-1; Tue, 30 Aug 2022 07:17:59 -0400 X-MC-Unique: O9tjiwXgMS-RF4V2x6kbXw-1 Received: by mail-wm1-f71.google.com with SMTP id f9-20020a7bcd09000000b003a62725489bso1868718wmj.2 for ; Tue, 30 Aug 2022 04:17:58 -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 :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=ZxmNIacuuwOoWBsLtTJD3DQdhsimDAChe/PhEh+YcZI=; b=Xo++qbjsmZAlQK0iYm8rgSKkFWKwvZMIo15X+0JalqsgNG8WRjo2pvBi6Qxl59sLKY rTnsPksoJKyzIrgfdGkNv2JQFph7jfu3wzJ6lxbOur3aEBYfC8x4KWnJqTe/A71YCcT1 k+P5FNRN9SbJ8ZYDOmj2qPfByKEX03yKkIfo7qb5EEDWbuTCj+S/wxNLXOndkZAWJOeh QUGyGyT+DbkkMwNa/dZXmRrWSo+c3HbrhStR/qy/sysXM2jlZn6PMlMevYtdIAUBB2QD sZdemHve2GY+kYrgXDSXkhhF1fHMPdX0ECYyClddPTiYIoLNP0IQKxHbchhD/KznwvnY jrHQ== X-Gm-Message-State: ACgBeo05Tf58s7c5qluqAkb1NzKNRCPB+nullMKqBc1Fugft99i1XbfA I6qwkqS0btlBilevCbLEOAcypJYJBgGHdYogQr3gEXYk7QnSgnuZdP7U/6TvxCMRkJRVCSrfH9A kTwc/z16lMLE= X-Received: by 2002:a1c:7c0d:0:b0:3a6:673a:395e with SMTP id x13-20020a1c7c0d000000b003a6673a395emr9216563wmc.67.1661858277910; Tue, 30 Aug 2022 04:17:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR6yoSx94SNgBaZ6EuUcO48Vir8ri2vtPcwaz1VF0AmY4tAJL7otWozoHlqmLMFJc2DoyCHGuQ== X-Received: by 2002:a1c:7c0d:0:b0:3a6:673a:395e with SMTP id x13-20020a1c7c0d000000b003a6673a395emr9216542wmc.67.1661858277481; Tue, 30 Aug 2022 04:17:57 -0700 (PDT) Received: from ?IPV6:2003:cb:c70a:1000:ecb4:919b:e3d3:e20b? (p200300cbc70a1000ecb4919be3d3e20b.dip0.t-ipconnect.de. [2003:cb:c70a:1000:ecb4:919b:e3d3:e20b]) by smtp.gmail.com with ESMTPSA id l7-20020a05600c1d0700b003a317ee3036sm13323610wms.2.2022.08.30.04.17.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Aug 2022 04:17:56 -0700 (PDT) Message-ID: <329ab669-620c-ba9e-3c57-9cb90d55b942@redhat.com> Date: Tue, 30 Aug 2022 13:17:56 +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 , Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <0cfb3c69ba6ca9ff55e1fc2528d18d108416ba57.1660897864.git.remckee0@gmail.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <0cfb3c69ba6ca9ff55e1fc2528d18d108416ba57.1660897864.git.remckee0@gmail.com> 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; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IJLA3aDi; spf=pass (imf26.hostedemail.com: domain of david@redhat.com designates 170.10.129.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=1661858281; a=rsa-sha256; cv=none; b=FaAStyeiiTzgdJNrRvpJccZblRnCNzvtt/1tejw2WDV+vTOgsJ2ccFU0GLvhkZWpNOpSwy /LgMnW/DrOm3mW1GA11xQf7DSUV4NF/qsQpsYLqqjQG8Pa6t9Rn89sefJtb2JJ+w9yoDD+ 7QM5Dz2+Ik8QmkROg5r2WpUkPdScsmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661858281; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=ZxmNIacuuwOoWBsLtTJD3DQdhsimDAChe/PhEh+YcZI=; b=LvtfrVz2169HVlE73D1Tu5GPfe7wN3cFFrCTLsohop39OLMIDtXPiUmlWCix77H8YAujbf SUyDCILOHu7R88bVlH5w/EvWE/UcpmIkq8TP9bs4aq87pWhFV17vVV8htIgmjt4vs9GtfU 7gQbvvxgdg+3VyVDVNqCMXiy8iyEeQI= X-Rspam-User: X-Stat-Signature: a4qctty1tbbxb9tbawufugerdou3gydy X-Rspamd-Queue-Id: AC495140018 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IJLA3aDi; spf=pass (imf26.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam07 X-HE-Tag: 1661858280-654610 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 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? -- Thanks, David / dhildenb