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 1542CECAAD3 for ; Fri, 9 Sep 2022 11:41:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A21D88D0003; Fri, 9 Sep 2022 07:41:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D1258D0002; Fri, 9 Sep 2022 07:41:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 899998D0003; Fri, 9 Sep 2022 07:41:31 -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 7BF868D0002 for ; Fri, 9 Sep 2022 07:41:31 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5702B16139C for ; Fri, 9 Sep 2022 11:41:31 +0000 (UTC) X-FDA: 79892356782.22.40847B9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id E8AB71C0078 for ; Fri, 9 Sep 2022 11:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662723690; 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=M8m4RqaV+L7PjYgd4q6CvYkN7poUl5+DQqxJTHjxeEs=; b=EUXP/bTVQx6IR4nMQsPM/LHbz4SNFHq0fiUpQdp8DmM2Qhzq9Ah0DDiD5kplyjuTaa5wUH StGDQFeqb0OC2OE8+ujhbcbekppcN1Ry12CoXmttdr5BwmgfM72dJ6TCmJHLgXg2qK/85Y RPSGLDip+u+/x8MjPkqaL/qS/OT8JQM= 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-622-R1ELYl-RMeuE9t8CffHZgg-1; Fri, 09 Sep 2022 07:41:29 -0400 X-MC-Unique: R1ELYl-RMeuE9t8CffHZgg-1 Received: by mail-wm1-f71.google.com with SMTP id f7-20020a1c6a07000000b003a60ede816cso425375wmc.0 for ; Fri, 09 Sep 2022 04:41:29 -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:subject:date; bh=M8m4RqaV+L7PjYgd4q6CvYkN7poUl5+DQqxJTHjxeEs=; b=o0fAP4veg5jglvf4/3Bf84qUYU7NbnqeuMQRtKDErFEoCie/9QasduBtTU9/HEAqod kP5N6WqjpvANhN7D4CJBqIZV0Xnba7jFTNo6zWYTUw5pqSUj3V4rbJ+DXN8Xv+ignJ8f dC3MX6mq1w/i0klC+zGXSb256DymDbW7K8FlSUh8MXjrLFWVAVeEwtix3rCEkNDlPqtH RjxWi6tVNOt8tAfaHDwlCXmrF+tTzAmU107Fh2kpOe2Tn+KPHNnWEulGB/hMhqP/jt3m /kvoofkUBfJRSWIWOpYw0cYiWiK5Y7j6Msx2+pO3e9K/HXy2QXF9b4K7M9JQuU0uawoF qpvw== X-Gm-Message-State: ACgBeo2JgB+PQunL8Qbs0T70dUqmOLhISOiN4Q098ImIsAv6ck96m9TQ W82RQ3227RQbLR+v0EzlIDpbZgkLVieq3AeedKTZlAfRTDYuVyBc6m6UoDVk1JRkybuKePuJsNo iO6+Hmk7Xp5w= X-Received: by 2002:a05:600c:1552:b0:3a8:4523:d16 with SMTP id f18-20020a05600c155200b003a845230d16mr5144681wmg.200.1662723688107; Fri, 09 Sep 2022 04:41:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR6D0OWtKFY9E+O9vhBGqmrlOCmpkAqx5UZk5i7PfdubsvBswpnlbG93P0Gct9xrBqincvnZ6A== X-Received: by 2002:a05:600c:1552:b0:3a8:4523:d16 with SMTP id f18-20020a05600c155200b003a845230d16mr5144667wmg.200.1662723687858; Fri, 09 Sep 2022 04:41:27 -0700 (PDT) Received: from ?IPV6:2003:cb:c704:6300:1fe0:42e1:62c5:91b6? (p200300cbc70463001fe042e162c591b6.dip0.t-ipconnect.de. [2003:cb:c704:6300:1fe0:42e1:62c5:91b6]) by smtp.gmail.com with ESMTPSA id c8-20020a05600c0a4800b003a62052053csm658225wmq.18.2022.09.09.04.41.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Sep 2022 04:41:27 -0700 (PDT) Message-ID: <63cbc594-14cb-b5c3-485b-5c784315b04b@redhat.com> Date: Fri, 9 Sep 2022 13:41:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH v5 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: <5ac0e2f8d6b6cb985e2d6f308edeec2b699ecbea.1662698159.git.remckee0@gmail.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <5ac0e2f8d6b6cb985e2d6f308edeec2b699ecbea.1662698159.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=1662723691; a=rsa-sha256; cv=none; b=LHo0/kRO+He4XsZxjPbftpD74+8tSJ2RbO19b7o6S4bQKOphOlt2aKSSpawIYuT08tauWd TjTsRKnHsRVwB6ww2GoUmKGf4IzTr2j/IdzEx7R7YKw2ro/ROxnSaJqWnXZHrGzxnyxXXw gz2z2E7crbfimnEC6THFXO3HDPrcoD8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="EUXP/bTV"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662723691; 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=M8m4RqaV+L7PjYgd4q6CvYkN7poUl5+DQqxJTHjxeEs=; b=59b4SGqFewoMpC6NQfRLs5wyC6sQSlPTYwqly54H5sr9gUu3Q5GPZMjUwYT6KGCc+qf+nP 6mJqiBhNC4Jx7gpvc1M7ppq7COGBMSUiTEOupaVSksIvVLyOYMKDAPQDpaMO4tacSaDUzk eV21JVVWtopHnrShZdcZwjrDtRRoLJQ= X-Stat-Signature: 9hys85xcked3sbcfenhsnkuwc6mer4ck X-Rspamd-Queue-Id: E8AB71C0078 X-Rspam-User: Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="EUXP/bTV"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam02 X-HE-Tag: 1662723690-446377 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 09.09.22 06:46, 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 | 31 +++++++++++++++++++ > tools/testing/memblock/tests/common.h | 4 ++- > 3 files changed, 35 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..9d9ad7df298b 100644 > --- a/tools/testing/memblock/tests/common.c > +++ b/tools/testing/memblock/tests/common.c > @@ -9,6 +9,7 @@ > #define INIT_MEMBLOCK_RESERVED_REGIONS INIT_MEMBLOCK_REGIONS > #define PREFIXES_MAX 15 > #define DELIM ": " > +#define BASIS 10000 > > static struct test_memory memory_block; > static const char __maybe_unused *prefixes[PREFIXES_MAX]; > @@ -72,6 +73,36 @@ 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. > + * @node_fracs: an array representing the fraction of MEM_SIZE contained in > + * each node in basis point units (one hundredth of 1% or 1/10000). > + * For example, if node 0 should contain 1/8 of MEM_SIZE, > + * node_fracs[0] = 1250. > + * > + * The nids will be set to 0 through NUMA_NODES - 1. > + */ > +void setup_numa_memblock(const int node_fracs[]) If you make it an unsigned int ... > +{ > + 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(node_fracs[i] <= BASIS && node_fracs[i] > 0); You can drop the latter assertion. Thanks! Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb