From nobody Thu Oct 9 20:24:36 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 735242BF018 for ; Mon, 16 Jun 2025 13:52: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=1750081945; cv=none; b=W7MZL8YsM0FAr0TrJN/Bkvpl3Lz/tZCqDOUs2fyZ11guWXT/r6mVbyd1XfAr9upKmrEjpPFM2jJsULQXpPIIG31i7uUOpxRqXYow7In/6i6xsYwDk0apzz68hdUNUToxOBKP7l8KGq7wRl7p/Tj9nl13tTeOGDl/ufS00yNJavs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750081945; c=relaxed/simple; bh=6R9Ss4KQG7e6j2i/RejfHECkSDU5rzGoQQKl19n6nBs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uL3j6a/f8liQqf64OCTsC0SR1T1pzRA1HOMf87d7cBrv9wRJK4clTqZTMQlsDDcTLBPbQIF6zQoctQhvgAHs9asJPtHk9pzO9LMVPx28sDDyRjhXIOypZWtlLMqXv0DFpqdqJrxZFAjEo7HCdxu9WlMKjCFiRO9cKYLDvvw2bPw= 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=x/99woWr; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=eAQ5bvop; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=hvdBehz6; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=K021Rof3; 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="x/99woWr"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="eAQ5bvop"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="hvdBehz6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="K021Rof3" 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 921BE211B3; Mon, 16 Jun 2025 13:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081936; 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=x/99woWrllKp2E0FlvZah0Bz/Y8ZQVPX6bEi8NLk/wyZoH7TFTY8wdTXQPyueE3f2NuHp7 r0AsHScIjkYnf9gy3kwbzMPTyQTkdhJUURUgvaA/54SXWic5A9ITiJoy6XxXHi9f6s12hk ftTnHFUt2fpG5RFL37ajG8+ElndJmSs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081936; 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=eAQ5bvopSHs8j5mFMFJYjPsq4xvHpwr5LXLy7OUA3uu2kDbMcDPjz/ax+73TPN9YSbLmUz LdA9Ot+xcjJD55Aw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081931; 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=hvdBehz68NOIPgj6zXx7S3On2ls13+7vkdrV0KWmN9e974nEFuF025M7muV5JYwZdu9+se u6R2wV2uXR4vPDiemMVET5fek/QMH9Py3nE+mL6kjFgJ5xNbT1oBmus+d5KgW2T2welJ8u 0ZRRVl5LzcdUtDUBSiwsPEktYUZ94VQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081931; 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=K021Rof3kE2oHNm9fiQXHjnjE1x9Z3qLKTW5j66tR0dFQYOp1jE5AFRCoNz1T7VgeBurnV 0jciM26L7Qy+U3Bg== 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 074F213A6D; Mon, 16 Jun 2025 13:52:10 +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 KJLEOoohUGhHLwAAD6G6ig (envelope-from ); Mon, 16 Jun 2025 13:52:10 +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 v7 01/11] mm,slub: Do not special case N_NORMAL nodes for slab_nodes Date: Mon, 16 Jun 2025 15:51:44 +0200 Message-ID: <20250616135158.450136-2-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250616135158.450136-1-osalvador@suse.de> References: <20250616135158.450136-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: -1.30 X-Spamd-Result: default: False [-1.30 / 50.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]; TAGGED_RCPT(0.00)[]; RSPAMD_URIBL_FAIL(0.00)[oracle.com:query timed out]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_SEVEN(0.00)[10]; 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]; RSPAMD_EMAILBL_FAIL(0.00)[david.redhat.com:query timed out,harry.yoo.oracle.com:query timed out,vbabka.suse.cz:query timed out,osalvador.suse.de:query timed out]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,suse.de:mid,suse.de:email,oracle.com:email]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; 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 Thu Oct 9 20:24:36 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 A693D292B5D for ; Mon, 16 Jun 2025 13:52:28 +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=1750081950; cv=none; b=LhVLn6JuL347ZeZb/sonFiBIVYgySUXgCEmKSHySeuuoZ1gjvwtxuoeIlPAjeJh47KjQH2kdUNgiZ+xti3CfC06OzMP6/hUf+Fvr4uSAq19t7/pNrTqjCpGqlWQ6KOARMYo21XN4BuuEbbeC74Xlh/4iZozEh13mByh4JeRZ4y0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750081950; c=relaxed/simple; bh=s3YzOzWaTjYxXpa3cQyEUcIg3S8CrnR96BeKw02Caq4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lKDgzViVsCZE018E3aL/huFnaiS/6Uu0nuBE3jm8h+BJw4PMoRDpE4J0/7ZCUZIC2K/Q5MOfG2sk6zUj5p31RHLXJzANGxTBF+RizRRDL3H6QFzW96zQjrC8v1ZiF9Ik4uVvf6TOGnwq2o6fYmTfLclO9w398VfzCaF8VyIdAOs= 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=EUS3Ivth; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=MgW6xC8E; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=vfhUVOzq; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=tIZobyKL; 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="EUS3Ivth"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="MgW6xC8E"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="vfhUVOzq"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="tIZobyKL" 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 367F31F79F; Mon, 16 Jun 2025 13:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081937; 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=9ORTOaEJ/0V7ulfpgFNty+PVV14XRbqmPaznEqXnqKg=; b=EUS3IvthS1h/vWDgmXPGgkd1+FohlVD1FpXb4EP0jAR1oxycDpf7hW8k68N0E0A7KhDFFL 1C5EaRIaLoMdsi2FT9tJEIKnlihhsot32sUZmjJLMBmqVd6nWtfL2t28/ySzyon4LLcOWX BgxXkUQHcL2Tu4r9n+8m+PpDS1nMZ40= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081937; 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=9ORTOaEJ/0V7ulfpgFNty+PVV14XRbqmPaznEqXnqKg=; b=MgW6xC8EBPtZcF8MOKpo3nXjmE/zDtIUVK+yvwx3V0z7mZF0u7ebFR6UkyaTCmdX1R8VPS JeH6MG8N4swPu/Dg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081932; 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=9ORTOaEJ/0V7ulfpgFNty+PVV14XRbqmPaznEqXnqKg=; b=vfhUVOzqPfvtJEJyPcxsI03RAtyuaN+dH2aLXSJd8nX76rBGWH2YisZ+2JAVxaiBbvYZ2o GRnxeKnUTFqOXs8gNYEC8Ae0sV0Xs4AZolpQfpqevDvLXirw+DKXnr37cHGvA8WRnCuieP QO/pr+m6x6C/wgEkdy8lg/yo7Z3deO4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081932; 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=9ORTOaEJ/0V7ulfpgFNty+PVV14XRbqmPaznEqXnqKg=; b=tIZobyKLJsT2uqjre24kAJHC2Z+Y4vwfLMgT1OzfiaFwtBEVBhOljYn61hv6WLoupcB8S5 kTp8LFXiJuynlmDA== 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 A0AB013A99; Mon, 16 Jun 2025 13:52:11 +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 AHegJIshUGhHLwAAD6G6ig (envelope-from ); Mon, 16 Jun 2025 13:52:11 +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 v7 02/11] mm,memory_hotplug: Remove status_change_nid_normal and update documentation Date: Mon, 16 Jun 2025 15:51:45 +0200 Message-ID: <20250616135158.450136-3-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250616135158.450136-1-osalvador@suse.de> References: <20250616135158.450136-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-Spam-Flag: NO X-Spam-Score: -1.80 X-Spamd-Result: default: False [-1.80 / 50.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)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RCPT_COUNT_SEVEN(0.00)[10]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; 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]; RSPAMD_EMAILBL_FAIL(0.00)[david.redhat.com:query timed out,vbabka.suse.cz:query timed out,osalvador.suse.de:query timed out]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,suse.de:mid,suse.de:email] X-Spam-Level: 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 Reviewed-by: Vlastimil Babka Acked-by: David Hildenbrand --- 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 Thu Oct 9 20:24:36 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 95B072BF018 for ; Mon, 16 Jun 2025 13:52:41 +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=1750081963; cv=none; b=At+5DbUTORhKV3HAPZMskdsZS82WDb3Ug+364s4+tftGPD17oajYX3RNVJDI+bCL0kR3Rxz8jPC0nOvevozS4amVZKTCQK0G/VwHrBHg2atFj/9i/yYA/bBT0YLzZGpmtkJTqHrmTNEu+b5aYw7+OOfWnVwTESUud/W43fCuOtM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750081963; c=relaxed/simple; bh=JJAWNDdObCm60xm7Yf9vc5TUPBTCrgDhsG5u7qT2XRI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dCXqHv0SDrooUKy2U8UWQuVHA4rCaSgVBwCY987fmsvwTRyKJOuTT+IfWeIkurmmnMZPROqamJr9JbZhvSZs5CXogXKNJgdQZeqIMgspj8OOToIh2eimWxirclGCE+a/YjLUE77Tm2phX8VmCm+EURhxxrKz2CaPmn4XU+NO8n4= 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=izQUp55O; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=BBGZTpCA; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=laWD4APh; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=By0Q2X2B; 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="izQUp55O"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="BBGZTpCA"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="laWD4APh"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="By0Q2X2B" 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 DB22C211EB; Mon, 16 Jun 2025 13:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081943; 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=6KhCve2kyWr/xX9kQ4iFPhiYOfn5SZJvT43IbhTSXS4=; b=izQUp55ORBGMJtTNsw1krVKrd+Jz99TTP4IAMFTOPK+IKKm6ACKJra17dUjcgSPARLjeGO l9bcEwoTcMjtW+sS+i6IzqcVaw3ntqEIGfJFKnswPK4HGhbBi0AVfTaDteQcVgnsQyGKXy t3cu7UJWoA6pZyYvt7Qf3wRDevDqYY4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081943; 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=6KhCve2kyWr/xX9kQ4iFPhiYOfn5SZJvT43IbhTSXS4=; b=BBGZTpCAlqCwZGb4nYrLJ94E1ZPp0s5bbuoSKIVwjywB2j5mLEte0z8aVkCtIftiLSZ0x5 w1zMYaM/KfnshzDQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=laWD4APh; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=By0Q2X2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081937; 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=6KhCve2kyWr/xX9kQ4iFPhiYOfn5SZJvT43IbhTSXS4=; b=laWD4APhip2Mnm1Kxn5awjpzsKZqyBp5P/Q2+BP7hVgaFym5DBsWf806Vdf/nwEuo3Jjuw GJn9P+mJajnxfVUr0yq3ucvWQspSfely1lQ4ArTIb5XfmLrQBDh2U0qNwzLILfwTy+kLoh P54I8oxOoh6uJmG6r13PslXS3K/NM4o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081937; 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=6KhCve2kyWr/xX9kQ4iFPhiYOfn5SZJvT43IbhTSXS4=; b=By0Q2X2Bb05RFcMK6ELXLeCA7UthWnmJ9FRySMsgOvOfwjRBTDFr3UTST0frgnUIebfgCO 28+orh459iEOYpCw== 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 445DC13AD9; Mon, 16 Jun 2025 13:52:12 +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 mAAJDowhUGhHLwAAD6G6ig (envelope-from ); Mon, 16 Jun 2025 13:52:12 +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 v7 03/11] mm,memory_hotplug: Implement numa node notifier Date: Mon, 16 Jun 2025 15:51:46 +0200 Message-ID: <20250616135158.450136-4-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250616135158.450136-1-osalvador@suse.de> References: <20250616135158.450136-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-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: DB22C211EB X-Rspamd-Action: no action X-Spam-Flag: NO X-Spamd-Result: default: False [-1.51 / 50.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)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; RSPAMD_URIBL_FAIL(0.00)[huawei.com:server fail,oracle.com:query timed out]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,huawei.com:email,oracle.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:dkim,suse.de:email]; 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)[]; DKIM_TRACE(0.00)[suse.de:+]; RSPAMD_EMAILBL_FAIL(0.00)[vbabka.suse.cz:query timed out,jonathan.cameron.huawei.com:query timed out,harry.yoo.oracle.com:query timed out,osalvador.suse.de:query timed out]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Score: -1.51 X-Spam-Level: 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 Acked-by: David Hildenbrand --- Documentation/core-api/memory-hotplug.rst | 83 +++++++++++++ drivers/base/node.c | 21 ++++ include/linux/node.h | 40 ++++++ mm/memory_hotplug.c | 144 ++++++++++------------ 4 files changed, 208 insertions(+), 80 deletions(-) diff --git a/Documentation/core-api/memory-hotplug.rst b/Documentation/core= -api/memory-hotplug.rst index d1b8eb9add8a..fb84e78968b2 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 @@ -68,6 +71,14 @@ The third argument (arg) passes a pointer of struct memo= ry_notify:: If status_changed_nid* >=3D 0, callback should create/discard structures= for the node if necessary. =20 +It is possible to get notified for MEM_CANCEL_ONLINE without having been n= otified +for MEM_GOING_ONLINE, and the same applies to MEM_CANCEL_OFFLINE and +MEM_GOING_OFFLINE. +This can happen when a consumer fails, meaning we break the callchain and = we +stop calling the remaining consumers of the notifier. +It is then important that users of memory_notify make no assumptions and g= et +prepared to handle such cases. + The callback routine shall return one of the values NOTIFY_DONE, NOTIFY_OK, NOTIFY_BAD, NOTIFY_STOP defined in ``include/linux/notifier.h`` @@ -80,6 +91,78 @@ 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. + +It is possible to get notified for NODE_CANCEL_ADDING_FIRST_MEMORY without +having been notified for NODE_ADDING_FIRST_MEMORY, and the same applies to +NODE_CANCEL_REMOVING_LAST_MEMORY and NODE_REMOVING_LAST_MEMORY. +This can happen when a consumer fails, meaning we break the callchain and = we +stop calling the remaining consumers of the notifier. +It is then important that users of node_notify make no assumptions and get +prepared to handle such cases. + +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. + +Please note that we should not fail for NODE_ADDED_FIRST_MEMORY / +NODE_REMOVED_FIRST_MEMORY, as memory_hotplug code cannot rollback at that +point anymore. + 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..d7aa2636d948 100644 --- a/include/linux/node.h +++ b/include/linux/node.h @@ -123,6 +123,46 @@ static inline void register_memory_blocks_under_node(i= nt nid, unsigned long star #endif =20 extern void unregister_node(struct node *node); + +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 + #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..e8ccfe4cada2 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) { @@ -1167,11 +1150,18 @@ void mhp_deinit_memmap_on_memory(unsigned long pfn,= unsigned long nr_pages) int online_pages(unsigned long pfn, unsigned long nr_pages, struct zone *zone, struct memory_group *group) { - unsigned long flags; - int need_zonelists_rebuild =3D 0; + struct memory_notify mem_arg =3D { + .start_pfn =3D pfn, + .nr_pages =3D nr_pages, + .status_change_nid =3D NUMA_NO_NODE, + }; + struct node_notify node_arg =3D { + .nid =3D NUMA_NO_NODE, + }; const int nid =3D zone_to_nid(zone); + int need_zonelists_rebuild =3D 0; + unsigned long flags; int ret; - struct memory_notify arg; =20 /* * {on,off}lining is constrained to full memory sections (or more @@ -1188,11 +1178,17 @@ 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); + if (!node_state(nid, N_MEMORY)) { + /* Adding memory to the node for the first time */ + node_arg.nid =3D nid; + mem_arg.status_change_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); + 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,22 @@ 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); + memory_notify(MEM_CANCEL_ONLINE, &mem_arg); + if (node_arg.nid !=3D NUMA_NO_NODE) + node_notify(NODE_CANCEL_ADDING_FIRST_MEMORY, &node_arg); remove_pfn_range_from_zone(zone, pfn, nr_pages); return ret; } @@ -1880,48 +1883,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,11 +1898,19 @@ 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 unsigned long end_pfn =3D start_pfn + nr_pages; + struct pglist_data *pgdat =3D zone->zone_pgdat; const int node =3D zone_to_nid(zone); + struct memory_notify mem_arg =3D { + .start_pfn =3D start_pfn, + .nr_pages =3D nr_pages, + .status_change_nid =3D NUMA_NO_NODE, + }; + struct node_notify node_arg =3D { + .nid =3D NUMA_NO_NODE, + }; unsigned long flags; - struct memory_notify arg; char *reason; int ret; =20 @@ -2000,11 +1969,21 @@ 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); + /* + * Check whether the node will have no present pages after we offline + * 'nr_pages' more. If so, we know that the node will become empty, and + * so we will clear N_MEMORY for it. + */ + if (nr_pages >=3D pgdat->node_present_pages) { + node_arg.nid =3D node; + mem_arg.status_change_nid =3D node; + 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); + ret =3D memory_notify(MEM_GOING_OFFLINE, &mem_arg); ret =3D notifier_to_errno(ret); if (ret) { reason =3D "notifier failure"; @@ -2084,27 +2063,32 @@ 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); + memory_notify(MEM_CANCEL_OFFLINE, &mem_arg); + if (node_arg.nid !=3D NUMA_NO_NODE) + 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 Thu Oct 9 20:24:36 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 34CB22DBF71 for ; Mon, 16 Jun 2025 13:52:35 +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=1750081956; cv=none; b=d7zYt7/cdBXa0CAeAnsKkzWTzvww+hJhj9CLtwqzGBQr9Dz1XbldA3qUnRjHuvJU9AN5UZUnZCaD7Tzk2p1B0gCzCg5D40AbbNzG9rRB3hKuFaTCmnV8XxV7q9vc7DP6l8LCOGAlSYHSAuNvcxRep9UMHjCIzR0QZeiNR00WKp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750081956; c=relaxed/simple; bh=/8TsCVZKOPE1DhRIUaatqoY0vFG3mdYqkBZFpcFjoEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f7ha1cYrADXfe6aAHxK2HWwBTHpjFDy0QgqyRvdtJOzQ7ltFQqZIweL2XUG3yG+93ScAnrjvsMgiZbMGdDDbM5vmkQUDZ2q1fQCQt/H68WTAotd0BzGupotHqEDYO6Ruew+l9T0cxmsmgDhdKqbWIz9+0NXy+MGrZaFDy6XGSUw= 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=bHV0K0Tc; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=uFbpwRGD; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=ZsErYesK; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=M5ekM3xO; 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="bHV0K0Tc"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="uFbpwRGD"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="ZsErYesK"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="M5ekM3xO" 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 78A3B1F74D; Mon, 16 Jun 2025 13:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081938; 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=HTx+hI4xt6iSJJj4xnIqdQLTXs9ciYhDC9ckQWuC4pM=; b=bHV0K0Tc2UHrdTB6pmoMJkle/JGx5tAu128OpT0+XaqtCPubWva+09OQjWl+GFTh+0GhtJ EbEohU3JIaU55N5+ARi89pWcUPKBY4dVVTQMdgybYQueAkEfAYQzsv4S5d3f9EZ6oWbu0T hNfFBNtoLIUR7cLd3zkrDYwPiaYDrbg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081938; 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=HTx+hI4xt6iSJJj4xnIqdQLTXs9ciYhDC9ckQWuC4pM=; b=uFbpwRGDOh7yrfbDCVIIoTOqURviulPjnhV7eV76YsFj2DyXcHLqMhwnc+ABOnO08Ya+X8 jS+JSdZlM4BOH/Ag== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081933; 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=HTx+hI4xt6iSJJj4xnIqdQLTXs9ciYhDC9ckQWuC4pM=; b=ZsErYesKIFG+499bMGk0cTXMjkXliQ+4zpeFmnUnHID/6QJ3GoCuNC1FJ/6Zq311pDnEGP QsIu0hEy5BH+E2OEce3KfznYkHC8SGjCNvw+3RcELcP5M7AvvvY1cVsynXTkQ3kc1dEkOJ z/9u8YZXOEzXr55eiZfVIwhxP/Al1yE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081933; 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=HTx+hI4xt6iSJJj4xnIqdQLTXs9ciYhDC9ckQWuC4pM=; b=M5ekM3xO0Kwk4MCEbfDEPURmwlYNpIWho+Y9Ggaw320rayuyJPH0d3YFSLx13olrgxxpGQ TG0r3RtPfyqX4oBQ== 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 E142013ADC; Mon, 16 Jun 2025 13:52:12 +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 MM5LM4whUGhHLwAAD6G6ig (envelope-from ); Mon, 16 Jun 2025 13:52:12 +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 v7 04/11] mm,slub: Use node-notifier instead of memory-notifier Date: Mon, 16 Jun 2025 15:51:47 +0200 Message-ID: <20250616135158.450136-5-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250616135158.450136-1-osalvador@suse.de> References: <20250616135158.450136-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 [-1.30 / 50.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]; FREEMAIL_CC(0.00)[redhat.com,suse.cz,huawei.com,oracle.com,sk.com,gmail.com,kvack.org,vger.kernel.org,suse.de]; RSPAMD_URIBL_FAIL(0.00)[oracle.com:server fail,suse.cz:server fail,huawei.com:server fail]; DBL_BLOCKED_OPENRESOLVER(0.00)[huawei.com:email,oracle.com:email,suse.de:email,suse.de:mid,suse.cz:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -1.30 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 Acked-by: David Hildenbrand --- mm/slub.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index f92b43d36adc..3ff0b94f3eeb 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -6146,7 +6146,7 @@ int __kmem_cache_shrink(struct kmem_cache *s) return __kmem_cache_do_shrink(s); } =20 -static int slab_mem_going_offline_callback(void *arg) +static int slab_mem_going_offline_callback(void) { struct kmem_cache *s; =20 @@ -6160,21 +6160,12 @@ static int slab_mem_going_offline_callback(void *ar= g) return 0; } =20 -static int slab_mem_going_online_callback(void *arg) +static int slab_mem_going_online_callback(int nid) { struct kmem_cache_node *n; struct kmem_cache *s; - struct memory_notify *marg =3D arg; - int nid =3D marg->status_change_nid; int ret =3D 0; =20 - /* - * If the node's memory is already available, then kmem_cache_node is - * already created. Nothing to do. - */ - if (nid < 0) - return 0; - /* * We are bringing a node online. No memory is available yet. We must * allocate a kmem_cache_node structure in order to bring the node @@ -6214,17 +6205,16 @@ static int slab_mem_going_online_callback(void *arg) static int slab_memory_callback(struct notifier_block *self, unsigned long action, void *arg) { + struct node_notify *nn =3D arg; + int nid =3D nn->nid; int ret =3D 0; =20 switch (action) { - case MEM_GOING_ONLINE: - ret =3D slab_mem_going_online_callback(arg); - break; - case MEM_GOING_OFFLINE: - ret =3D slab_mem_going_offline_callback(arg); + case NODE_ADDING_FIRST_MEMORY: + ret =3D slab_mem_going_online_callback(nid); break; - case MEM_ONLINE: - case MEM_CANCEL_OFFLINE: + case NODE_REMOVING_LAST_MEMORY: + ret =3D slab_mem_going_offline_callback(); break; } if (ret) @@ -6300,7 +6290,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 Thu Oct 9 20:24:36 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 068622E06D3 for ; Mon, 16 Jun 2025 13:52: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=1750081969; cv=none; b=NKXVRZr3jx32M0GKJuzUOV42ArzhDdn+FXdn4hSwyiE+kx3+SxrPP2+WY/qANYvJFh+knR9VcWJ5tHnMoS7NiVYdw8QdySquoApghqOqnBN8UKNMrz8trNJbZHGe/nxJNWRDqt8wYVSEc0n2gUP3mdApBGZR274JcFwEAJkE74U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750081969; c=relaxed/simple; bh=W0dlmMdcZZMKB393CxN/p2Hhdv/r/O+84i/CH8RZ8XE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pvOb1/3O6SJn4VwivcGnKzWtGp7mZMnsdCO3urAljntUwIs+fkKUtqa0gxpcydAASteoodtO8l7vpykp6oe9oPB+NNYxKSR3JEqGN13h8BR+Wbhkqz3aIgwZEt/Pdc3F3d5nJyTAJxJnY14hHohBxZD2GawLW/BvU+/VcBUCu1A= 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=uWPq5lR/; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=zicGrzhX; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=OMTLI/J+; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=CDZtJo7q; 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="uWPq5lR/"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="zicGrzhX"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OMTLI/J+"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="CDZtJo7q" 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 A085B1F795; Mon, 16 Jun 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081945; 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=MMNHuzJzJyLgWzan34Wy5D6D68B1qu0nQ6rptGO5Izg=; b=uWPq5lR/MqJgsqJ9Xy1C42kaxyPBOZexy5GaOuLHvV2ZITdZRuCB+yuVS2w2lebJsEXoQO pe9/d9cGp76ek9gNZ7epVBeBY/Fot5w+h2pdwyP8WsLyBpgzD6v2Jn/6zzX3pzdfCNJUbw wpO07FJ+l6VDMJWFFNTMte5icaR+8p8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081945; 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=MMNHuzJzJyLgWzan34Wy5D6D68B1qu0nQ6rptGO5Izg=; b=zicGrzhXg35a5TMjMYSfxrwqsc4YBXuWRWqH4LeiQBuDPNh/SHRJwqutXBU0/5dFSbeLkC /cncPPPaJirN1XAQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081940; 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=MMNHuzJzJyLgWzan34Wy5D6D68B1qu0nQ6rptGO5Izg=; b=OMTLI/J+HvudeExzLCThCmv/z1Smeqcq6K2h19mA4GoZifmmjyYpFOfL+S8Nwhn5NM1BZw RVkQkRgRU82pkkgsWvLnMaqeIDG5WVbfTUdq6R2DJ8AU8i0eU8rg1WmuTQ8rWiwmkkwUPa 5k1CicByJs12LHZX+tv4j2Sa81QuJ/s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081940; 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=MMNHuzJzJyLgWzan34Wy5D6D68B1qu0nQ6rptGO5Izg=; b=CDZtJo7qiCAidLzaZ+PMRDTJQ3kJdIx5Yq/TkvVNhbNLBpasjfMdVoPDhc06tbvN+q4BHf h/DZSOvUm4l/vFDQ== 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 85E8613AE1; Mon, 16 Jun 2025 13:52:13 +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 QEUWHo0hUGhHLwAAD6G6ig (envelope-from ); Mon, 16 Jun 2025 13:52:13 +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 v7 05/11] mm,memory-tiers: Use node-notifier instead of memory-notifier Date: Mon, 16 Jun 2025 15:51:48 +0200 Message-ID: <20250616135158.450136-6-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250616135158.450136-1-osalvador@suse.de> References: <20250616135158.450136-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 [-1.30 / 50.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]; TAGGED_RCPT(0.00)[]; RSPAMD_URIBL_FAIL(0.00)[suse.cz:query timed out,oracle.com:query timed out]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_SEVEN(0.00)[10]; 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]; R_RATELIMIT(0.00)[to_ip_from(RLsc83pr41xu6y1i6mw9yajrf5)]; DBL_BLOCKED_OPENRESOLVER(0.00)[huawei.com:email,oracle.com:email,imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid,suse.cz:email]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -1.30 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 Acked-by: David Hildenbrand --- mm/memory-tiers.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c index fc14fe53e9b7..0382b6942b8b 100644 --- a/mm/memory-tiers.c +++ b/mm/memory-tiers.c @@ -872,25 +872,18 @@ 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; - - /* - * Only update the node migration order when a node is - * changing status, like online->offline. - */ - if (arg->status_change_nid < 0) - return notifier_from_errno(0); + struct node_notify *nn =3D _arg; =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(nn->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(nn->nid); if (!IS_ERR(memtier)) establish_demotion_targets(); mutex_unlock(&memory_tier_lock); @@ -929,7 +922,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 Thu Oct 9 20:24:36 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 752022E06DB for ; Mon, 16 Jun 2025 13:52:49 +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=1750081971; cv=none; b=EjSc2tSQmrv+1uvwgg8Q0ym+R622iTCp+P1KW4AB5D6gyqDAGsaW3E0uR+AZHUkmgnxoPrvX/mtdwQaNY71MAN8r3VcLj3NIy+OrLciJjbTKDUFKaAiq5DddgFQp+8G1bvqI+1S5uIC6/EYziXZS4BED0BFPmaBy6dUF80ART7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750081971; c=relaxed/simple; bh=7op++JcYZ0IUdeEcoVaDhrzP5zsEfkcLzWcuVU3pl4E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SOcDOVHkrzjj/qDb5NFK7gMS4U0mSlbR62jeeYUX7DTQwKsxtGLcoWz3at1XIRFrtjl4RuOgwF+XTnld43ux6Z2t21s/jTMO9uZjsukN7vawYmwpVVdDWDTzVvnhdGe5LABxVjSYn8MIBxDPZG4iSxR6/NCI87iK7LIqnTgvmJ0= 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=THJuL96n; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=L9akPOcz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Jj8gWIuO; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=0Mt4A65e; 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="THJuL96n"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="L9akPOcz"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Jj8gWIuO"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="0Mt4A65e" 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 A53942118F; Mon, 16 Jun 2025 13:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081943; 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=0GOPVWW/FS6+WFimcJvKcp1cTSYaDvg9IjFzhzn+sIc=; b=THJuL96nOYp9/YhhSRxhZrUfRo/uuzICRAAMeyCqM0Ie9dhRytwEzAkdyG5ZEs2omU0NMf EwK5e/9JfpT8bk4ac4sY4gTbL5vmBX5ToJflt4UCx5D1Li1FCMNZoPBd1isBKqajhKU3T5 TWOUtQhp7k1qeUz5h3irRhX/pMkjKQM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081943; 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=0GOPVWW/FS6+WFimcJvKcp1cTSYaDvg9IjFzhzn+sIc=; b=L9akPOczaDkXWRuSSsdzbHbRqLaWK/uT6UJyPqpahIeBZ//To1StshVyjJKz15C7OiHrRS jrzSpTccKaLVejDA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081940; 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=0GOPVWW/FS6+WFimcJvKcp1cTSYaDvg9IjFzhzn+sIc=; b=Jj8gWIuOVbMvge7/vXRbgL0+2Mv2wGG90e0FRIVkhyxn7PptfLW9Si4vnZ70T26K8E6Ez+ COb2aL/kJPsANMiEDAkFSaVp6IZIME9nbq2fSDY2WcoDW5iX72HEU7lKUPlL/SvhDGlb4M Dt1sCnYyn2/BbXAX2Y5gF7w30e/ptOw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081940; 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=0GOPVWW/FS6+WFimcJvKcp1cTSYaDvg9IjFzhzn+sIc=; b=0Mt4A65eB8zEM5T92Ncmr2Ji3P+Lm4RSvnVLN/qpulsCdrk4S+0C5O3yaT6xzafG8C6zDh oOHe8mWYBPgyEXDg== 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 2838913AE2; Mon, 16 Jun 2025 13:52:14 +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 wKYyB44hUGhHLwAAD6G6ig (envelope-from ); Mon, 16 Jun 2025 13:52:14 +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 v7 06/11] drivers,cxl: Use node-notifier instead of memory-notifier Date: Mon, 16 Jun 2025 15:51:49 +0200 Message-ID: <20250616135158.450136-7-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250616135158.450136-1-osalvador@suse.de> References: <20250616135158.450136-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: -1.30 X-Spamd-Result: default: False [-1.30 / 50.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]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RSPAMD_URIBL_FAIL(0.00)[huawei.com:server fail,oracle.com:query timed out]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; ARC_NA(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]; R_RATELIMIT(0.00)[to_ip_from(RLsc83pr41xu6y1i6mw9yajrf5)]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; RSPAMD_EMAILBL_FAIL(0.00)[harry.yoo.oracle.com:query timed out,david.redhat.com:query timed out,vbabka.suse.cz:query timed out,jonathan.cameron.huawei.com:query timed out,osalvador.suse.de:query timed out]; DBL_BLOCKED_OPENRESOLVER(0.00)[oracle.com:email,imap1.dmz-prg2.suse.org:helo,suse.cz:email,suse.de:mid,suse.de:email,huawei.com:email] X-Spam-Level: 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 Acked-by: David Hildenbrand --- 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..261e07302ca4 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 *nn =3D arg; + int nid =3D nn->nid; int region_nid; =20 - if (nid =3D=3D NUMA_NO_NODE || action !=3D MEM_ONLINE) + if (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 Thu Oct 9 20:24:36 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 DADCD2E3395 for ; Mon, 16 Jun 2025 13:52:55 +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=1750081977; cv=none; b=BhUfOyQWvCQsOVZUCBhS8WvYIL+G5LWUWVKmr1nSF0iJ3Hxhh1Bba6kqCQ86XTUfHvnJ0J9Vg4tgNKU6xbK0ojBVCvcX8BLJw25vjv6LBjX8LR6k8E/zY+783ntZJqvwJWlpLPOJbwM5Y1eQM4Eo4pemNzGOPWO3Zqekxd4djzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750081977; c=relaxed/simple; bh=HZ7VTMFCZg/RrEaRfaqlQE/QwJsYgd6PCOTFvkwF/iE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PA6YwIAQfkSBnedWkMgQ0NRB+GnzibWr1uNl9svFWQJdS/jAnJ0PfmhVCXOhDbQ57eAnqTQx0+2Jw9PxHy4/F+CHMqN3iUDnrXbhD3HSiy8TL026Jhrbbe6qG/7eA/RLcpQhlNbt3tojH3dxfNT0hbUtzXN7H0mZS+V56yP01B0= 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=dsRoRfxL; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=265VEO8k; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=KJONCF02; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=kMzdF76e; 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="dsRoRfxL"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="265VEO8k"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="KJONCF02"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="kMzdF76e" 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 D02F1211AD; Mon, 16 Jun 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081946; 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=MRexV9IJxfAwxsTfqVeSOlBNGRbyQpxEVLWIJJKw5mQ=; b=dsRoRfxLKtdv4ei0VlI9LKBX3lMlgbWiiN6gO5OfSvYO+LCsV4vuZ6DL0Md2XBxPssLITI Zk5DdTikuSv6OCt9uWoSFPb75/qDy5qAidLOBVkGKCcZE4kBD3nncmkKbtwHzzS18+pY+u AbRU0Fyu3r58PRW+AVKSsm+nKW60uZE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081946; 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=MRexV9IJxfAwxsTfqVeSOlBNGRbyQpxEVLWIJJKw5mQ=; b=265VEO8kflQetmz3526mokfwA3LM9J1YPVjGovDCho9WDgYZCharHscG4O3k2m4HlyCnPU tX8HYaZ9sDtFdEBw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=KJONCF02; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=kMzdF76e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081941; 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=MRexV9IJxfAwxsTfqVeSOlBNGRbyQpxEVLWIJJKw5mQ=; b=KJONCF02BfvXEWl272lnT3aB8nUCYTAl6lmg7EwerSuQxGOft7+1D8VfjnqSEpLEEeobYl iv4xepdLakJHQe4dZb+A4/BnOgkTqg4fAiu2mbGdbKkiIQqELfe3WiFWmMC7pYKl2zqT3u aPToVr0HaAAPR3q0Zx0ZZAE43XElhes= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081941; 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=MRexV9IJxfAwxsTfqVeSOlBNGRbyQpxEVLWIJJKw5mQ=; b=kMzdF76es1pBSWQZTRpwT5U150VfurtN2gSD0NGMEanAKm2L56GDH+ZksvD878iLlSAYeq UntEHt87DV/IH8AA== 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 C015413AE7; Mon, 16 Jun 2025 13:52:14 +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 QBVHLI4hUGhHLwAAD6G6ig (envelope-from ); Mon, 16 Jun 2025 13:52:14 +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 v7 07/11] drivers,hmat: Use node-notifier instead of memory-notifier Date: Mon, 16 Jun 2025 15:51:50 +0200 Message-ID: <20250616135158.450136-8-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250616135158.450136-1-osalvador@suse.de> References: <20250616135158.450136-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 [-1.51 / 50.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)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; RSPAMD_URIBL_FAIL(0.00)[oracle.com:query timed out,suse.cz:query timed out]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[redhat.com,suse.cz,huawei.com,oracle.com,sk.com,gmail.com,kvack.org,vger.kernel.org,suse.de]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[huawei.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.cz:email,suse.de:dkim,suse.de:mid,suse.de:email,oracle.com:email]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_SEVEN(0.00)[10]; TAGGED_RCPT(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Level: X-Spam-Flag: NO X-Rspamd-Queue-Id: D02F1211AD X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -1.51 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 Acked-by: David Hildenbrand --- 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..4958301f5417 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 *nn =3D arg; + int pxm, nid =3D nn->nid; =20 - if (nid =3D=3D NUMA_NO_NODE || action !=3D MEM_ONLINE) + if (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 Thu Oct 9 20:24:36 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 CFAE82877F0 for ; Mon, 16 Jun 2025 13:52:41 +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=1750081963; cv=none; b=aJAXeNDiWWDv7ey6fRSyWy6huGR33C7MYLzPjmoqKMxkFMBNlJlusrhj9FJ2wbgOUuJfnORT7ybJVeRoWOCDuNtCwTqMttBHbG7v6G4qtPwrgpfCMmA27/TjvUQoumlE5sY+vfr+SRMK++MRhZsEyX38ah+j1VXgGI2nQaEOoOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750081963; c=relaxed/simple; bh=uRIz+VXav4EQnfDauh+iPVhleicrhYK6zI5Z02XIkh0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=htGpCAfNpBC42jxwi3o+nRWOm32MSvdZxtBVtR45gHQwfja/wnru7rDSLGZJtMo1rh6iGChaPgJGAmrTyuyDbpu5JWz9gZ2c+S1wJoNTASnnzh+5fJ5wFuKguD05jE81uRAIeTJndc/UNj40deBSlH+rOWWyqWQB3XpQL7WUSe4= 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=xIV6D+Wh; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=liphTJNP; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=WGghh4+k; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=39qVt0pe; 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="xIV6D+Wh"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="liphTJNP"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="WGghh4+k"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="39qVt0pe" 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 D1AF71F798; Mon, 16 Jun 2025 13:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081943; 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=qagJ6zCe/DEdOhtEMbQyUIS/FQ9HhC1GdKUsrS5yZsU=; b=xIV6D+WhsqDqaE/Qc3IJuiR8aytdRnYm2XmoXoAI+IFWEoD9QYdQQ9Vfxu6j/1dIP/znkk 51tPdQRkGAMmUSVg9ghGqtE9kDeFcBogmQhG/hIEV9vL5xsMekW2oyF+gqwYb2PZE5aN9g tasdJu8oekQ241iI4wpH95JCBt9FX0Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081943; 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=qagJ6zCe/DEdOhtEMbQyUIS/FQ9HhC1GdKUsrS5yZsU=; b=liphTJNPjGXXO6kOJLGvfrKz4kYBKWPgCH1+9WvwfEmV1nROEXjs6bMabunsNRRghj+RgG MW1snmvmo2/YuhBA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081941; 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=qagJ6zCe/DEdOhtEMbQyUIS/FQ9HhC1GdKUsrS5yZsU=; b=WGghh4+k5pLRsS48qNICFZG/0x2JFBJVjxJrgrw1kJaXCjiNzCH8WiLAWjVAgSvUVH91FC a6N/O+YcMsX8WXUv7wQK7wdcO5ANJ0YGa+DUROwni4L/74xFgraD+rtulPZNj0fRX5bjTJ F6BVC7INNT8myq5v8VqD7SJWsEK2OAQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081941; 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=qagJ6zCe/DEdOhtEMbQyUIS/FQ9HhC1GdKUsrS5yZsU=; b=39qVt0pePHsbAYTR/qddoMsoA9yo1rw04fWzP3nQ78RjdNUUChi4TsUt5Bj4YE5BysQ0FM t1zNC5EIxNM+oCBA== 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 6499C13AEB; Mon, 16 Jun 2025 13:52: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 EG/tFY8hUGhHLwAAD6G6ig (envelope-from ); Mon, 16 Jun 2025 13:52: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 v7 08/11] kernel,cpuset: Use node-notifier instead of memory-notifier Date: Mon, 16 Jun 2025 15:51:51 +0200 Message-ID: <20250616135158.450136-9-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250616135158.450136-1-osalvador@suse.de> References: <20250616135158.450136-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 [-1.30 / 50.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]; TAGGED_RCPT(0.00)[]; RSPAMD_URIBL_FAIL(0.00)[huawei.com:server fail,oracle.com:query timed out,suse.cz:query timed out]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_SEVEN(0.00)[10]; 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]; R_RATELIMIT(0.00)[to_ip_from(RLsc83pr41xu6y1i6mw9yajrf5)]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid,huawei.com:email,oracle.com:email]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -1.30 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 Thu Oct 9 20:24:36 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 E08492E4252 for ; Mon, 16 Jun 2025 13:52:53 +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=1750081975; cv=none; b=tufOM1B5HBhG/eOJUBeq/4ghE6j2ABirgC1DUIkqXc0pHrrHklNtNyMMv2rMGedkaycomizCG+/rusu+EeoczGlgSeIH/RdDOrM0CM5nzUeaf0LyXavSP8bHaEMpIhSjVgZCNGC6we7mc1WzQ0nwD21Y0U4EwKxEvl/irt3St+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750081975; c=relaxed/simple; bh=kTIgeJwBHcA+TYgIEmJHB28Qv++Tv+rlMxf8bOb+d7I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bHClEjVkn/TSFHXR41sbHBxnTCD6p5ecqEYtBvoQEcI7zpIVgjWrt0gmHNlCJZ1H+iKY6IeqDkM42kV5AKwWwhA1AbxgL/3L42nOeWH1GHr3Obdfg4mCuODKRDrqN39UBf3CLfF+aSWkBHAl41++jeOBBlJzqB40s/EH3wEQl3k= 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=QFt+mI3v; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=PhCsFBJI; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=tn19BeKV; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=aILlNkjg; 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="QFt+mI3v"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="PhCsFBJI"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="tn19BeKV"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="aILlNkjg" 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 4459B1F79A; Mon, 16 Jun 2025 13:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081947; 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=kvQ93fpE+S5r7kCRZqpZhmVWGTpofUKn8LF66RwQceA=; b=QFt+mI3vXjn6x8BZL3La4acdV780kVqsi1tUP+Sk96R1YvH9Tx6rhGlzKcRMGm4U/ueVRJ 8Sl+DT+SgBlN6fszzfoq4fhPEMIcZavIVTEcJViE/PlF+IEF01FEjuBrm4Jb1H9JlfDuPW cXK5F8BKt+YhW/PF6+DGS/aQuBx2/l4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081947; 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=kvQ93fpE+S5r7kCRZqpZhmVWGTpofUKn8LF66RwQceA=; b=PhCsFBJI68RCCn7UtN2M56Zw41nMFf2duu6CZpPthmZoRHIW4JDRwkLDNsFqan22vkwSSr XcEyyTuy/rGvFCAA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=tn19BeKV; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=aILlNkjg DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081942; 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=kvQ93fpE+S5r7kCRZqpZhmVWGTpofUKn8LF66RwQceA=; b=tn19BeKVQq/FmlR5L8u+gGv60Jeypk4uB1aIsa+JXjkzNfjHbU8fY89BRu7Vffo+/GseRz WTougCEQgABCVJQIY610ksLIg7cL1QLNQ1DqjVi9yWvzRC6G9+SOpnP1CdgGG5mz9bs7RZ gK3Zy7Iutgjnyl1NYT8oOdAND0xnASk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081942; 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=kvQ93fpE+S5r7kCRZqpZhmVWGTpofUKn8LF66RwQceA=; b=aILlNkjgUfKOfj0+MeDYbSzMCMmR8DyarjRJ8Ps0kOcIvLI3EQ8eQMEgHo0zf7SbmPnQAZ kTZSmtOSbdy+NDAA== 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 096C113AEE; Mon, 16 Jun 2025 13:52: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 IC8vO48hUGhHLwAAD6G6ig (envelope-from ); Mon, 16 Jun 2025 13:52: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 v7 09/11] mm,mempolicy: Use node-notifier instead of memory-notifier Date: Mon, 16 Jun 2025 15:51:52 +0200 Message-ID: <20250616135158.450136-10-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250616135158.450136-1-osalvador@suse.de> References: <20250616135158.450136-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-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 4459B1F79A X-Rspamd-Action: no action X-Spam-Flag: NO X-Spamd-Result: default: False [-1.51 / 50.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)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; RSPAMD_URIBL_FAIL(0.00)[oracle.com:query timed out,sk.com:query timed out]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,suse.de:email,suse.cz:email,huawei.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,oracle.com:email]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; FROM_EQ_ENVFROM(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]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; TAGGED_RCPT(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RL13d73xi3shrbuzu7ftfs459h)]; RSPAMD_EMAILBL_FAIL(0.00)[jonathan.cameron.huawei.com:server fail,harry.yoo.oracle.com:query timed out,david.redhat.com:query timed out,vbabka.suse.cz:query timed out,osalvador.suse.de:query timed out,rakie.kim.sk.com:query timed out]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Score: -1.51 X-Spam-Level: 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 Acked-by: David Hildenbrand --- mm/mempolicy.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 72fd72e156b1..693319c2652d 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -3793,20 +3793,17 @@ 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; - - if (nid < 0) - return NOTIFY_OK; + struct node_notify *nn =3D data; + int nid =3D nn->nid; =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 +3842,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 Thu Oct 9 20:24:36 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 0CA4E2BF018 for ; Mon, 16 Jun 2025 13:52:35 +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=1750081957; cv=none; b=Jh/QdpGJDr3xC0OR5dgg4cdymFP8BSsT71KPn8iE162y8OfNsXCnEGc5YO/a/2iZiO2JNeitGMg8QMKBB1pj1LPYJssp+W+7e2XvEw7wc9CsbwcBSU+fE4f8WDedS3KfYZKAagHmjaokqmnlZVxhxX831xMHqLQKWsva5CQOm8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750081957; c=relaxed/simple; bh=McIBe5rjHEh6+UlWK5PHMkSkm0ITwlqwRONiJNK4ryM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HINyiFuEZwCLcZ0ADUPCPvfAEYEaBmtprS39dxY+v2KKzCfZwMT522Go/C7knHAOzh2oNyITp61qR0hZOPe+3yct4mS0WrUNUi1n0+MFjj/XJ0MNB7Pnx7RURyOozkqPi0h3g8SvpHXsScJrOUInitwD9QOWywlMTBtP0UTf8NI= 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=Puinu84S; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=/qjERsN/; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=NIsw3b2K; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=jc9ioTjv; 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="Puinu84S"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="/qjERsN/"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="NIsw3b2K"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="jc9ioTjv" 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 47D06211F2; Mon, 16 Jun 2025 13:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081943; 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=GQkEClDP0wrzDDOsHwrNIl3nI8G2kqil/mCtolIEaQ0=; b=Puinu84S/THIZbGL7+grRK744YM9p6O4ydy1pE0hF2kEXSD7j3mcy9ooHSkaoYcN8mLVZN 80lkpZ6U3l1HzZR7B8eL5RGzxXGbbFl8BK23etYsEYUspcX1PpGm2z0GekHyR5XDNY8dtC ipuOMn8LuEX8AAcvNxWNAQo+yeadd80= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081943; 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=GQkEClDP0wrzDDOsHwrNIl3nI8G2kqil/mCtolIEaQ0=; b=/qjERsN/mZ0gWixnZ83sE71OKrJ7AZtgl2SZbwGgbt8mWavPABsx3fJ0iwSmSxF2XT83aH hKqBT+j5mEA5heAg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081942; 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=GQkEClDP0wrzDDOsHwrNIl3nI8G2kqil/mCtolIEaQ0=; b=NIsw3b2KjfLPUUkgQidAn5l/vz39+xC2PHf2jP4fMjRzJ8uzljqfaGZnyQOaVbjGed5JVn rgW/oqB2lAZrVFvZDyWlweFtNNMy6yPmUQmKqHSx68cCNhfaboR7XXtQhyokCYA7GYSgeZ eJvdfswxczmqPXjv/dpVmdguFpLms24= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081942; 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=GQkEClDP0wrzDDOsHwrNIl3nI8G2kqil/mCtolIEaQ0=; b=jc9ioTjvdemVgFrh1TRaIapA4LQI50s9MqUVY9CogW5h5ScxvWRBl8ZTP1G49bCuq5ufW+ o6ZP7h9Goa9gQCAw== 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 A1F5D13AEF; Mon, 16 Jun 2025 13:52: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 oB3wJJAhUGhHLwAAD6G6ig (envelope-from ); Mon, 16 Jun 2025 13:52: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 v7 10/11] mm,page_ext: Derive the node from the pfn Date: Mon, 16 Jun 2025 15:51:53 +0200 Message-ID: <20250616135158.450136-11-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250616135158.450136-1-osalvador@suse.de> References: <20250616135158.450136-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 [-1.30 / 50.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]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RSPAMD_URIBL_FAIL(0.00)[suse.cz:query timed out,oracle.com:query timed out]; FREEMAIL_CC(0.00)[redhat.com,suse.cz,huawei.com,oracle.com,sk.com,gmail.com,kvack.org,vger.kernel.org,suse.de]; RCVD_TLS_ALL(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLsc83pr41xu6y1i6mw9yajrf5)]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[oracle.com:email,imap1.dmz-prg2.suse.org:helo,suse.cz:email,suse.de:email,suse.de:mid]; TAGGED_RCPT(0.00)[]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -1.30 Content-Type: text/plain; charset="utf-8" page_ext is the only user of 'status_change_nid', which is set in online/offline operations, to know to which node we are adding/removing memory. Prior to call any notifiers, the memmap is initialized via, which among other things, sets the node the pages belong to, to all corresponging pages. This means that there is no need to keep using 'status_change_nid' since we can derive the node from the pfn. This will allow us to finally drop 'status_change_nid' from the memory_noti= fy struct. Suggested-by: David Hildenbrand Signed-off-by: Oscar Salvador Reviewed-by: Harry Yoo Reviewed-by: Vlastimil Babka Acked-by: David Hildenbrand --- mm/page_ext.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/mm/page_ext.c b/mm/page_ext.c index c351fdfe9e9a..d7396a8970e5 100644 --- a/mm/page_ext.c +++ b/mm/page_ext.c @@ -369,25 +369,15 @@ static void __invalidate_page_ext(unsigned long pfn) } =20 static int __meminit online_page_ext(unsigned long start_pfn, - unsigned long nr_pages, - int nid) + unsigned long nr_pages) { + int nid =3D pfn_to_nid(start_pfn); unsigned long start, end, pfn; int fail =3D 0; =20 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) @@ -435,8 +425,7 @@ static int __meminit page_ext_callback(struct notifier_= block *self, =20 switch (action) { case MEM_GOING_ONLINE: - ret =3D online_page_ext(mn->start_pfn, - mn->nr_pages, mn->status_change_nid); + ret =3D online_page_ext(mn->start_pfn, mn->nr_pages); break; case MEM_OFFLINE: offline_page_ext(mn->start_pfn, --=20 2.49.0 From nobody Thu Oct 9 20:24:36 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 C70F02BF018 for ; Mon, 16 Jun 2025 13:52: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=1750081951; cv=none; b=k78dgQ3/PzapE0aLGeeeqoZhyE7VJ3HeE8CWoBDTk62nQa9woZ048ZLJQpr+HEHNM8EmY9aTnpGBR0/jSjyoYe1sFWQy1tge8p0ZIH8vgft3mkMUP2Snz91CeMfvd7x6wwULPTBzRGO84sEctBOF/drHsWLPmgJDxQjHytAU7SI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750081951; c=relaxed/simple; bh=NuvAG5Ic7stlgpTDpW1Ft+SUtgwCL1O/JOF3GB6Clf0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T84n8feMrIlFOuqKmX8IBwmn10g7cEV97NX8VVnUP5+q2BifEcQgz+8dL8wfy/Lu78lUXHhbNzf5XCpqHHnWvMpSxBZFCeIWOVWtInDn+i4/5+iPhNC8v8fcNKhNIupPVctcHwtruJS9fIcJnPR3lnHpE9DFmsbwjplUXJbVDjA= 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=RbZwnZZz; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=c7ga4orI; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=RbZwnZZz; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=c7ga4orI; 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="RbZwnZZz"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="c7ga4orI"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="RbZwnZZz"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="c7ga4orI" 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 82C51211E8; Mon, 16 Jun 2025 13:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081943; 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=QwIgB06OxaspRxHAY+9bd+ehKx+2dZwQV4n7zKbdfq8=; b=RbZwnZZzNxkdmyLx+iPMvU+wPqlL8I9WR+GrFYz3KH2F5G98PiQhcRzc1BBIq0p8fxNgQQ 9Un/o6oOx+znwKumCcAcuZg70yuR8fyD5U8HsYMvhUgUVncy4uNz2Ie77r6wLH0thQjwpw NfEwVl+qwBqo+TgkkUQaBAW5Q+nhbCM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081943; 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=QwIgB06OxaspRxHAY+9bd+ehKx+2dZwQV4n7zKbdfq8=; b=c7ga4orIVC00MD6dDsTpwW45tgdPIc7C2BBRF+sr7zCmBipwX/EhJPJbUcUdjyqXB+FuUf xGudF2PXBL62RtBg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1750081943; 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=QwIgB06OxaspRxHAY+9bd+ehKx+2dZwQV4n7zKbdfq8=; b=RbZwnZZzNxkdmyLx+iPMvU+wPqlL8I9WR+GrFYz3KH2F5G98PiQhcRzc1BBIq0p8fxNgQQ 9Un/o6oOx+znwKumCcAcuZg70yuR8fyD5U8HsYMvhUgUVncy4uNz2Ie77r6wLH0thQjwpw NfEwVl+qwBqo+TgkkUQaBAW5Q+nhbCM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1750081943; 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=QwIgB06OxaspRxHAY+9bd+ehKx+2dZwQV4n7zKbdfq8=; b=c7ga4orIVC00MD6dDsTpwW45tgdPIc7C2BBRF+sr7zCmBipwX/EhJPJbUcUdjyqXB+FuUf xGudF2PXBL62RtBg== 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 47F1E13AF1; Mon, 16 Jun 2025 13:52: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 ePvhDpEhUGhHLwAAD6G6ig (envelope-from ); Mon, 16 Jun 2025 13:52: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 v7 11/11] mm,memory_hotplug: Drop status_change_nid parameter from memory_notify Date: Mon, 16 Jun 2025 15:51:54 +0200 Message-ID: <20250616135158.450136-12-osalvador@suse.de> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250616135158.450136-1-osalvador@suse.de> References: <20250616135158.450136-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 [-1.30 / 50.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]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo]; ARC_NA(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]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; R_RATELIMIT(0.00)[to_ip_from(RLsc83pr41xu6y1i6mw9yajrf5)]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -1.30 Content-Type: text/plain; charset="utf-8" There no users left of status_change_nid, so drop it from memory_notify struct. Suggested-by: David Hildenbrand Signed-off-by: Oscar Salvador Acked-by: David Hildenbrand --- Documentation/core-api/memory-hotplug.rst | 7 ------- include/linux/memory.h | 1 - mm/memory_hotplug.c | 4 ---- 3 files changed, 12 deletions(-) diff --git a/Documentation/core-api/memory-hotplug.rst b/Documentation/core= -api/memory-hotplug.rst index fb84e78968b2..8fc97c2379de 100644 --- a/Documentation/core-api/memory-hotplug.rst +++ b/Documentation/core-api/memory-hotplug.rst @@ -59,17 +59,10 @@ 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; } =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. =20 It is possible to get notified for MEM_CANCEL_ONLINE without having been n= otified for MEM_GOING_ONLINE, and the same applies to MEM_CANCEL_OFFLINE and diff --git a/include/linux/memory.h b/include/linux/memory.h index a9ccd6579422..de8b898ada3f 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; }; =20 struct notifier_block; diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index e8ccfe4cada2..bfaa570c0685 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1153,7 +1153,6 @@ int online_pages(unsigned long pfn, unsigned long nr_= pages, struct memory_notify mem_arg =3D { .start_pfn =3D pfn, .nr_pages =3D nr_pages, - .status_change_nid =3D NUMA_NO_NODE, }; struct node_notify node_arg =3D { .nid =3D NUMA_NO_NODE, @@ -1181,7 +1180,6 @@ int online_pages(unsigned long pfn, unsigned long nr_= pages, if (!node_state(nid, N_MEMORY)) { /* Adding memory to the node for the first time */ node_arg.nid =3D nid; - mem_arg.status_change_nid =3D nid; ret =3D node_notify(NODE_ADDING_FIRST_MEMORY, &node_arg); ret =3D notifier_to_errno(ret); if (ret) @@ -1905,7 +1903,6 @@ int offline_pages(unsigned long start_pfn, unsigned l= ong nr_pages, struct memory_notify mem_arg =3D { .start_pfn =3D start_pfn, .nr_pages =3D nr_pages, - .status_change_nid =3D NUMA_NO_NODE, }; struct node_notify node_arg =3D { .nid =3D NUMA_NO_NODE, @@ -1976,7 +1973,6 @@ int offline_pages(unsigned long start_pfn, unsigned l= ong nr_pages, */ if (nr_pages >=3D pgdat->node_present_pages) { node_arg.nid =3D node; - mem_arg.status_change_nid =3D node; ret =3D node_notify(NODE_REMOVING_LAST_MEMORY, &node_arg); ret =3D notifier_to_errno(ret); if (ret) --=20 2.49.0