From nobody Fri Dec 19 19:20:12 2025 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89CDB320F for ; Thu, 5 Jun 2025 14:23:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133399; cv=none; b=bsPIauyPAcSYLMVT7UMpoCg/FtpTlxdLHneK3FDkLdnBJ+156WKpK9AP3c7+Q5DZO35Fb6GiDXq0bZz1QEQ54N1aNvrpqZyBIYKjqtkxBLNSxr7RVp8szsLE8E0w4B7H+PwxYK4yzO8Bn+vaF/UP+0Hf6ZDVe2g4gDliINXaS4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133399; c=relaxed/simple; bh=6R9Ss4KQG7e6j2i/RejfHECkSDU5rzGoQQKl19n6nBs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tH4jactNHO82EDEIBVXkfK0DGgElvRqnuaKYJcRX+VyHGg4Sdz3NVvsr1ZNE9pps+z2+RWrmMswYXeSAg95Z2f1yFiERDIwNTxeCbbML3DMYaglv8mJWYRUzyYQBBXn+aiuz5aKUFwz8KOSoGdT4NrkJyGoqdB+sEdJi/atqsLU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=MzPmhZd1; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=bjpgOHRB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=MzPmhZd1; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=bjpgOHRB; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="MzPmhZd1"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="bjpgOHRB"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="MzPmhZd1"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="bjpgOHRB" 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-out1.suse.de (Postfix) with ESMTPS id 9BC72337D0; Thu, 5 Jun 2025 14:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1749133395; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oPo5dP2xx4yCEpwtQyV+S69pInSlZfneHcEHHsBK/5o=; b=MzPmhZd1gsuaSsw+0A6rfxBhQX5ih9ATnrWanvzcdicTib5NebXGNvIiuCdiBSvF4WLgR7 WSrodURmdQ6847M1xg81H6+KPFgKtSxsx+l+xhWjCnDMthYkLgRH/N0qAx+H7KSOq2sPoQ JTAeSzFHZXCBaQYqxeXh/0bAJNKCBXI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1749133395; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oPo5dP2xx4yCEpwtQyV+S69pInSlZfneHcEHHsBK/5o=; b=bjpgOHRBiGV4Ex0Rlb4pKwv2nkuHI3mrgwx+QRtVgU+dt0lv7KUaTqVsjX3rLAS0mgfFA7 2mlRxR+Lm+WGCwCA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1749133395; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oPo5dP2xx4yCEpwtQyV+S69pInSlZfneHcEHHsBK/5o=; b=MzPmhZd1gsuaSsw+0A6rfxBhQX5ih9ATnrWanvzcdicTib5NebXGNvIiuCdiBSvF4WLgR7 WSrodURmdQ6847M1xg81H6+KPFgKtSxsx+l+xhWjCnDMthYkLgRH/N0qAx+H7KSOq2sPoQ JTAeSzFHZXCBaQYqxeXh/0bAJNKCBXI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1749133395; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oPo5dP2xx4yCEpwtQyV+S69pInSlZfneHcEHHsBK/5o=; b=bjpgOHRBiGV4Ex0Rlb4pKwv2nkuHI3mrgwx+QRtVgU+dt0lv7KUaTqVsjX3rLAS0mgfFA7 2mlRxR+Lm+WGCwCA== 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 0E7F3139CB; Thu, 5 Jun 2025 14:23:15 +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 wHfMAFOoQWipRwAAD6G6ig (envelope-from ); Thu, 05 Jun 2025 14:23:15 +0000 From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Vlastimil Babka , Jonathan Cameron , Harry Yoo , Rakie Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v5 01/10] mm,slub: Do not special case N_NORMAL nodes for slab_nodes Date: Thu, 5 Jun 2025 16:22:52 +0200 Message-ID: <20250605142305.244465-2-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250605142305.244465-1-osalvador@suse.de> References: <20250605142305.244465-1-osalvador@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Spam-Score: -5.30 X-Spamd-Result: default: False [-5.30 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_TLS_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,suse.cz,huawei.com,oracle.com,sk.com,gmail.com,kvack.org,vger.kernel.org,suse.de]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,oracle.com:email,suse.cz:email,suse.de:mid,suse.de:email]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[oracle.com:email,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,suse.cz:email]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Level: Content-Type: text/plain; charset="utf-8" Currently, slab_mem_going_online_callback() checks whether the node has N_NORMAL memory in order to be set in slab_nodes. While it is true that getting rid of that enforcing would mean ending up with movables nodes in slab_nodes, the memory waste that comes with that is negligible. So stop checking for status_change_nid_normal and just use status_change_nid instead which works for both types of memory. Also, once we allocate the kmem_cache_node cache for the node in slab_mem_online_callback(), we never deallocate it in slab_mem_offline_callback() when the node goes memoryless, so we can just get rid of it. The side effects are that we will stop clearing the node from slab_nodes, and also that newly created kmem caches after node hotremove will now alloc= ate their kmem_cache_node for the node(s) that was hotremoved, but these should be negligible. Suggested-by: David Hildenbrand Signed-off-by: Oscar Salvador Reviewed-by: Vlastimil Babka Reviewed-by: Harry Yoo Acked-by: David Hildenbrand --- mm/slub.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index be8b09e09d30..f92b43d36adc 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -447,7 +447,7 @@ static inline struct kmem_cache_node *get_node(struct k= mem_cache *s, int node) =20 /* * Tracks for which NUMA nodes we have kmem_cache_nodes allocated. - * Corresponds to node_state[N_NORMAL_MEMORY], but can temporarily + * Corresponds to node_state[N_MEMORY], but can temporarily * differ during memory hotplug/hotremove operations. * Protected by slab_mutex. */ @@ -6160,36 +6160,12 @@ static int slab_mem_going_offline_callback(void *ar= g) return 0; } =20 -static void slab_mem_offline_callback(void *arg) -{ - struct memory_notify *marg =3D arg; - int offline_node; - - offline_node =3D marg->status_change_nid_normal; - - /* - * If the node still has available memory. we need kmem_cache_node - * for it yet. - */ - if (offline_node < 0) - return; - - mutex_lock(&slab_mutex); - node_clear(offline_node, slab_nodes); - /* - * We no longer free kmem_cache_node structures here, as it would be - * racy with all get_node() users, and infeasible to protect them with - * slab_mutex. - */ - mutex_unlock(&slab_mutex); -} - static int slab_mem_going_online_callback(void *arg) { struct kmem_cache_node *n; struct kmem_cache *s; struct memory_notify *marg =3D arg; - int nid =3D marg->status_change_nid_normal; + int nid =3D marg->status_change_nid; int ret =3D 0; =20 /* @@ -6247,10 +6223,6 @@ static int slab_memory_callback(struct notifier_bloc= k *self, case MEM_GOING_OFFLINE: ret =3D slab_mem_going_offline_callback(arg); break; - case MEM_OFFLINE: - case MEM_CANCEL_ONLINE: - slab_mem_offline_callback(arg); - break; case MEM_ONLINE: case MEM_CANCEL_OFFLINE: break; @@ -6321,7 +6293,7 @@ void __init kmem_cache_init(void) * Initialize the nodemask for which we will allocate per node * structures. Here we don't need taking slab_mutex yet. */ - for_each_node_state(node, N_NORMAL_MEMORY) + for_each_node_state(node, N_MEMORY) node_set(node, slab_nodes); =20 create_boot_cache(kmem_cache_node, "kmem_cache_node", --=20 2.49.0 From nobody Fri Dec 19 19:20:12 2025 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E001617A2F8 for ; Thu, 5 Jun 2025 14:23:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133405; cv=none; b=QM1XbSMLFmw6+5D0aW5IsxkzNUG3b2KZWMGyb+HdJ+wCgWBI6F8VnHzucYZGnucOAu0Xd/GBa2TW/O5uByFDm7pKSL+czCEqis5YyDFawteQkDwOUBZQdcrU8CQYBGCwlW1+J6o1c3rGZ04WOHIIXmbP8l1i2iawR7I0SgkxnIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133405; c=relaxed/simple; bh=pnFV71/YviZ5WPBl34/gOG+1EOlwF3xCHHMZRhWOmq4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BHGWEYHW7ET0/4ZXw8jbtiJSG3xOCeiN6YWgWLo7izyt7BhUZ082SNaONQR17GlZfMjGg7hHozSrfULAFL0hfpAlVA7hP1wvHVvnWWGq3QU3uTPzc/eqJvXhpWdnilbe5ef8WyJFIKJf7j0dw7CkCmqXukxfhhoVvk9Hm9VDzyE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=TIg/cWVZ; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=BEmc0EXF; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=TIg/cWVZ; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=BEmc0EXF; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="TIg/cWVZ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="BEmc0EXF"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="TIg/cWVZ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="BEmc0EXF" 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-out1.suse.de (Postfix) with ESMTPS id 4EABE218D5; Thu, 5 Jun 2025 14:23:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1749133396; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5GT2CYRiAr+9AmbzTZ+VtvFRriYDWDxy/TDg03PmFt0=; b=TIg/cWVZfbbsOi6mQWQAesLErovvbFuIkBT+J/SxUgGxlQakyokC0KibOEmTXoYy6trHQN LHYtpk52rSM9Cl4x4T3lz7oORTFz8Wl/wynN3O+4Eb+1HhfAcdaMRM9t7gZuikOlpdeNZR LJrpUVO2OX0Tl8xbx/R5lFNgukuG6c4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1749133396; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5GT2CYRiAr+9AmbzTZ+VtvFRriYDWDxy/TDg03PmFt0=; b=BEmc0EXFuVmIzTbWsv9mMnoY4fBNWobI/YlZt848YZx9L6XPyGJpPjDeUpguUGmJIeaJUy 7yyujm1ccKSt3SDA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1749133396; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5GT2CYRiAr+9AmbzTZ+VtvFRriYDWDxy/TDg03PmFt0=; b=TIg/cWVZfbbsOi6mQWQAesLErovvbFuIkBT+J/SxUgGxlQakyokC0KibOEmTXoYy6trHQN LHYtpk52rSM9Cl4x4T3lz7oORTFz8Wl/wynN3O+4Eb+1HhfAcdaMRM9t7gZuikOlpdeNZR LJrpUVO2OX0Tl8xbx/R5lFNgukuG6c4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1749133396; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5GT2CYRiAr+9AmbzTZ+VtvFRriYDWDxy/TDg03PmFt0=; b=BEmc0EXFuVmIzTbWsv9mMnoY4fBNWobI/YlZt848YZx9L6XPyGJpPjDeUpguUGmJIeaJUy 7yyujm1ccKSt3SDA== 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 B47B1137FE; Thu, 5 Jun 2025 14:23:15 +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 mEAJKFOoQWipRwAAD6G6ig (envelope-from ); Thu, 05 Jun 2025 14:23:15 +0000 From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Vlastimil Babka , Jonathan Cameron , Harry Yoo , Rakie Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v5 02/10] mm,memory_hotplug: Remove status_change_nid_normal and update documentation Date: Thu, 5 Jun 2025 16:22:53 +0200 Message-ID: <20250605142305.244465-3-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250605142305.244465-1-osalvador@suse.de> References: <20250605142305.244465-1-osalvador@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-5.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; R_RATELIMIT(0.00)[to_ip_from(RLsc83pr41xu6y1i6mw9yajrf5)]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,suse.cz,huawei.com,oracle.com,sk.com,gmail.com,kvack.org,vger.kernel.org,suse.de]; RCPT_COUNT_SEVEN(0.00)[10]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -5.80 Now that the last user of status_change_nid_normal is gone, we can remove i= t. Update documentation accordingly. Signed-off-by: Oscar Salvador Acked-by: David Hildenbrand Reviewed-by: Vlastimil Babka --- Documentation/core-api/memory-hotplug.rst | 3 --- .../translations/zh_CN/core-api/memory-hotplug.rst | 3 --- include/linux/memory.h | 1 - mm/memory_hotplug.c | 12 ------------ 4 files changed, 19 deletions(-) diff --git a/Documentation/core-api/memory-hotplug.rst b/Documentation/core= -api/memory-hotplug.rst index 682259ee633a..d1b8eb9add8a 100644 --- a/Documentation/core-api/memory-hotplug.rst +++ b/Documentation/core-api/memory-hotplug.rst @@ -56,14 +56,11 @@ The third argument (arg) passes a pointer of struct mem= ory_notify:: struct memory_notify { unsigned long start_pfn; unsigned long nr_pages; - int status_change_nid_normal; int status_change_nid; } =20 - start_pfn is start_pfn of online/offline memory. - nr_pages is # of pages of online/offline memory. -- status_change_nid_normal is set node id when N_NORMAL_MEMORY of nodemask - is (will be) set/clear, if this is -1, then nodemask status is not chang= ed. - status_change_nid is set node id when N_MEMORY of nodemask is (will be) set/clear. It means a new(memoryless) node gets new memory by online and= a node loses all memory. If this is -1, then nodemask status is not change= d. diff --git a/Documentation/translations/zh_CN/core-api/memory-hotplug.rst b= /Documentation/translations/zh_CN/core-api/memory-hotplug.rst index 9b2841fb9a5f..c2a4122ae221 100644 --- a/Documentation/translations/zh_CN/core-api/memory-hotplug.rst +++ b/Documentation/translations/zh_CN/core-api/memory-hotplug.rst @@ -62,7 +62,6 @@ memory_notify=E7=BB=93=E6=9E=84=E4=BD=93=E7=9A=84=E6=8C= =87=E9=92=88:: struct memory_notify { unsigned long start_pfn; unsigned long nr_pages; - int status_change_nid_normal; int status_change_nid; } =20 @@ -70,8 +69,6 @@ memory_notify=E7=BB=93=E6=9E=84=E4=BD=93=E7=9A=84=E6=8C= =87=E9=92=88:: =20 - nr_pages=E6=98=AF=E5=9C=A8=E7=BA=BF/=E7=A6=BB=E7=BA=BF=E5=86=85=E5=AD=98= =E7=9A=84=E9=A1=B5=E6=95=B0=E3=80=82 =20 -- status_change_nid_normal=E6=98=AF=E5=BD=93nodemask=E7=9A=84N_NORMAL_MEMO= RY=E8=A2=AB=E8=AE=BE=E7=BD=AE/=E6=B8=85=E9=99=A4=E6=97=B6=E8=AE=BE=E7=BD=AE= =E8=8A=82 - =E7=82=B9id=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=98=AF-1=EF=BC=8C=E5=88=99nodem= ask=E7=8A=B6=E6=80=81=E4=B8=8D=E6=94=B9=E5=8F=98=E3=80=82 =20 - status_change_nid=E6=98=AF=E5=BD=93nodemask=E7=9A=84N_MEMORY=E8=A2=AB=EF= =BC=88=E5=B0=86=EF=BC=89=E8=AE=BE=E7=BD=AE/=E6=B8=85=E9=99=A4=E6=97=B6=E8= =AE=BE=E7=BD=AE=E7=9A=84=E8=8A=82=E7=82=B9id=E3=80=82=E8=BF=99 =E6=84=8F=E5=91=B3=E7=9D=80=E4=B8=80=E4=B8=AA=E6=96=B0=E7=9A=84=EF=BC=88= =E6=B2=A1=E4=B8=8A=E7=BA=BF=E7=9A=84=EF=BC=89=E8=8A=82=E7=82=B9=E9=80=9A=E8= =BF=87=E8=81=94=E6=9C=BA=E8=8E=B7=E5=BE=97=E6=96=B0=E7=9A=84=E5=86=85=E5=AD= =98=EF=BC=8C=E8=80=8C=E4=B8=80=E4=B8=AA=E8=8A=82=E7=82=B9=E5=A4=B1=E5=8E=BB= =E4=BA=86=E6=89=80=E6=9C=89=E7=9A=84=E5=86=85 diff --git a/include/linux/memory.h b/include/linux/memory.h index 5ec4e6d209b9..a9ccd6579422 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -109,7 +109,6 @@ struct memory_notify { unsigned long altmap_nr_pages; unsigned long start_pfn; unsigned long nr_pages; - int status_change_nid_normal; int status_change_nid; }; =20 diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index b1caedbade5b..94ae0ca37021 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -706,19 +706,13 @@ static void node_states_check_changes_online(unsigned= long nr_pages, int nid =3D zone_to_nid(zone); =20 arg->status_change_nid =3D NUMA_NO_NODE; - arg->status_change_nid_normal =3D NUMA_NO_NODE; =20 if (!node_state(nid, N_MEMORY)) arg->status_change_nid =3D nid; - if (zone_idx(zone) <=3D ZONE_NORMAL && !node_state(nid, N_NORMAL_MEMORY)) - arg->status_change_nid_normal =3D nid; } =20 static void node_states_set_node(int node, struct memory_notify *arg) { - if (arg->status_change_nid_normal >=3D 0) - node_set_state(node, N_NORMAL_MEMORY); - if (arg->status_change_nid >=3D 0) node_set_state(node, N_MEMORY); } @@ -1895,7 +1889,6 @@ static void node_states_check_changes_offline(unsigne= d long nr_pages, enum zone_type zt; =20 arg->status_change_nid =3D NUMA_NO_NODE; - arg->status_change_nid_normal =3D NUMA_NO_NODE; =20 /* * Check whether node_states[N_NORMAL_MEMORY] will be changed. @@ -1907,8 +1900,6 @@ static void node_states_check_changes_offline(unsigne= d long nr_pages, */ for (zt =3D 0; zt <=3D ZONE_NORMAL; zt++) present_pages +=3D pgdat->node_zones[zt].present_pages; - if (zone_idx(zone) <=3D ZONE_NORMAL && nr_pages >=3D present_pages) - arg->status_change_nid_normal =3D zone_to_nid(zone); =20 /* * We have accounted the pages from [0..ZONE_NORMAL); ZONE_HIGHMEM @@ -1927,9 +1918,6 @@ static void node_states_check_changes_offline(unsigne= d long nr_pages, =20 static void node_states_clear_node(int node, struct memory_notify *arg) { - if (arg->status_change_nid_normal >=3D 0) - node_clear_state(node, N_NORMAL_MEMORY); - if (arg->status_change_nid >=3D 0) node_clear_state(node, N_MEMORY); } --=20 2.49.0 From nobody Fri Dec 19 19:20:12 2025 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15F2C17A2F8 for ; Thu, 5 Jun 2025 14:23:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133412; cv=none; b=b1SrPIFK8c2IislYF4g+8kLDhYtoxf1EKDW7XqsckAph7vH+D3Adet3WBQQl1Hf2Br3rdBmSXeFN4CV0ajBYwtixOVep+5nTtRVxxqOhMiurSU/cGj4X4gPsuwhPXuPR6RABTGN4JWtWxC/d69HBY8dJU6THd4sznljKuEHsB2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133412; c=relaxed/simple; bh=QS1hx1CnyBo07NfCxHuekt1LeTc0CcPxwRw/4XZvZQk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fPUCH3g8brGELxfBdQ49K6A5ih8azV8GC6xBag9u2re8sVgfhpNOI575AxuCz3Y7UIuwVVF0MNUuMuLLi0GH4cd3kCdyXXBkz/CgIq11BbeTlB32FSA8d6hA6SQY1VBtLMHOj0e+HYL+YQziNT4f8htMPaeSLzmElwWEHS0nDB4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de 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-out1.suse.de (Postfix) with ESMTPS id 0E6E522357; Thu, 5 Jun 2025 14:23:17 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none 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 627A2139CB; Thu, 5 Jun 2025 14:23:16 +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 OFUSFVSoQWipRwAAD6G6ig (envelope-from ); Thu, 05 Jun 2025 14:23:16 +0000 From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Vlastimil Babka , Jonathan Cameron , Harry Yoo , Rakie Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v5 03/10] mm,memory_hotplug: Implement numa node notifier Date: Thu, 5 Jun 2025 16:22:54 +0200 Message-ID: <20250605142305.244465-4-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250605142305.244465-1-osalvador@suse.de> References: <20250605142305.244465-1-osalvador@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spam-Level: X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[]; TAGGED_RCPT(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU] X-Spam-Flag: NO X-Rspamd-Queue-Id: 0E6E522357 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Score: -4.00 Content-Type: text/plain; charset="utf-8" There are at least six consumers of hotplug_memory_notifier that what they really are interested in is whether any numa node changed its state, e.g: g= oing from having memory to not having memory and vice versa. Implement a specific notifier for numa nodes when their state gets changed, which will later be used by those consumers that are only interested in numa node state changes. Add documentation as well. Signed-off-by: Oscar Salvador Reviewed-by: Jonathan Cameron Reviewed-by: Harry Yoo Reviewed-by: Vlastimil Babka --- Documentation/core-api/memory-hotplug.rst | 66 +++++++++ drivers/base/node.c | 21 +++ include/linux/node.h | 42 ++++++ mm/memory_hotplug.c | 155 ++++++++++------------ 4 files changed, 202 insertions(+), 82 deletions(-) diff --git a/Documentation/core-api/memory-hotplug.rst b/Documentation/core= -api/memory-hotplug.rst index d1b8eb9add8a..b19c3be7437d 100644 --- a/Documentation/core-api/memory-hotplug.rst +++ b/Documentation/core-api/memory-hotplug.rst @@ -9,6 +9,9 @@ Memory hotplug event notifier =20 Hotplugging events are sent to a notification queue. =20 +Memory notifier +---------------- + There are six types of notification defined in ``include/linux/memory.h``: =20 MEM_GOING_ONLINE @@ -80,6 +83,69 @@ further processing of the notification queue. =20 NOTIFY_STOP stops further processing of the notification queue. =20 +Numa node notifier +------------------ + +There are six types of notification defined in ``include/linux/node.h``: + +NODE_ADDING_FIRST_MEMORY + Generated before memory becomes available to this node for the first time. + +NODE_CANCEL_ADDING_FIRST_MEMORY + Generated if NODE_ADDING_FIRST_MEMORY fails. + +NODE_ADDED_FIRST_MEMORY + Generated when memory has become available fo this node for the first tim= e. + +NODE_REMOVING_LAST_MEMORY + Generated when the last memory available to this node is about to be offl= ined. + +NODE_CANCEL_REMOVING_LAST_MEMORY + Generated when NODE_CANCEL_REMOVING_LAST_MEMORY fails. + +NODE_REMOVED_LAST_MEMORY + Generated when the last memory available to this node has been offlined. + +A callback routine can be registered by calling:: + + hotplug_node_notifier(callback_func, priority) + +Callback functions with higher values of priority are called before callba= ck +functions with lower values. + +A callback function must have the following prototype:: + + int callback_func( + + struct notifier_block *self, unsigned long action, void *arg); + +The first argument of the callback function (self) is a pointer to the blo= ck +of the notifier chain that points to the callback function itself. +The second argument (action) is one of the event types described above. +The third argument (arg) passes a pointer of struct node_notify:: + + struct node_notify { + int nid; + } + +- nid is the node we are adding or removing memory to. + + If nid >=3D 0, callback should create/discard structures for the + node if necessary. + +The callback routine shall return one of the values +NOTIFY_DONE, NOTIFY_OK, NOTIFY_BAD, NOTIFY_STOP +defined in ``include/linux/notifier.h`` + +NOTIFY_DONE and NOTIFY_OK have no effect on the further processing. + +NOTIFY_BAD is used as response to the NODE_ADDING_FIRST_MEMORY, +NODE_REMOVING_LAST_MEMORY, NODE_ADDED_FIRST_MEMORY or +NODE_REMOVED_LAST_MEMORY action to cancel hotplugging. +It stops further processing of the notification queue. + +NOTIFY_STOP stops further processing of the notification queue. + Locking Internals =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/drivers/base/node.c b/drivers/base/node.c index 25ab9ec14eb8..c5b0859d846d 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -111,6 +111,27 @@ static const struct attribute_group *node_access_node_= groups[] =3D { NULL, }; =20 +#ifdef CONFIG_MEMORY_HOTPLUG +static BLOCKING_NOTIFIER_HEAD(node_chain); + +int register_node_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&node_chain, nb); +} +EXPORT_SYMBOL(register_node_notifier); + +void unregister_node_notifier(struct notifier_block *nb) +{ + blocking_notifier_chain_unregister(&node_chain, nb); +} +EXPORT_SYMBOL(unregister_node_notifier); + +int node_notify(unsigned long val, void *v) +{ + return blocking_notifier_call_chain(&node_chain, val, v); +} +#endif + static void node_remove_accesses(struct node *node) { struct node_access_nodes *c, *cnext; diff --git a/include/linux/node.h b/include/linux/node.h index 2b7517892230..8c783269011d 100644 --- a/include/linux/node.h +++ b/include/linux/node.h @@ -123,6 +123,48 @@ static inline void register_memory_blocks_under_node(i= nt nid, unsigned long star #endif =20 extern void unregister_node(struct node *node); + +#ifdef CONFIG_MEMORY_HOTPLUG +struct node_notify { + int nid; +}; + +#define NODE_ADDING_FIRST_MEMORY (1<<0) +#define NODE_ADDED_FIRST_MEMORY (1<<1) +#define NODE_CANCEL_ADDING_FIRST_MEMORY (1<<2) +#define NODE_REMOVING_LAST_MEMORY (1<<3) +#define NODE_REMOVED_LAST_MEMORY (1<<4) +#define NODE_CANCEL_REMOVING_LAST_MEMORY (1<<5) + +#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_NUMA) +extern int register_node_notifier(struct notifier_block *nb); +extern void unregister_node_notifier(struct notifier_block *nb); +extern int node_notify(unsigned long val, void *v); + +#define hotplug_node_notifier(fn, pri) ({ \ + static __meminitdata struct notifier_block fn##_node_nb =3D\ + { .notifier_call =3D fn, .priority =3D pri };\ + register_node_notifier(&fn##_node_nb); \ +}) +#else +static inline int register_node_notifier(struct notifier_block *nb) +{ + return 0; +} +static inline void unregister_node_notifier(struct notifier_block *nb) +{ +} +static inline int node_notify(unsigned long val, void *v) +{ + return 0; +} +static inline int hotplug_node_notifier(notifier_fn_t fn, int pri) +{ + return 0; +} +#endif +#endif + #ifdef CONFIG_NUMA extern void node_dev_init(void); /* Core of the node registration - only memory hotplug should use this */ diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 94ae0ca37021..0550f3061fc4 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -35,6 +35,7 @@ #include #include #include +#include =20 #include =20 @@ -699,24 +700,6 @@ static void online_pages_range(unsigned long start_pfn= , unsigned long nr_pages) online_mem_sections(start_pfn, end_pfn); } =20 -/* check which state of node_states will be changed when online memory */ -static void node_states_check_changes_online(unsigned long nr_pages, - struct zone *zone, struct memory_notify *arg) -{ - int nid =3D zone_to_nid(zone); - - arg->status_change_nid =3D NUMA_NO_NODE; - - if (!node_state(nid, N_MEMORY)) - arg->status_change_nid =3D nid; -} - -static void node_states_set_node(int node, struct memory_notify *arg) -{ - if (arg->status_change_nid >=3D 0) - node_set_state(node, N_MEMORY); -} - static void __meminit resize_zone_range(struct zone *zone, unsigned long s= tart_pfn, unsigned long nr_pages) { @@ -1171,7 +1154,9 @@ int online_pages(unsigned long pfn, unsigned long nr_= pages, int need_zonelists_rebuild =3D 0; const int nid =3D zone_to_nid(zone); int ret; - struct memory_notify arg; + struct memory_notify mem_arg; + struct node_notify node_arg; + bool cancel_mem_notifier_on_err =3D false, cancel_node_notifier_on_err = =3D false; =20 /* * {on,off}lining is constrained to full memory sections (or more @@ -1188,11 +1173,22 @@ int online_pages(unsigned long pfn, unsigned long n= r_pages, /* associate pfn range with the zone */ move_pfn_range_to_zone(zone, pfn, nr_pages, NULL, MIGRATE_ISOLATE); =20 - arg.start_pfn =3D pfn; - arg.nr_pages =3D nr_pages; - node_states_check_changes_online(nr_pages, zone, &arg); + node_arg.nid =3D NUMA_NO_NODE; + if (!node_state(nid, N_MEMORY)) { + /* Adding memory to the node for the first time */ + cancel_node_notifier_on_err =3D true; + node_arg.nid =3D nid; + ret =3D node_notify(NODE_ADDING_FIRST_MEMORY, &node_arg); + ret =3D notifier_to_errno(ret); + if (ret) + goto failed_addition; + } =20 - ret =3D memory_notify(MEM_GOING_ONLINE, &arg); + mem_arg.start_pfn =3D pfn; + mem_arg.nr_pages =3D nr_pages; + mem_arg.status_change_nid =3D node_arg.nid; + cancel_mem_notifier_on_err =3D true; + ret =3D memory_notify(MEM_GOING_ONLINE, &mem_arg); ret =3D notifier_to_errno(ret); if (ret) goto failed_addition; @@ -1218,7 +1214,8 @@ int online_pages(unsigned long pfn, unsigned long nr_= pages, online_pages_range(pfn, nr_pages); adjust_present_page_count(pfn_to_page(pfn), group, nr_pages); =20 - node_states_set_node(nid, &arg); + if (node_arg.nid >=3D 0) + node_set_state(nid, N_MEMORY); if (need_zonelists_rebuild) build_all_zonelists(NULL); =20 @@ -1239,16 +1236,23 @@ int online_pages(unsigned long pfn, unsigned long n= r_pages, kswapd_run(nid); kcompactd_run(nid); =20 + if (node_arg.nid >=3D 0) + /* First memory added successfully. Notify consumers. */ + node_notify(NODE_ADDED_FIRST_MEMORY, &node_arg); + writeback_set_ratelimit(); =20 - memory_notify(MEM_ONLINE, &arg); + memory_notify(MEM_ONLINE, &mem_arg); return 0; =20 failed_addition: pr_debug("online_pages [mem %#010llx-%#010llx] failed\n", (unsigned long long) pfn << PAGE_SHIFT, (((unsigned long long) pfn + nr_pages) << PAGE_SHIFT) - 1); - memory_notify(MEM_CANCEL_ONLINE, &arg); + if (cancel_mem_notifier_on_err) + memory_notify(MEM_CANCEL_ONLINE, &mem_arg); + if (cancel_node_notifier_on_err) + node_notify(NODE_CANCEL_ADDING_FIRST_MEMORY, &node_arg); remove_pfn_range_from_zone(zone, pfn, nr_pages); return ret; } @@ -1880,48 +1884,6 @@ static int __init cmdline_parse_movable_node(char *p) } early_param("movable_node", cmdline_parse_movable_node); =20 -/* check which state of node_states will be changed when offline memory */ -static void node_states_check_changes_offline(unsigned long nr_pages, - struct zone *zone, struct memory_notify *arg) -{ - struct pglist_data *pgdat =3D zone->zone_pgdat; - unsigned long present_pages =3D 0; - enum zone_type zt; - - arg->status_change_nid =3D NUMA_NO_NODE; - - /* - * Check whether node_states[N_NORMAL_MEMORY] will be changed. - * If the memory to be offline is within the range - * [0..ZONE_NORMAL], and it is the last present memory there, - * the zones in that range will become empty after the offlining, - * thus we can determine that we need to clear the node from - * node_states[N_NORMAL_MEMORY]. - */ - for (zt =3D 0; zt <=3D ZONE_NORMAL; zt++) - present_pages +=3D pgdat->node_zones[zt].present_pages; - - /* - * We have accounted the pages from [0..ZONE_NORMAL); ZONE_HIGHMEM - * does not apply as we don't support 32bit. - * Here we count the possible pages from ZONE_MOVABLE. - * If after having accounted all the pages, we see that the nr_pages - * to be offlined is over or equal to the accounted pages, - * we know that the node will become empty, and so, we can clear - * it for N_MEMORY as well. - */ - present_pages +=3D pgdat->node_zones[ZONE_MOVABLE].present_pages; - - if (nr_pages >=3D present_pages) - arg->status_change_nid =3D zone_to_nid(zone); -} - -static void node_states_clear_node(int node, struct memory_notify *arg) -{ - if (arg->status_change_nid >=3D 0) - node_clear_state(node, N_MEMORY); -} - static int count_system_ram_pages_cb(unsigned long start_pfn, unsigned long nr_pages, void *data) { @@ -1937,13 +1899,17 @@ static int count_system_ram_pages_cb(unsigned long = start_pfn, int offline_pages(unsigned long start_pfn, unsigned long nr_pages, struct zone *zone, struct memory_group *group) { - const unsigned long end_pfn =3D start_pfn + nr_pages; - unsigned long pfn, managed_pages, system_ram_pages =3D 0; - const int node =3D zone_to_nid(zone); - unsigned long flags; - struct memory_notify arg; - char *reason; int ret; + char *reason; + enum zone_type zt; + unsigned long flags; + struct memory_notify mem_arg; + struct node_notify node_arg; + const int node =3D zone_to_nid(zone); + struct pglist_data *pgdat =3D zone->zone_pgdat; + const unsigned long end_pfn =3D start_pfn + nr_pages; + unsigned long pfn, managed_pages, system_ram_pages =3D 0, present_pages = =3D 0; + bool cancel_mem_notifier_on_err =3D false, cancel_node_notifier_on_err = =3D false; =20 /* * {on,off}lining is constrained to full memory sections (or more @@ -2000,11 +1966,30 @@ int offline_pages(unsigned long start_pfn, unsigned= long nr_pages, goto failed_removal_pcplists_disabled; } =20 - arg.start_pfn =3D start_pfn; - arg.nr_pages =3D nr_pages; - node_states_check_changes_offline(nr_pages, zone, &arg); + /* + * Here we count the possible pages within the range [0..ZONE_MOVABLE]. + * If after having accounted all the pages, we see that the nr_pages to + * be offlined is greater or equal to the accounted pages, we know that t= he + * node will become empty, and so, we will clear N_MEMORY for it. + */ + node_arg.nid =3D NUMA_NO_NODE; + for (zt =3D 0; zt <=3D ZONE_MOVABLE; zt++) + present_pages +=3D pgdat->node_zones[zt].present_pages; + + if (nr_pages >=3D present_pages) { + node_arg.nid =3D node; + cancel_node_notifier_on_err =3D true; + ret =3D node_notify(NODE_REMOVING_LAST_MEMORY, &node_arg); + ret =3D notifier_to_errno(ret); + if (ret) + goto failed_removal_isolated; + } =20 - ret =3D memory_notify(MEM_GOING_OFFLINE, &arg); + mem_arg.start_pfn =3D start_pfn; + mem_arg.nr_pages =3D nr_pages; + mem_arg.status_change_nid =3D node_arg.nid; + cancel_mem_notifier_on_err =3D true; + ret =3D memory_notify(MEM_GOING_OFFLINE, &mem_arg); ret =3D notifier_to_errno(ret); if (ret) { reason =3D "notifier failure"; @@ -2084,27 +2069,33 @@ int offline_pages(unsigned long start_pfn, unsigned= long nr_pages, * Make sure to mark the node as memory-less before rebuilding the zone * list. Otherwise this node would still appear in the fallback lists. */ - node_states_clear_node(node, &arg); + if (node_arg.nid >=3D 0) + node_clear_state(node, N_MEMORY); if (!populated_zone(zone)) { zone_pcp_reset(zone); build_all_zonelists(NULL); } =20 - if (arg.status_change_nid >=3D 0) { + if (node_arg.nid >=3D 0) { kcompactd_stop(node); kswapd_stop(node); + /* Node went memoryless. Notify consumers */ + node_notify(NODE_REMOVED_LAST_MEMORY, &node_arg); } =20 writeback_set_ratelimit(); =20 - memory_notify(MEM_OFFLINE, &arg); + memory_notify(MEM_OFFLINE, &mem_arg); remove_pfn_range_from_zone(zone, start_pfn, nr_pages); return 0; =20 failed_removal_isolated: /* pushback to free area */ undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE); - memory_notify(MEM_CANCEL_OFFLINE, &arg); + if (cancel_mem_notifier_on_err) + memory_notify(MEM_CANCEL_OFFLINE, &mem_arg); + if (cancel_node_notifier_on_err) + node_notify(NODE_CANCEL_REMOVING_LAST_MEMORY, &node_arg); failed_removal_pcplists_disabled: lru_cache_enable(); zone_pcp_enable(zone); --=20 2.49.0 From nobody Fri Dec 19 19:20:12 2025 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14E701BF33F for ; Thu, 5 Jun 2025 14:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133418; cv=none; b=KUt/e/LTh3gslLs1tvgD0yMqNVIxai2nkDzWM0OdesudaNsLy7z1x7afsvXvHyqoJ4sjDWREh6bM/ZSASbxE8Bf1jFC6/i3DoUhGd2hQw9w16EY10UAE58qiWjnMfQE8Ii1zaW5/9xTs/79Oi6fhCjp2OcXaXQqc2cuSHEKEBW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133418; c=relaxed/simple; bh=MD3aMlFOHJvpDZqHB+YncJLnt3iOZYjJ0u3p2gY2aNg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qq4Cp6SY+HIA5IeLHsqD/Bnq3oJppEuTINX487SisJbZ4/k82o8nbdZZzkadnhRjQ1FsMnlrjSnhk4F460qbUOHj24chvJFf3tFicCUEUsrYM5OX7x77k+wGjyrREWNhU4vZBp0vo9taw6kVXw0cYLTIvkO2YPBNxyaBvbNRP5s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de 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-out1.suse.de (Postfix) with ESMTPS id B2602336C3; Thu, 5 Jun 2025 14:23:17 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none 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 20D5D137FE; Thu, 5 Jun 2025 14:23:17 +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 UF9GBVWoQWipRwAAD6G6ig (envelope-from ); Thu, 05 Jun 2025 14:23:17 +0000 From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Vlastimil Babka , Jonathan Cameron , Harry Yoo , Rakie Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v5 04/10] mm,slub: Use node-notifier instead of memory-notifier Date: Thu, 5 Jun 2025 16:22:55 +0200 Message-ID: <20250605142305.244465-5-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250605142305.244465-1-osalvador@suse.de> References: <20250605142305.244465-1-osalvador@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[]; TAGGED_RCPT(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU] X-Rspamd-Queue-Id: B2602336C3 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -4.00 Content-Type: text/plain; charset="utf-8" slub is only concerned when a numa node changes its memory state, so stop using the memory notifier and use the new numa node notifer instead. Signed-off-by: Oscar Salvador Reviewed-by: Jonathan Cameron Reviewed-by: Harry Yoo Reviewed-by: Vlastimil Babka --- mm/slub.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index f92b43d36adc..b8b5b81bfd1a 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -6164,8 +6164,8 @@ static int slab_mem_going_online_callback(void *arg) { struct kmem_cache_node *n; struct kmem_cache *s; - struct memory_notify *marg =3D arg; - int nid =3D marg->status_change_nid; + struct node_notify *narg =3D arg; + int nid =3D narg->nid; int ret =3D 0; =20 /* @@ -6217,15 +6217,12 @@ static int slab_memory_callback(struct notifier_blo= ck *self, int ret =3D 0; =20 switch (action) { - case MEM_GOING_ONLINE: + case NODE_ADDING_FIRST_MEMORY: ret =3D slab_mem_going_online_callback(arg); break; - case MEM_GOING_OFFLINE: + case NODE_REMOVING_LAST_MEMORY: ret =3D slab_mem_going_offline_callback(arg); break; - case MEM_ONLINE: - case MEM_CANCEL_OFFLINE: - break; } if (ret) ret =3D notifier_from_errno(ret); @@ -6300,7 +6297,7 @@ void __init kmem_cache_init(void) sizeof(struct kmem_cache_node), SLAB_HWCACHE_ALIGN | SLAB_NO_OBJ_EXT, 0, 0); =20 - hotplug_memory_notifier(slab_memory_callback, SLAB_CALLBACK_PRI); + hotplug_node_notifier(slab_memory_callback, SLAB_CALLBACK_PRI); =20 /* Able to allocate the per node structures */ slab_state =3D PARTIAL; --=20 2.49.0 From nobody Fri Dec 19 19:20:12 2025 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9A301A275 for ; Thu, 5 Jun 2025 14:23:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133405; cv=none; b=X6XzfkP9o0gEmYVGhST2UyeQK4UHpS8jxs4t73PCf8oYOntUH9h/zZoFtTcnxtWf2IxhVhWVdga5cyd/fM2u36z3fxpGhN/Z7/tIqnUqzKWNqkG57Q4xunz5POHR2QLVmXOHLRMoHTffDrk0V9bJyT0X1dzt/OC/rpN6fJlbptM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133405; c=relaxed/simple; bh=nishEo9TFyl0gqR6Lnhz9QHfE3lo9HH8FfAyXE3iFJA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ph8evY7fTjvxi2WOLGiWoPEOuIPPc3gJLmwDyXO7sPepNk5y9RFrIkr6O3wzeF7w/vvT45doBQ/UJiqW0bNwqb0OGXf4p5YEWvnYuGVWGbzrOoNqOtNmd5Mq9Jg3MJo+v47CgKEnyglvXmkdsrAee64K0sjqKVyvzgUbqNi8a+8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de 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 610021F898; Thu, 5 Jun 2025 14:23:18 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none 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 C4E69137FE; Thu, 5 Jun 2025 14:23:17 +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 cPVELVWoQWipRwAAD6G6ig (envelope-from ); Thu, 05 Jun 2025 14:23:17 +0000 From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Vlastimil Babka , Jonathan Cameron , Harry Yoo , Rakie Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v5 05/10] mm,memory-tiers: Use node-notifier instead of memory-notifier Date: Thu, 5 Jun 2025 16:22:56 +0200 Message-ID: <20250605142305.244465-6-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250605142305.244465-1-osalvador@suse.de> References: <20250605142305.244465-1-osalvador@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spam-Level: X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[]; TAGGED_RCPT(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU] X-Spam-Flag: NO X-Rspamd-Queue-Id: 610021F898 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Score: -4.00 Content-Type: text/plain; charset="utf-8" memory-tier is only concerned when a numa node changes its memory state, because it then needs to re-create the demotion list. So stop using the memory notifier and use the new numa node notifer instead. Signed-off-by: Oscar Salvador Reviewed-by: Jonathan Cameron Reviewed-by: Harry Yoo Reviewed-by: Vlastimil Babka --- mm/memory-tiers.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c index fc14fe53e9b7..67f06e6264a1 100644 --- a/mm/memory-tiers.c +++ b/mm/memory-tiers.c @@ -872,25 +872,25 @@ static int __meminit memtier_hotplug_callback(struct = notifier_block *self, unsigned long action, void *_arg) { struct memory_tier *memtier; - struct memory_notify *arg =3D _arg; + struct node_notify *narg =3D _arg; =20 /* * Only update the node migration order when a node is * changing status, like online->offline. */ - if (arg->status_change_nid < 0) + if (narg->nid < 0) return notifier_from_errno(0); =20 switch (action) { - case MEM_OFFLINE: + case NODE_REMOVED_LAST_MEMORY: mutex_lock(&memory_tier_lock); - if (clear_node_memory_tier(arg->status_change_nid)) + if (clear_node_memory_tier(narg->nid)) establish_demotion_targets(); mutex_unlock(&memory_tier_lock); break; - case MEM_ONLINE: + case NODE_ADDED_FIRST_MEMORY: mutex_lock(&memory_tier_lock); - memtier =3D set_node_memory_tier(arg->status_change_nid); + memtier =3D set_node_memory_tier(narg->nid); if (!IS_ERR(memtier)) establish_demotion_targets(); mutex_unlock(&memory_tier_lock); @@ -929,7 +929,7 @@ static int __init memory_tier_init(void) nodes_and(default_dram_nodes, node_states[N_MEMORY], node_states[N_CPU]); =20 - hotplug_memory_notifier(memtier_hotplug_callback, MEMTIER_HOTPLUG_PRI); + hotplug_node_notifier(memtier_hotplug_callback, MEMTIER_HOTPLUG_PRI); return 0; } subsys_initcall(memory_tier_init); --=20 2.49.0 From nobody Fri Dec 19 19:20:12 2025 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD1DA148830 for ; Thu, 5 Jun 2025 14:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133412; cv=none; b=X8CeY2GWFvnzw8IlRcpPTeDz7fPtKGBgd2WgyE3QevnoAtYj9Ocvv2qdJzhyI3Ld8ivKPG1UqoAutXh6rq3QXkr4s7UZZEG4oO0HiSjiBmbsqmXTSIguQoZq6p23LE/mTI58nQV0MtEl9m3uNEzqVK/ogatkhymq5c4/q4kRwrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133412; c=relaxed/simple; bh=TAzrt6nhy8E8EUa5WhmeMI7II9eV2j9n/Aq2emSKi0A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GseGb9Tuc2O9MsHkzm2ONbkz4F4TDr8z39iQ7RlXSnnbEpMLnZWKUFVXPYVNrbTdNjl2dzuWudU0IJdjcsTgaM229m7oQxMznush+JFChdhPa7F4LlMOzA4PwxXSuqM+AwrBjlQnJ25UnHKQdIVUzsxPKNk1OJCdAmdssolR7ME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de 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 110081FB40; Thu, 5 Jun 2025 14:23:19 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none 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 73F1B137FE; Thu, 5 Jun 2025 14:23:18 +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 WBmOGVaoQWipRwAAD6G6ig (envelope-from ); Thu, 05 Jun 2025 14:23:18 +0000 From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Vlastimil Babka , Jonathan Cameron , Harry Yoo , Rakie Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v5 06/10] drivers,cxl: Use node-notifier instead of memory-notifier Date: Thu, 5 Jun 2025 16:22:57 +0200 Message-ID: <20250605142305.244465-7-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250605142305.244465-1-osalvador@suse.de> References: <20250605142305.244465-1-osalvador@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spam-Level: X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[]; TAGGED_RCPT(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU] X-Spam-Flag: NO X-Rspamd-Queue-Id: 110081FB40 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Score: -4.00 Content-Type: text/plain; charset="utf-8" memory-tier is only concerned when a numa node changes its memory state, specifically when a numa node with memory comes into play for the first time, because it needs to get its performance attributes to build a proper demotion chain. So stop using the memory notifier and use the new numa node notifer instead. Signed-off-by: Oscar Salvador Reviewed-by: Jonathan Cameron Reviewed-by: Harry Yoo Reviewed-by: Vlastimil Babka --- drivers/cxl/core/region.c | 16 ++++++++-------- drivers/cxl/cxl.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index c3f4dc244df7..a8477a3e175c 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2432,12 +2432,12 @@ static int cxl_region_perf_attrs_callback(struct no= tifier_block *nb, unsigned long action, void *arg) { struct cxl_region *cxlr =3D container_of(nb, struct cxl_region, - memory_notifier); - struct memory_notify *mnb =3D arg; - int nid =3D mnb->status_change_nid; + node_notifier); + struct node_notify *mnb =3D arg; + int nid =3D mnb->nid; int region_nid; =20 - if (nid =3D=3D NUMA_NO_NODE || action !=3D MEM_ONLINE) + if (nid =3D=3D NUMA_NO_NODE || action !=3D NODE_ADDED_FIRST_MEMORY) return NOTIFY_DONE; =20 /* @@ -3484,7 +3484,7 @@ static void shutdown_notifiers(void *_cxlr) { struct cxl_region *cxlr =3D _cxlr; =20 - unregister_memory_notifier(&cxlr->memory_notifier); + unregister_node_notifier(&cxlr->node_notifier); unregister_mt_adistance_algorithm(&cxlr->adist_notifier); } =20 @@ -3523,9 +3523,9 @@ static int cxl_region_probe(struct device *dev) if (rc) return rc; =20 - cxlr->memory_notifier.notifier_call =3D cxl_region_perf_attrs_callback; - cxlr->memory_notifier.priority =3D CXL_CALLBACK_PRI; - register_memory_notifier(&cxlr->memory_notifier); + cxlr->node_notifier.notifier_call =3D cxl_region_perf_attrs_callback; + cxlr->node_notifier.priority =3D CXL_CALLBACK_PRI; + register_node_notifier(&cxlr->node_notifier); =20 cxlr->adist_notifier.notifier_call =3D cxl_region_calculate_adistance; cxlr->adist_notifier.priority =3D 100; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index a9ab46eb0610..48ac02dee881 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -513,7 +513,7 @@ enum cxl_partition_mode { * @flags: Region state flags * @params: active + config params for the region * @coord: QoS access coordinates for the region - * @memory_notifier: notifier for setting the access coordinates to node + * @node_notifier: notifier for setting the access coordinates to node * @adist_notifier: notifier for calculating the abstract distance of node */ struct cxl_region { @@ -526,7 +526,7 @@ struct cxl_region { unsigned long flags; struct cxl_region_params params; struct access_coordinate coord[ACCESS_COORDINATE_MAX]; - struct notifier_block memory_notifier; + struct notifier_block node_notifier; struct notifier_block adist_notifier; }; =20 --=20 2.49.0 From nobody Fri Dec 19 19:20:12 2025 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B10ED1552FD for ; Thu, 5 Jun 2025 14:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133418; cv=none; b=GH/BEPMAGJGpZ6IyzmJIPBt857+rX2oHg6EmmbtKYJ+e4Q8p9POXR1H4nrLPFOT8Ggfqf8XrUg3q8C639idJ/NdMJcdtyZrP273Yf96UxO5/qcuClNN7YFn6s2lUDE7fONh3fdnaFBG8mFuMWpE6iHe7icl6858lZCrRU4T6W4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133418; c=relaxed/simple; bh=unRD5RKD6xhSaEllEGZZH2fCsQ/seiSinfUoX+565ok=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MkszhDHCz4jXfgc+uEfaucHWY3+MRRYnCpSTqbwtl8oh5jkdWoh4sn3vUUMhqn2NbN0a0ZSabpfdxCX3jMb39ZwyNPrr7gfZL+gtFI7vLXzH+Nn0U3BtWuhemxCPwaWJyISrqGsd7GfX2hu3JCvP4Rn1CPFqNslLDfuwjirfVso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=zWbYJvWL; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=mI60w1ai; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=zWbYJvWL; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=mI60w1ai; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="zWbYJvWL"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="mI60w1ai"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="zWbYJvWL"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="mI60w1ai" 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 B57891FC07; Thu, 5 Jun 2025 14:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1749133399; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TfQBDueegZSN3Kmr3ysy5n8hn7Z096/ISwoCXJ5ZmnM=; b=zWbYJvWL9IwlUT0QyuNU1e/H2zkY9nAGFWR9gPCQ4kCvfvgl1m6Y7Xc28xFo+8veSh/mHe OSP10casSp+KJt6Qba0V/J0hKa8OyQ6UVMMlvvCxNUnRhMDF6CRwhhFnTxywsNJ6AXUXD6 P+eQeBAYlCsAMW3Sy7KSN7Ae2x03CiE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1749133399; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TfQBDueegZSN3Kmr3ysy5n8hn7Z096/ISwoCXJ5ZmnM=; b=mI60w1aiFARGc5RyNWieEIvw2NTo1b+pDiwkVvz1NKMO4yIFQggBvpjOw0kliuEAvlFbPH oDIIxvIyIX7v/fCg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1749133399; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TfQBDueegZSN3Kmr3ysy5n8hn7Z096/ISwoCXJ5ZmnM=; b=zWbYJvWL9IwlUT0QyuNU1e/H2zkY9nAGFWR9gPCQ4kCvfvgl1m6Y7Xc28xFo+8veSh/mHe OSP10casSp+KJt6Qba0V/J0hKa8OyQ6UVMMlvvCxNUnRhMDF6CRwhhFnTxywsNJ6AXUXD6 P+eQeBAYlCsAMW3Sy7KSN7Ae2x03CiE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1749133399; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TfQBDueegZSN3Kmr3ysy5n8hn7Z096/ISwoCXJ5ZmnM=; b=mI60w1aiFARGc5RyNWieEIvw2NTo1b+pDiwkVvz1NKMO4yIFQggBvpjOw0kliuEAvlFbPH oDIIxvIyIX7v/fCg== 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 24BBE137FE; Thu, 5 Jun 2025 14:23:19 +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 CPEABleoQWipRwAAD6G6ig (envelope-from ); Thu, 05 Jun 2025 14:23:19 +0000 From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Vlastimil Babka , Jonathan Cameron , Harry Yoo , Rakie Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v5 07/10] drivers,hmat: Use node-notifier instead of memory-notifier Date: Thu, 5 Jun 2025 16:22:58 +0200 Message-ID: <20250605142305.244465-8-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250605142305.244465-1-osalvador@suse.de> References: <20250605142305.244465-1-osalvador@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Spam-Score: -5.30 X-Spamd-Result: default: False [-5.30 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; URIBL_BLOCKED(0.00)[suse.de:mid,suse.de:email,suse.cz:email,imap1.dmz-prg2.suse.org:helo,oracle.com:email,huawei.com:email]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,suse.cz,huawei.com,oracle.com,sk.com,gmail.com,kvack.org,vger.kernel.org,suse.de]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLsc83pr41xu6y1i6mw9yajrf5)]; DBL_BLOCKED_OPENRESOLVER(0.00)[oracle.com:email,suse.cz:email,imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email] X-Spam-Level: Content-Type: text/plain; charset="utf-8" hmat driver is only concerned when a numa node changes its memory state, specifically when a numa node with memory comes into play for the first time, because it will register the memory_targets belonging to that numa node. So stop using the memory notifier and use the new numa node notifer instead. Signed-off-by: Oscar Salvador Reviewed-by: Jonathan Cameron Reviewed-by: Harry Yoo Reviewed-by: Vlastimil Babka --- drivers/acpi/numa/hmat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c index 9d9052258e92..fe626e969fdc 100644 --- a/drivers/acpi/numa/hmat.c +++ b/drivers/acpi/numa/hmat.c @@ -962,10 +962,10 @@ static int hmat_callback(struct notifier_block *self, unsigned long action, void *arg) { struct memory_target *target; - struct memory_notify *mnb =3D arg; - int pxm, nid =3D mnb->status_change_nid; + struct node_notify *nb =3D arg; + int pxm, nid =3D nb->nid; =20 - if (nid =3D=3D NUMA_NO_NODE || action !=3D MEM_ONLINE) + if (nid =3D=3D NUMA_NO_NODE || action !=3D NODE_ADDED_FIRST_MEMORY) return NOTIFY_OK; =20 pxm =3D node_to_pxm(nid); @@ -1118,7 +1118,7 @@ static __init int hmat_init(void) hmat_register_targets(); =20 /* Keep the table and structures if the notifier may use them */ - if (hotplug_memory_notifier(hmat_callback, HMAT_CALLBACK_PRI)) + if (hotplug_node_notifier(hmat_callback, HMAT_CALLBACK_PRI)) goto out_put; =20 if (!hmat_set_default_dram_perf()) --=20 2.49.0 From nobody Fri Dec 19 19:20:12 2025 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E95E21DE3A7 for ; Thu, 5 Jun 2025 14:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133424; cv=none; b=NmdCOAl1ySUMSlv9eHxwaBDvwo5nQjXGVsmI6t1re3EM7SLlD4gG9+EQHiPw+CanH96tdDr7+Tp49YfCEDoa7ERDHO55MyD9+4tRyUwjW+vJ+ZwkDL37JEDzdgglWj/MsmtYVj2XNLzfdpSvYONFk679WMnVCtu1ZPsa1gfAqC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133424; c=relaxed/simple; bh=daxhZFbTtNCtc+n3FkbjtNEJWZrBraCDsQ4oBldj/5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jnYJn4E6X/KwQMfA6+Fv55S1TFgWkQulGyc7G2o54jzX3SuL4zLWx7vcxiuDZRjVPuOl4lulx8FfyCehn1S2MfG8ePRviKhj7hEy5BYU4c7DQYs3QYkfOn+Hl3Ueyk8FHFpk6sNzFudjirhTEjB6YE83M8CdNolnzDE98ficQFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de 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-out1.suse.de (Postfix) with ESMTPS id 60A0033726; Thu, 5 Jun 2025 14:23:20 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none 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 C5F00139CB; Thu, 5 Jun 2025 14:23:19 +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 4CCVLVeoQWipRwAAD6G6ig (envelope-from ); Thu, 05 Jun 2025 14:23:19 +0000 From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Vlastimil Babka , Jonathan Cameron , Harry Yoo , Rakie Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v5 08/10] kernel,cpuset: Use node-notifier instead of memory-notifier Date: Thu, 5 Jun 2025 16:22:59 +0200 Message-ID: <20250605142305.244465-9-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250605142305.244465-1-osalvador@suse.de> References: <20250605142305.244465-1-osalvador@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[]; TAGGED_RCPT(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU] X-Rspamd-Queue-Id: 60A0033726 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -4.00 Content-Type: text/plain; charset="utf-8" cpuset is only concerned when a numa node changes its memory state, as it needs to know the current numa nodes with memory to keep an updated mems_allowed mask. So stop using the memory notifier and use the new numa node notifer instead. Signed-off-by: Oscar Salvador Reviewed-by: Jonathan Cameron Reviewed-by: Harry Yoo Reviewed-by: Vlastimil Babka Acked-by: David Hildenbrand --- kernel/cgroup/cpuset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 83639a12883d..66c84024f217 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -4013,7 +4013,7 @@ void __init cpuset_init_smp(void) cpumask_copy(top_cpuset.effective_cpus, cpu_active_mask); top_cpuset.effective_mems =3D node_states[N_MEMORY]; =20 - hotplug_memory_notifier(cpuset_track_online_nodes, CPUSET_CALLBACK_PRI); + hotplug_node_notifier(cpuset_track_online_nodes, CPUSET_CALLBACK_PRI); =20 cpuset_migrate_mm_wq =3D alloc_ordered_workqueue("cpuset_migrate_mm", 0); BUG_ON(!cpuset_migrate_mm_wq); --=20 2.49.0 From nobody Fri Dec 19 19:20:12 2025 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E69911DE2CF for ; Thu, 5 Jun 2025 14:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133424; cv=none; b=YcC/5E1AdOGZWHONPj4AfCptnyL/TsstmNRZ3q62Glhue9pwoYsL1/HKuyV+fPObQ3BLz+fTjBJBAPdQj+Qty33pZHzxTAJ0hwarUns8U2eV4mNeWyo0WUPQY4NWq1KIHvFnNmGupOzejoM5C4UOvHnrTHPz8QoEO7n49DcAu08= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133424; c=relaxed/simple; bh=NjrFzsmMMVDfSK30eUWfJlAavtEqL6V+GN78HLu9+eU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ja/vY3uy3/yXZoSNvuWDxNg1X7irXepCxf7BMGQO10QfeRh7aXjafmpjqmrTXGtsVIEOdeVpjNVV86vGVvZZyDEI2mi73fOIHw3CpB0Okbt0GpVA7bpzSBtNzrE6eV85IpTUexu9Qexv6jO2/7X27+xu+AOLF67K9OVhpwLrvu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de 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 1090E1FCFD; Thu, 5 Jun 2025 14:23:21 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none 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 72A5B137FE; Thu, 5 Jun 2025 14:23: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 CEI9GVioQWipRwAAD6G6ig (envelope-from ); Thu, 05 Jun 2025 14:23:20 +0000 From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Vlastimil Babka , Jonathan Cameron , Harry Yoo , Rakie Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v5 09/10] mm,mempolicy: Use node-notifier instead of memory-notifier Date: Thu, 5 Jun 2025 16:23:00 +0200 Message-ID: <20250605142305.244465-10-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250605142305.244465-1-osalvador@suse.de> References: <20250605142305.244465-1-osalvador@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spam-Level: X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[]; TAGGED_RCPT(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU] X-Spam-Flag: NO X-Rspamd-Queue-Id: 1090E1FCFD X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Score: -4.00 Content-Type: text/plain; charset="utf-8" mempolicy is only concerned when a numa node changes its memory state, because it needs to take this node into account for the auto-weighted memory policy system. So stop using the memory notifier and use the new numa node notifer instead. Signed-off-by: Oscar Salvador Reviewed-by: Jonathan Cameron Reviewed-by: Harry Yoo Reviewed-by: Vlastimil Babka Reviewed-by: Rakie Kim --- mm/mempolicy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 72fd72e156b1..1b87628f3cfc 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -3793,20 +3793,20 @@ static int wi_node_notifier(struct notifier_block *= nb, unsigned long action, void *data) { int err; - struct memory_notify *arg =3D data; - int nid =3D arg->status_change_nid; + struct node_notify *arg =3D data; + int nid =3D arg->nid; =20 if (nid < 0) return NOTIFY_OK; =20 switch (action) { - case MEM_ONLINE: + case NODE_ADDED_FIRST_MEMORY: err =3D sysfs_wi_node_add(nid); if (err) pr_err("failed to add sysfs for node%d during hotplug: %d\n", nid, err); break; - case MEM_OFFLINE: + case NODE_REMOVED_LAST_MEMORY: sysfs_wi_node_delete(nid); break; } @@ -3845,7 +3845,7 @@ static int __init add_weighted_interleave_group(struc= t kobject *mempolicy_kobj) } } =20 - hotplug_memory_notifier(wi_node_notifier, DEFAULT_CALLBACK_PRI); + hotplug_node_notifier(wi_node_notifier, DEFAULT_CALLBACK_PRI); return 0; =20 err_cleanup_kobj: --=20 2.49.0 From nobody Fri Dec 19 19:20:12 2025 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C89E8188734 for ; Thu, 5 Jun 2025 14:23:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133430; cv=none; b=t8wIgLzdcWqpJWz+w3qmwzhpGXAPF86Oza6LjWmmO0Ch13hwTy2cXzFVBibmVF2OY2RNq6/jM2X9NS6bzbFBvrk1zR4xBpkUyVci3uigeBJc23Z/a0rkSsrQKvDsAAVO7sDPhmenHCfR/hM6Bdq8ZXceH757kOu7EgqH3nTDPEU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749133430; c=relaxed/simple; bh=8JcmyBEdd4dZW0ykXLCuOpg53uPa5lB0AReWtq+k78Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n4p68tp+WCeabQ9t71RSmW1fdckjky8wJMiMV7OLwiZvU7Qeie056gPHs8RWQpmlNkl8xFdDQDsyrpe2gsSf7QR82oste5FwYEa5hBW5TDj4IcuLY7mgvJ9lJ/26/+6mZ91RrT2DOccheNCStHXI0nVSAkI0BxBYThOaTgOrH08= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=wMJQdNQe; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=M2tk8Jzw; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=wMJQdNQe; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=M2tk8Jzw; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="wMJQdNQe"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="M2tk8Jzw"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="wMJQdNQe"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="M2tk8Jzw" 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 BCEC41FDC9; Thu, 5 Jun 2025 14:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1749133401; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SmSyjhZyv9opvDAxMx9rc8iOlerhOsuhbkuJ00p6FnE=; b=wMJQdNQe2CHkW3QhzHzBnRYpS6r79wY6Pzjenus1EwRVLCfJUnO6VIwHrNUhU5LymiO4Fg Ym85LVtpiJdusifKnEB8uQPfGD/x80AcyEEsrMZCOsgg0EUiRCEwLjJNCOHFeRewkORAiQ shAxpREEx6LV5r+wEWl7OoeM80agUvI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1749133401; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SmSyjhZyv9opvDAxMx9rc8iOlerhOsuhbkuJ00p6FnE=; b=M2tk8Jzw7FwcP9Zi/OpZUDNmqXkw0odqrNWc7yDoFQWfFTjqFZjCwPRTGUglVS4LU/mTJt Y5ah8jcpV+DTVCAA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1749133401; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SmSyjhZyv9opvDAxMx9rc8iOlerhOsuhbkuJ00p6FnE=; b=wMJQdNQe2CHkW3QhzHzBnRYpS6r79wY6Pzjenus1EwRVLCfJUnO6VIwHrNUhU5LymiO4Fg Ym85LVtpiJdusifKnEB8uQPfGD/x80AcyEEsrMZCOsgg0EUiRCEwLjJNCOHFeRewkORAiQ shAxpREEx6LV5r+wEWl7OoeM80agUvI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1749133401; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SmSyjhZyv9opvDAxMx9rc8iOlerhOsuhbkuJ00p6FnE=; b=M2tk8Jzw7FwcP9Zi/OpZUDNmqXkw0odqrNWc7yDoFQWfFTjqFZjCwPRTGUglVS4LU/mTJt Y5ah8jcpV+DTVCAA== 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 23A81137FE; Thu, 5 Jun 2025 14:23:21 +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 gPv7BVmoQWipRwAAD6G6ig (envelope-from ); Thu, 05 Jun 2025 14:23:21 +0000 From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Vlastimil Babka , Jonathan Cameron , Harry Yoo , Rakie Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v5 10/10] mm,memory_hotplug: Rename status_change_nid parameter in memory_notify Date: Thu, 5 Jun 2025 16:23:01 +0200 Message-ID: <20250605142305.244465-11-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250605142305.244465-1-osalvador@suse.de> References: <20250605142305.244465-1-osalvador@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-5.30 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,suse.cz,huawei.com,oracle.com,sk.com,gmail.com,kvack.org,vger.kernel.org,suse.de]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; TAGGED_RCPT(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_SEVEN(0.00)[10]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,suse.cz:email,imap1.dmz-prg2.suse.org:helo,oracle.com:email]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; R_RATELIMIT(0.00)[to_ip_from(RLsc83pr41xu6y1i6mw9yajrf5)]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -5.30 Content-Type: text/plain; charset="utf-8" The 'status_change_nid' field was used to track changes in the memory state of a numa node, but that funcionality has been decoupled from memory_notify and moved to node_notify. Current consumers of memory_notify are only interested in which node the memory we are adding belongs to, so rename current 'status_change_nid' to 'nid'. Reviewed-by: Harry Yoo Reviewed-by: Vlastimil Babka Signed-off-by: Oscar Salvador --- Documentation/core-api/memory-hotplug.rst | 9 ++------- include/linux/memory.h | 2 +- mm/memory_hotplug.c | 4 ++-- mm/page_ext.c | 12 +----------- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/Documentation/core-api/memory-hotplug.rst b/Documentation/core= -api/memory-hotplug.rst index b19c3be7437d..97efb7b651ac 100644 --- a/Documentation/core-api/memory-hotplug.rst +++ b/Documentation/core-api/memory-hotplug.rst @@ -59,17 +59,12 @@ The third argument (arg) passes a pointer of struct mem= ory_notify:: struct memory_notify { unsigned long start_pfn; unsigned long nr_pages; - int status_change_nid; + int nid; } =20 - start_pfn is start_pfn of online/offline memory. - nr_pages is # of pages of online/offline memory. -- status_change_nid is set node id when N_MEMORY of nodemask is (will be) - set/clear. It means a new(memoryless) node gets new memory by online and= a - node loses all memory. If this is -1, then nodemask status is not change= d. - - If status_changed_nid* >=3D 0, callback should create/discard structures= for the - node if necessary. +- nid is set to the node id, where the memory we are adding or removing be= longs to. =20 The callback routine shall return one of the values NOTIFY_DONE, NOTIFY_OK, NOTIFY_BAD, NOTIFY_STOP diff --git a/include/linux/memory.h b/include/linux/memory.h index a9ccd6579422..918c65ecf299 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -109,7 +109,7 @@ struct memory_notify { unsigned long altmap_nr_pages; unsigned long start_pfn; unsigned long nr_pages; - int status_change_nid; + int nid; }; =20 struct notifier_block; diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 0550f3061fc4..bccbc02ed122 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1186,7 +1186,7 @@ int online_pages(unsigned long pfn, unsigned long nr_= pages, =20 mem_arg.start_pfn =3D pfn; mem_arg.nr_pages =3D nr_pages; - mem_arg.status_change_nid =3D node_arg.nid; + mem_arg.nid =3D node_arg.nid; cancel_mem_notifier_on_err =3D true; ret =3D memory_notify(MEM_GOING_ONLINE, &mem_arg); ret =3D notifier_to_errno(ret); @@ -1987,7 +1987,7 @@ int offline_pages(unsigned long start_pfn, unsigned l= ong nr_pages, =20 mem_arg.start_pfn =3D start_pfn; mem_arg.nr_pages =3D nr_pages; - mem_arg.status_change_nid =3D node_arg.nid; + mem_arg.nid =3D node_arg.nid; cancel_mem_notifier_on_err =3D true; ret =3D memory_notify(MEM_GOING_OFFLINE, &mem_arg); ret =3D notifier_to_errno(ret); diff --git a/mm/page_ext.c b/mm/page_ext.c index c351fdfe9e9a..477e6f24b7ab 100644 --- a/mm/page_ext.c +++ b/mm/page_ext.c @@ -378,16 +378,6 @@ static int __meminit online_page_ext(unsigned long sta= rt_pfn, start =3D SECTION_ALIGN_DOWN(start_pfn); end =3D SECTION_ALIGN_UP(start_pfn + nr_pages); =20 - if (nid =3D=3D NUMA_NO_NODE) { - /* - * In this case, "nid" already exists and contains valid memory. - * "start_pfn" passed to us is a pfn which is an arg for - * online__pages(), and start_pfn should exist. - */ - nid =3D pfn_to_nid(start_pfn); - VM_BUG_ON(!node_online(nid)); - } - for (pfn =3D start; !fail && pfn < end; pfn +=3D PAGES_PER_SECTION) fail =3D init_section_page_ext(pfn, nid); if (!fail) @@ -436,7 +426,7 @@ static int __meminit page_ext_callback(struct notifier_= block *self, switch (action) { case MEM_GOING_ONLINE: ret =3D online_page_ext(mn->start_pfn, - mn->nr_pages, mn->status_change_nid); + mn->nr_pages, mn->nid); break; case MEM_OFFLINE: offline_page_ext(mn->start_pfn, --=20 2.49.0