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 2F391C5AD49 for ; Tue, 3 Jun 2025 11:09:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F9896B03A6; Tue, 3 Jun 2025 07:09:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D1BA6B03C0; Tue, 3 Jun 2025 07:09:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E77B6B0404; Tue, 3 Jun 2025 07:09:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 025436B03A6 for ; Tue, 3 Jun 2025 07:09:10 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id ACBDB16052C for ; Tue, 3 Jun 2025 11:09:10 +0000 (UTC) X-FDA: 83513817660.10.E6D9866 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf17.hostedemail.com (Postfix) with ESMTP id 959B04000C for ; Tue, 3 Jun 2025 11:09:08 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf17.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1748948948; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zoU/44fOg13rpWtmefDcCWzwTg7jIUF7E8mdwpeMy+w=; b=8h8hYAAah7oXof+shXgB8aJHhTz6Zx3ozCCH59ePjdUKAignPa2RLpu/BqJcce6zB7Uvr6 fhuhZ1HZk8SRNKYaJvQHt1TphaDK/BSi433UOeN69wpwhYb6qXPBmla+x31s2y/YDG9sA/ e70AAsVrXDj+2o7EJgoFxrWxNyHSBJ4= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf17.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1748948948; a=rsa-sha256; cv=none; b=QZqqzlBJHb+Sw9WSPtEUCodFAIRp6/4/LpW0wo0qLW0XU1a1BJ4oINzllUgjIUHhE9Eqvn GkswvsqP54j4bxJ21hjUDK5rfFV1D8kwwo63s9AXVtqzWVyWFVoDnlrRBuNOqmMizjvMUd L7hJyHCHCpbEu4OUW/rgyR8vkJAaGOQ= 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 055082121C; Tue, 3 Jun 2025 11:09:07 +0000 (UTC) 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 6E9C213AAD; Tue, 3 Jun 2025 11:09:06 +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 oEXkF9LXPmjfXQAAD6G6ig (envelope-from ); Tue, 03 Jun 2025 11:09:06 +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 v4 1/3] mm,slub: Do not special case N_NORMAL nodes for slab_nodes Date: Tue, 3 Jun 2025 13:08:48 +0200 Message-ID: <20250603110850.192912-2-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250603110850.192912-1-osalvador@suse.de> References: <20250603110850.192912-1-osalvador@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Queue-Id: 959B04000C X-Stat-Signature: tqwwaxowp5rmzmig6o1gcn5dnh878988 X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1748948948-506960 X-HE-Meta: U2FsdGVkX1+JzAq39imW+oaFmbKotdLkRI9FVnHEC30dT7oE2jWWEzY4krcfTsHbUHwvY4Lk2oS0fuZqsb+DLFXPe2Uxf9pUl5Am9+Mp6ZUlVeEy+W/HJDTXFrDDyvp2859bncesi0bzp2cmaCTaJCJ1cMhpvO6d6fYq76CkvWu4mKFKPdXQJ5XXbqGE+i6m+nOTZZTwcyMNwMoy02bODw82sHtz0ysL9MejlnXS/cREJnMZ94z/R34CqFLvT5y4fzqB8M2Os4EEfug527j2uBdclLbjVDghBAUxx3M2WcFAO7RiV+M0szHP6n79vtU+tgtQ8tjspocttdTmlnB/kd5u4vq86l1RnTvOGu4YDLoaZfklpDz2v/iJd07G4gKz5GChhK7U5+FjSCBMTUtsTi/sN9Bn4mFFITYDP8D7b6NU3TmmhCOYjMMo/oHl3rm4OPxjw4LP4S71TG6caD3EMgYQybigY4UjPYbHV1/NMFBu+Bh3a9mP0ulWEVFPZ681WQDaCUWAUcLJzgBGx3l2gZ06ACu7ZYzw1NaXsnP/i0RgxScRhZzyrU9RchSPIYCHDkXnGq7CBF6pA28WFT035RdHIU1aztEeLjYJQ7KVqcdqyhJm2AQc2YKp0EE0itYKWLnCPWhcnUHcyd//MsfAAn39LbCK8Ofzk2AFkg8Yv9ZNynKiFar4dluwoknlNty4Ok2j6YMh57XpkoGQFzxpG1SPytJvQkvuv4ggPGzbUBwDmOuBszeOyabkEAK9D4+GDLKFWoRlPNvlXCQKs8L2vMAxF0/nApa7sUohRg2wSqYtsmMzFND+/RTwo39hdhI/ldrYdTCuORv2cmLHYRo43JEdszEsNhKpycQyCZwAieOxXsljzS9qRaqG7/2Q6RsfTeh5NzuT5yxWSnF8sD3CwoVlTx/Lo6jMai6SRGPQDhzy46WOQEgUuDGjXloukyYe5rL1fKPWtz9xsYfmlpj lGsd2jAr GxlY1ieaRVnt0cW/RPh274gSEeV6QSTB3q5kfVhrPjqRIPXqajnO4sGe6XbCsmirs+9zxOlN5nxF6QqfFVyyDlQYOUhqvyUyAJ7EJc6QIYWoAyQbEaCR+ea8DB6synOS8KIMmtPz/OpTRe3xPYyDHr59rpsnPYgA3bUBRpYqQRp/k/PmsLw30mgZ/tf7AymAjfbrvKye138UxLADwbj8zrrVKg8HHUcjv7YLys8jmr8xUGhAjtmfCzNRisGc86M6JoBwaCZ6/hRhriVg= 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: Currently, slab_mem_going_going_callback() checks whether the node has N_NORMAL memory in order to be set in slab_nodes. While it is true that gettind 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_off_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 allocate 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 --- 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 kmem_cache *s, int node) /* * 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 *arg) return 0; } -static void slab_mem_offline_callback(void *arg) -{ - struct memory_notify *marg = arg; - int offline_node; - - offline_node = 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 = arg; - int nid = marg->status_change_nid_normal; + int nid = marg->status_change_nid; int ret = 0; /* @@ -6247,10 +6223,6 @@ static int slab_memory_callback(struct notifier_block *self, case MEM_GOING_OFFLINE: ret = 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); create_boot_cache(kmem_cache_node, "kmem_cache_node", -- 2.49.0