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 5626FC7EE30 for ; Tue, 1 Jul 2025 18:52:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D84138D0003; Tue, 1 Jul 2025 14:52:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D344B8D0001; Tue, 1 Jul 2025 14:52:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C235B8D0003; Tue, 1 Jul 2025 14:52:57 -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 B2B998D0001 for ; Tue, 1 Jul 2025 14:52:57 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4FCDE1D8373 for ; Tue, 1 Jul 2025 18:52:57 +0000 (UTC) X-FDA: 83616592794.21.2EB93A3 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf17.hostedemail.com (Postfix) with ESMTP id EBF034000E for ; Tue, 1 Jul 2025 18:52:54 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=jaIQuJid; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=kRN+p+Dm; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=WyxVuUtd; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=WA5IzkR8; spf=pass (imf17.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751395975; 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=4IDDEwwLc66TFLTdRypmAMmtEWcDAqTm7+W0Z7NtUns=; b=MoRf8k7q272O6q14xS7QJkBjvDiq7H439OVQXv6RsZDIq98IM7DpJyoxql4dFBgSYlz3vd Dp4L3siWX6HCU1ySk93tT+HpgqywAIXJt8dZcJ20khJyYpiBhA6VSdIx7RZWkxHmV3ebLO GP+1HaXiFMt91RH1NW78tcpeLzWddZ0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751395975; a=rsa-sha256; cv=none; b=d3yEsp7wkYe/w4nZT09hG1cKZOcFNbEwZOCiCjov/Ip50oxz7ys/L7L0t6fQd8z80SmhbR EzfxjN2+a2hIvLGuOKhWixqt1ba9lln/8h8FInVmowrM314TfmLSSmSCx55pcFr1O4KAzx T/t3j+b9TzDsoZusp1nSvwqi6Ofy5ow= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=jaIQuJid; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=kRN+p+Dm; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=WyxVuUtd; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=WA5IzkR8; spf=pass (imf17.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de Received: from imap1.dmz-prg2.suse.org (unknown [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 291E41F445; Tue, 1 Jul 2025 18:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1751395973; 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=4IDDEwwLc66TFLTdRypmAMmtEWcDAqTm7+W0Z7NtUns=; b=jaIQuJidIaqbKVMtKe5bKR7bpp8EG7h9HRNMXqQR3bcncgevGLnoorXrAIVg81kiaZegGx CEHUvW1w5vtgVfMNK1mYectGfpctQ34fo1JT49KtIJzNOGgV2gwE5ololk7Gd9fh4sHAz6 BZQoSrFwe25o8wJm310X4v8hLZ1sw84= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1751395973; 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=4IDDEwwLc66TFLTdRypmAMmtEWcDAqTm7+W0Z7NtUns=; b=kRN+p+DmJZrTjpN5O2y3MKVIxWCHyiuQEla0nNMbH6/PM23SulzPjkXos8b29JegzUlEyz Eu8k+zGlTU9dPKAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1751395972; 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=4IDDEwwLc66TFLTdRypmAMmtEWcDAqTm7+W0Z7NtUns=; b=WyxVuUtd7DdkNwgbuEfxcJo4XytCN38kfpmOLtE/k8NVDIGEZQb+wjnUeU32UcyRhqN6jh CsJ2SayWyiEGgCmJmSnAtYnO23uKoaXTJvws2qOa7uGH5ZstPDm/sMqeYqikwwvfZLydeT B19UYMA1mloKKadEXQmRth+Nx17eSPA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1751395972; 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=4IDDEwwLc66TFLTdRypmAMmtEWcDAqTm7+W0Z7NtUns=; b=WA5IzkR8GfqtoX+oUkOE7jflUh0S9euii/8sB+yh/pBYy07azsn6L+6v706i5xdhsnNxvC b3CNgEve9flltBDQ== 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 E2CE913A71; Tue, 1 Jul 2025 18:52:51 +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 R+7RNIMuZGjVXAAAD6G6ig (envelope-from ); Tue, 01 Jul 2025 18:52:51 +0000 Date: Tue, 1 Jul 2025 20:52:50 +0200 From: Oscar Salvador To: Hannes Reinecke Cc: David Hildenbrand , linux-mm@kvack.org Subject: Re: [PATCH 2/2] mm/memory_hotplug: activate node before adding new memory blocks Message-ID: References: <20250701114155.16452-1-hare@kernel.org> <20250701114155.16452-3-hare@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EBF034000E X-Stat-Signature: 5c8pocmsgk3btjturk7m7nbg5rkk69bi X-HE-Tag: 1751395974-965087 X-HE-Meta: U2FsdGVkX19edCMyfBz2emF4qCqs/lCj01MFoq2L0b0wXqPuiXYxXT1eZ+xPKBt6m4fvW8uR3CMRoaZoB3cLRLCEUzESVJcz4AGXHrruxO3jaTYqIICINUHxeJsvkPfcRsXemz/6yicvqGlluXuhyyIIHVAZsp2ZWpOUWhsAxEhDU3pyf0Hvp9OrkmlgZPFBJF01u/Y59pVY3VxyzFwVnpKCwFleQ6kbWW223MRIMH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/PZtFuSxAD+1Z1Hy4N+YcVCF4hZCBAjGn7JbefGUOK+oATcuaVfXy5mu5o4OP/jfJJ5um3P0SchXpihaw0G8GIg//Z+lIDkh4= 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 Tue, Jul 01, 2025 at 04:02:08PM +0200, Oscar Salvador wrote: > On Tue, Jul 01, 2025 at 01:41:54PM +0200, Hannes Reinecke wrote: > > @@ -1540,8 +1540,16 @@ int add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) > > > > ret = __try_online_node(nid, false); > > if (ret < 0) > > - goto error; > > - new_node = ret; > > + goto error_memblock_remove; > > + if (ret) { > > + node_set_online(nid); > > + ret = __register_one_node(nid); > > + if (WARN_ON(ret)) { > > + node_set_offline(nid); > > + goto error_memblock_remove; > > + } > > + new_node = true; > > + } > > Do we have any constraints wrt. having the node onlined before calling in > __register_one_node() ? > This is a sensitive path (convulated :-) heh), but unless I'm missing anything, > it should be ok to call node_set_online after, right? Ok, can you rebase this on top of mm-new? Because of you do, you'll see that we no longer call __register_one_node, as this was replaced with register_one_node. commit 6d166dec7451cab8782a08b85910685d930750e9 Author: Donet Tom Date: Wed May 28 12:18:04 2025 -0500 drivers/base/node: rename __register_one_node() to register_one_node() Now, with that in mind, we could do: diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 62d45752f9f4..9e0ade195a5f 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1537,10 +1537,9 @@ int add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) goto error_mem_hotplug_end; } - ret = __try_online_node(nid, false); + ret = __try_online_node(nid, true); if (ret < 0) goto error; - new_node = ret; /* * Self hosted memmap array @@ -1563,17 +1562,6 @@ int add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) } } - if (new_node) { - /* If sysfs file of new node can't be created, cpu on the node - * can't be hot-added. There is no rollback way now. - * So, check by BUG_ON() to catch it reluctantly.. - * We online node here. We can't roll back from here. - */ - node_set_online(nid); - ret = register_one_node(nid); - BUG_ON(ret); - } - register_memory_blocks_under_node_hotplug(nid, PFN_DOWN(start), PFN_UP(start + size - 1)); Note that this would be incomplete, as we have to know whether we fail before we onlined the node, but the thing is that this chunk in __try_online_node(): <----- pgdat = hotadd_init_pgdat(nid); if (!pgdat) { pr_err("Cannot online node %d due to NULL pgdat\n", nid); ret = -ENOMEM; goto out; } -----> Cannot be longer be triggered since: commit 09f49dca570a917a8c6bccd7e8c61f5141534e3a Author: Michal Hocko Date: Tue Mar 22 14:46:54 2022 -0700 mm: handle uninitialized numa nodes gracefully as we initialize all __possible__ numa nodes. With that in mind, you'll have it easier as you can drop that, and then the function becomes Ret values 0: node already onlined 1: node onlined -err: register_one_node failed. -- Oscar Salvador SUSE Labs