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 24B09ECAAD4 for ; Wed, 31 Aug 2022 15:15:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 691268D0002; Wed, 31 Aug 2022 11:15:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 640A68D0001; Wed, 31 Aug 2022 11:15:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 508588D0002; Wed, 31 Aug 2022 11:15:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3DA198D0001 for ; Wed, 31 Aug 2022 11:15:57 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 180021406EF for ; Wed, 31 Aug 2022 15:15:57 +0000 (UTC) X-FDA: 79860237954.30.687D15D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id A51BB1C0054 for ; Wed, 31 Aug 2022 15:15:56 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ECDE060E07; Wed, 31 Aug 2022 15:15:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CED7BC433D6; Wed, 31 Aug 2022 15:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661958955; bh=R7EXO46M5qFjicJi09WHTFPA6AYwOQpIYMdt1O//+is=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=o7d+iH2Jp76tnUZZGZp3y/mCdP/BiWmflvKS3gpSbmCixTlU6JB5bqnoGhzIxyidD 9V+fTsZPtR/2ToNv8QUi3bkRbT4wVlJwvcv0H1qv0on/gTLgc+bsxtgRFt6DDUuGQ8 W3b3Ir2JGMVSACG/ClcYLL62Kz0xh1hfY9CPKAMvKr6iPJBUqpZXEvGbuTWN1JbWq2 roanbd7pZkUtIoa3+37iP0a14uunDZQ876Zw97wa/R6aqeR2lfTRIhSrQJArL/BnxN DVPNKl2jIifkZMmYEyAfxuoFbCqmwFtP7nYNRcO/MQZRHUxa3fp7ZFzrJcl5Avuat8 Lqy3xEUurPBtw== Date: Wed, 31 Aug 2022 18:15:41 +0300 From: Mike Rapoport To: Rebecca Mckeever Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, David Hildenbrand Subject: Re: [PATCH v2 1/4] memblock tests: add simulation of physical memory with multiple NUMA nodes Message-ID: References: <0cfb3c69ba6ca9ff55e1fc2528d18d108416ba57.1660897864.git.remckee0@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0cfb3c69ba6ca9ff55e1fc2528d18d108416ba57.1660897864.git.remckee0@gmail.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661958956; a=rsa-sha256; cv=none; b=JrdHXrGBP9syJme5pxdpOyjcHX4ZMc9HdWOOY3JfCZ/y5Xz3rJmGZzKcwNbEcR3YxA+rfQ TtF3FwycmDOh6AFPatWrdjPpGcfHJoOsc9mRLsEpguv5fll20j5kz2E6r/moSwlPOOFXVl LU9OPxRnzLLFZmxbvgr3V3WlNM7+1Uc= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=o7d+iH2J; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661958956; 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=CXxzweXLnxGhRbY6PP1vct+ZO64nNLswNCY0zf1APfg=; b=B7ZSq2PjnyOskHJekAfXq67WtqOOaSY7QF0pdy6ngHH3l3GP6RXjy1ePY6JOluDDFuG5M0 DuRjcTiuoClSQc5NOhiHD7NwaY7imuIJxE2NUvOncv0MqmIsbKoXAN+RVu+X7ugDTkEou4 WthO+FivRhv+Qh80naK+YRwoHs7x+NQ= X-Rspamd-Queue-Id: A51BB1C0054 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=o7d+iH2J; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: 8bherd49fspkn1qncchcnmwoj4cw5mgi X-HE-Tag: 1661958956-213392 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 Fri, Aug 19, 2022 at 02:05:31AM -0700, 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(-) ... > +/** > + * 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) I only had time for a quick look and it seems this function is never used on its own. Let's fold it into setup_numa_memblock() for now. > +{ > + 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]; > + > + memblock_add_node(base, size, i, flags); > + base += size; > + } > + fill_memblock(); > +} > + > +void setup_numa_memblock(void) > +{ > + setup_numa_memblock_generic(node_sizes, NUMA_NODES, MEM_FACTOR); > +} > + -- Sincerely yours, Mike.