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 DA61BC369A2 for ; Tue, 8 Apr 2025 13:54:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A76A56B000A; Tue, 8 Apr 2025 09:54:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FF146B000C; Tue, 8 Apr 2025 09:54:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 879A56B0011; Tue, 8 Apr 2025 09:54:23 -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 680DE6B000A for ; Tue, 8 Apr 2025 09:54:23 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AA6B9140F15 for ; Tue, 8 Apr 2025 13:54:24 +0000 (UTC) X-FDA: 83311021248.05.F47F80B Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf05.hostedemail.com (Postfix) with ESMTP id 7335F100007 for ; Tue, 8 Apr 2025 13:54:22 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=r09DITqq; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=H6ybNsAU; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=r09DITqq; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=H6ybNsAU; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf05.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744120462; 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=FLrxEWJYmUgKP6lcHFFafdBuMzOHBtJam10U8q12Uyc=; b=x91tPm8C31pUb+tOVow2lERjU/v+2/ogaB/Efbda2T4Vh+aONobv/XxePsOdneFHvDu8fr 2NjrYDTBtV/zw62OClV3Ph1Rq9xrsL70ie6qsFmi7R/37Ucm3bdghI+qTFVyxGUpv2Tx2U HNzkV3dJgmnw4c8rDtKLsyHce6Y4B9E= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=r09DITqq; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=H6ybNsAU; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=r09DITqq; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=H6ybNsAU; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf05.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744120462; a=rsa-sha256; cv=none; b=o7Gbkc4lU8CMLqG2LyVSLnIhQ5VMQHnno4IOcglMgjpoXQD91GUqRitQ3U0RGz5iK+oRq/ 4N2uMvLnz8UfToeGMi4reQlq5ZzheN4Oy0YIML2n+ImaNBr5lJGTgasaJwTg7NUMB9HlsS GKR9hdB3Y+VPKkgMJH31W0NWR0l8Wr8= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D6CBB1F38D; Tue, 8 Apr 2025 13:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1744120460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FLrxEWJYmUgKP6lcHFFafdBuMzOHBtJam10U8q12Uyc=; b=r09DITqqwNvvUMrEU5Lgdovl0t6CpkDfKrBUME429WRLnvQet5FovLv0yp/f0ZgBJYfeeW Gk7a5/qKRwY9DKQHBDJY+3XKprDhXGoJwI6bVpU1jV7lKM2ZyJdMMu5ImEug4HLIVZkWBW 2UqTC53JPJfetM+3tGOLQJ95V0FBrG0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1744120460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FLrxEWJYmUgKP6lcHFFafdBuMzOHBtJam10U8q12Uyc=; b=H6ybNsAUXX5tJhgIi4hdB7G4KAp+Rhh6Dpf5CfqvJ6t4G/cAL/l507E0rKE1HW6nCLoU22 NWmcmKNPnX9cWEBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1744120460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FLrxEWJYmUgKP6lcHFFafdBuMzOHBtJam10U8q12Uyc=; b=r09DITqqwNvvUMrEU5Lgdovl0t6CpkDfKrBUME429WRLnvQet5FovLv0yp/f0ZgBJYfeeW Gk7a5/qKRwY9DKQHBDJY+3XKprDhXGoJwI6bVpU1jV7lKM2ZyJdMMu5ImEug4HLIVZkWBW 2UqTC53JPJfetM+3tGOLQJ95V0FBrG0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1744120460; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FLrxEWJYmUgKP6lcHFFafdBuMzOHBtJam10U8q12Uyc=; b=H6ybNsAUXX5tJhgIi4hdB7G4KAp+Rhh6Dpf5CfqvJ6t4G/cAL/l507E0rKE1HW6nCLoU22 NWmcmKNPnX9cWEBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6D13313A1E; Tue, 8 Apr 2025 13:54:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Zuf6F4wq9Wd4OwAAD6G6ig (envelope-from ); Tue, 08 Apr 2025 13:54:20 +0000 Date: Tue, 8 Apr 2025 15:54:18 +0200 From: Oscar Salvador To: Frank van der Linden Cc: akpm@linux-foundation.org, muchun.song@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, david@redhat.com, luizcap@redhat.com Subject: Re: [PATCH] mm/hugetlb: use separate nodemask for bootmem allocations Message-ID: References: <20250402205613.3086864-1-fvdl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250402205613.3086864-1-fvdl@google.com> X-Rspamd-Action: no action X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 7335F100007 X-Stat-Signature: 91ar599nztmirpi1a8eozoaq8xqyownz X-Rspam-User: X-HE-Tag: 1744120462-806515 X-HE-Meta: U2FsdGVkX18iS7Ua60fcaBR0TQ+NsTd7nltfsl9aVgROEzaZ+lkuVD93L2v4fwJDjZiqE0z12DRPqi+As4gxOSlyoJobGw7/dfm5ARZ+vZe6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jLY0U8EPONS2ci6zfaIyeXHWgobixpOkzsczx5Id8+NOjjuZ+0n3bztiKNN/1BV5aOlsSInRnrso4= 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: List-Subscribe: List-Unsubscribe: On Wed, Apr 02, 2025 at 08:56:13PM +0000, Frank van der Linden wrote: > Hugetlb boot allocation has used online nodes for allocation since > commit de55996d7188 ("mm/hugetlb: use online nodes for bootmem > allocation"). This was needed to be able to do the allocations > earlier in boot, before N_MEMORY was set. > > This might lead to a different distribution of gigantic hugepages > across NUMA nodes if there are memoryless nodes in the system. > > What happens is that the memoryless nodes are tried, but then > the memblock allocation fails and falls back, which usually means > that the node that has the highest physical address available > will be used (top-down allocation). While this will end up > getting the same number of hugetlb pages, they might not be > be distributed the same way. The fallback for each memoryless > node might not end up coming from the same node as the > successful round-robin allocation from N_MEMORY nodes. > > While administrators that rely on having a specific number of > hugepages per node should use the hugepages=N:X syntax, it's > better not to change the old behavior for the plain hugepages=N > case. > > To do this, construct a nodemask for hugetlb bootmem purposes > only, containing nodes that have memory. Then use that > for round-robin bootmem allocations. > > This saves some cycles, and the added advantage here is that > hugetlb_cma can use it too, avoiding the older issue of > pointless attempts to create a CMA area for memoryless nodes > (which will also cause the per-node CMA area size to be too > small). Hi Frank, Makes sense. There something I do not quite understand though > @@ -5012,7 +5039,6 @@ void __init hugetlb_bootmem_alloc(void) > > for_each_hstate(h) { > h->next_nid_to_alloc = first_online_node; > - h->next_nid_to_free = first_online_node; Why are you unsetting next_nid_to_free? I guess it is because we do not use it during boot time and you already set it to first_memory_node further down the road in hugetlb_init_hstates. And the reason you are leaving next_nid_to_alloc set is to see if there is any chance that first_online_node is part of hugetlb_bootmem_nodes? -- Oscar Salvador SUSE Labs