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 6AC9BECAAD5 for ; Tue, 6 Sep 2022 13:17:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E51A480285; Tue, 6 Sep 2022 09:17:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E01AA80224; Tue, 6 Sep 2022 09:17:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA23480285; Tue, 6 Sep 2022 09:17:52 -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 BA8FD80224 for ; Tue, 6 Sep 2022 09:17:52 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3EA77811B7 for ; Tue, 6 Sep 2022 13:17:52 +0000 (UTC) X-FDA: 79881713184.02.68F0164 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id B347C180072 for ; Tue, 6 Sep 2022 13:17:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662470270; 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=GjwOR0IwFj7/RGmX3t8tdGBhDDX1U7Y1rtGQK453L9s=; b=CGKn6PODg0oQQ2L16NP2IM+glRznswsVPVUq7J/c5OE98k0AUeW0JdMtzzmsCFIbsTYSB6 zPoaoSJYCpVy/D5Adtihx1550YxfgYwPW5Brox2eVpJYIMd61ZzVS9saxxP2zsiU9q8pRy CYO4llNxrcXnIoCXw4Y+QtwTZMKWl48= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-31-Ah90iA20M-OHm6yFAmhbww-1; Tue, 06 Sep 2022 09:17:49 -0400 X-MC-Unique: Ah90iA20M-OHm6yFAmhbww-1 Received: by mail-wm1-f72.google.com with SMTP id q16-20020a1cf310000000b003a626026ed1so2097161wmq.4 for ; Tue, 06 Sep 2022 06:17:48 -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:subject:organization:from :references:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=GjwOR0IwFj7/RGmX3t8tdGBhDDX1U7Y1rtGQK453L9s=; b=ogTEfQypNyNa+TXTtcgrl2R2hak6cUsyjEBsLFepRFhxn4VGhk1ttv/n2SLxlTFsIi ueIrYBCUA4Jw+rO8uJeqDTgn8JkgSr5JVcKvJCi5Egr8/RV4i2QErKVBFYRUcDK4tEBG r/yTA+3LwHpUThUPxUhpzWqDN9JmhRsHZmufTiSzS5ueWbMdewubNU/EL21AYsW42wGc Tu01pMOmkHmZRf8G7f+zkcwBaNAOI26JmXpnSAdkmxN8lkhS9SokACqYGoK1gatMb23L aNBvRzrzPFzCEHwdcI5BiAXG/KB85GIG7wS+tNhKUNEAjCJUZPuhYXJ+JIUlrsZxE6Rp X8tg== X-Gm-Message-State: ACgBeo1rkIicdU9fj8Cfn2hzRdSSdBgotL2VpIMiVKRDFnTidySUmLhH cKBN2Lxip40nsPihKUljJEeqDipaW55fXXCA6Ydqvj7kCB1hg9INwcGbmWXujTs8mqXzkG4RrlP iwezRQt1vRTo= X-Received: by 2002:a5d:62d0:0:b0:228:d6ee:9bf4 with SMTP id o16-20020a5d62d0000000b00228d6ee9bf4mr2376974wrv.34.1662470267886; Tue, 06 Sep 2022 06:17:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR60faROv7NXDWQZSAZ3esquhwyEQlDW0rmfE16kWqyRI1dSjiveaH/zBuliIdeF9eC3CgbQVw== X-Received: by 2002:a5d:62d0:0:b0:228:d6ee:9bf4 with SMTP id o16-20020a5d62d0000000b00228d6ee9bf4mr2376951wrv.34.1662470267511; Tue, 06 Sep 2022 06:17:47 -0700 (PDT) Received: from ?IPV6:2003:d8:2f0d:ba00:c951:31d7:b2b0:8ba0? (p200300d82f0dba00c95131d7b2b08ba0.dip0.t-ipconnect.de. [2003:d8:2f0d:ba00:c951:31d7:b2b0:8ba0]) by smtp.gmail.com with ESMTPSA id j17-20020a05600c411100b003a6896feef7sm14104782wmi.39.2022.09.06.06.17.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Sep 2022 06:17:46 -0700 (PDT) Message-ID: Date: Tue, 6 Sep 2022 15:17:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 To: Rebecca Mckeever , Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <49b96ce88dece5b394d5dd4332c1572da917b30a.1662264560.git.remckee0@gmail.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v4 1/4] memblock tests: add simulation of physical memory with multiple NUMA nodes In-Reply-To: <49b96ce88dece5b394d5dd4332c1572da917b30a.1662264560.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; format=flowed Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662470271; a=rsa-sha256; cv=none; b=WWCVvv3YCkztYH26SgEd8vvtdl5gXY+knW99FomhQFYYK91g9ymVsNwblIWDx+qVs/Osvp B+8t4Vd8HtQlxzuHrVOBKDsmNgzKay7rtlAcD4j96Ueo9fTSGXTuO4YL1V/Dk3YXqGh2YY 8C5M+rg6BkcRSx25LOWVix7aXP3CEH4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CGKn6POD; spf=pass (imf16.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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662470271; 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=GjwOR0IwFj7/RGmX3t8tdGBhDDX1U7Y1rtGQK453L9s=; b=XmI9oj1NokS/Ep4toIsHHcSa1HM/k9DnQspsERSPVcTmQ9/AdoHu9df9L41kzfWK+XdwCU I+gMLNwFh8LET3KPT8SOjjAluBtIWBhEC782iHKCj/6kbzd/STP8HKXzCiwaMYMj1uNTVs xDuCUHagkVouKKEM0tMseD0u8s/KdwQ= X-Stat-Signature: 713a85g7kf67iiim7n9x59fobt1h6j1m X-Rspamd-Queue-Id: B347C180072 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CGKn6POD; spf=pass (imf16.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: rspam11 X-Rspam-User: X-HE-Tag: 1662470270-530169 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 04.09.22 06:21, Rebecca Mckeever wrote: > Add function setup_numa_memblock() for setting up a memory layout with > multiple NUMA nodes in a previously allocated dummy physical memory. > This function can be used in place of setup_memblock() in tests that need > to simulate a NUMA system. > > setup_numa_memblock(): > - allows for setting up a memory layout by specifying the fraction of > MEM_SIZE in each node > > 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 | 29 +++++++++++++++++++ > tools/testing/memblock/tests/common.h | 4 ++- > 3 files changed, 33 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..b6110df21b2a 100644 > --- a/tools/testing/memblock/tests/common.c > +++ b/tools/testing/memblock/tests/common.c > @@ -72,6 +72,35 @@ void setup_memblock(void) > fill_memblock(); > } > > +/** > + * setup_numa_memblock: > + * Set up a memory layout with multiple NUMA nodes in a previously allocated > + * dummy physical memory. > + * @nodes: an array containing the denominators of the fractions of MEM_SIZE > + * contained in each node (e.g., if nodes[0] = SZ_8, node 0 will > + * contain 1/8th of MEM_SIZE) > + * > + * The nids will be set to 0 through NUMA_NODES - 1. > + */ > +void setup_numa_memblock(const phys_addr_t nodes[]) > +{ > + 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 < NUMA_NODES; i++) { > + assert(nodes[i] <= MEM_SIZE && nodes[i] > 0); I think it would be even easier to get if this would just be a fraction. E.g., instead of "1/8 * MEM_SIZE" just "1/8". All values have to add up to 1. ... but then we'd have to mess with floats eventually, so I guess this makes it easier to handle these fractions. We could use "int" and simply specify the fraction in percent, like nodes[0] = 50; nodes[1] = 25; nodes[2] = 25; and everything has to add up to 100. > + phys_addr_t size = MEM_SIZE / nodes[i]; Hmmm, assuming a single node with "MEM_SIZE", we would get size=1. Shouldn't this be "size = nodes[i]" ? -- Thanks, David / dhildenb