From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5598C5B543 for ; Tue, 10 Jun 2025 08:10:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 326616B008C; Tue, 10 Jun 2025 04:10:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FDB56B0092; Tue, 10 Jun 2025 04:10:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 213946B0093; Tue, 10 Jun 2025 04:10:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id ECED96B008C for ; Tue, 10 Jun 2025 04:10:32 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7926EC15DC for ; Tue, 10 Jun 2025 08:10:32 +0000 (UTC) X-FDA: 83538769104.20.DB57342 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 9497E10000A for ; Tue, 10 Jun 2025 08:10:29 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P3whfM5U; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749543029; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XBF5G6xXJgxVi2vMYnM2PoWsVLDMf3ZJWcnIVkEvmXs=; b=ghm8cpB/EGvJK/QrmQnVww18RU6+3S8bZ6MXsbygYh999SMAzWPxBFQjEvOamrqOaQaP3c Ug+smDT5VQsjh492OqEsMY5+oXzMz1VP+iD9QpcrKr7PrB5wqOe0YHvU2ArdJ8X29va83S 3zmAckahg2AiQVa/yCCFapi1meHfuXQ= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P3whfM5U; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749543029; a=rsa-sha256; cv=none; b=PGbNTD0eeudHLkOQhJDU4xUZjpr4m8qOQVXqs/ceOUpOsueop3BSUHX9F0KcDc7t6lnl6D KbowxwaNIhAKITmfvcDacuuR7Hx7wn4/suKwyQezsquGxeNX1VWUipHAvyhz/VDJUJC6yM pAAS0ICyZBizgxRdq17VAVa1vCNJWaM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749543029; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=XBF5G6xXJgxVi2vMYnM2PoWsVLDMf3ZJWcnIVkEvmXs=; b=P3whfM5UPjSKKqOjxMPnCRFGLu1m0aGLU2eJXvvPfSq6xGulDtoZ9Lcmep0QXBeDLoMbfD epoNkTLzXe64ijOZ+0zF12Qi7ENnHlyYZzatIawoY5lgNs4aEkv7jWGdEbN1dtOXeP+FL7 MqQos0B8b4WId/Y2BrICuMExvtg+90o= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-31-UPsd1dWGMFma4vbn-VaUOQ-1; Tue, 10 Jun 2025 04:10:24 -0400 X-MC-Unique: UPsd1dWGMFma4vbn-VaUOQ-1 X-Mimecast-MFC-AGG-ID: UPsd1dWGMFma4vbn-VaUOQ_1749543024 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-451deff247cso28068985e9.1 for ; Tue, 10 Jun 2025 01:10:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749543024; x=1750147824; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=XBF5G6xXJgxVi2vMYnM2PoWsVLDMf3ZJWcnIVkEvmXs=; b=d6N26BKayzPIcsvpxn1EwNdYCRlMkjmcpe1Y2X3WMM60/l7/XubLz448uFI1ZCXcfc HPtV0rJ2vZdluhAzCrrz8qOFHItvj4ZFBfJfixcbpF+PMNs60uHLFw3a3qHl5WTm+Kfq Fi28uZr3J0qZ5AWvZLnNMHUzBIOrNxnm02IG8dchBND+d5l6aOAOo8yqOeNDA01KOddL eJ1nUBWYnyf4OMC1mQQG03zalGrVCgLMB/6RWUEJXdApZmBaa/59MkBF9YhP+HbphCVy 30c2rN5WHt8m4fqoWcW0uMbR7gbfZdyjdb5hPU5ruW+becThlrR9G6lGy1Kvx14F3dnH 0cog== X-Forwarded-Encrypted: i=1; AJvYcCX7f0DnUb4f7+aAJUJlW9Rz+gPJVuRHFT9L92vallA3xBaXmnHZ8GCLLHq+me/9bhtHtUfninhtEg==@kvack.org X-Gm-Message-State: AOJu0YwZhnkaWvbRKwtea1Sn2/fQUAQuDsBBbFUGAUAiwpo8PPyAev9E 4WDkILKBhjwU3qoOA8G+QHCXA2Dk3vQEK+cCMs9Tw/fWKtFRKNQNXJZJlck4jZUPUZRWBxxDiCu GZeyGsNv+lMmgbP70ZP1U9C1gLnW7PtcfKdTw2C6/xulOX0cxuMnH X-Gm-Gg: ASbGncuwMkcmGoZaNdsxpQaAGtAE57VhIwegmESNqLxEJ0nLbHgQ83MIBXI+JhjuwIz yzDZ9xLI8XUMt0HksgcdHFNwBC9S6sTU6duNv0Kb9VSbbzTx08+H39QRP8JThF9laHWv9toi9MU Tz38HHN68R/2eUo/uWeYzOxoLHUhpeMqatI2KeY2YWNwy6Q1lGuFyRd/rkrzkoTSgzg9zO3mfH0 7cC8RaxTBnJ3/Rucsi7LMbaJvGJosdXrpUrIVl5pFmB/QGfwKCMH03YUTIEBX9q5MokxWHZJO6y cafV+hLcas6pjD9pqZVbRb7pdusG27YMF59XMv0Qfte7t6mxOKw0ELo= X-Received: by 2002:a5d:64e3:0:b0:3a5:271e:c684 with SMTP id ffacd0b85a97d-3a55142089emr1990663f8f.24.1749543023672; Tue, 10 Jun 2025 01:10:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmc32OVn4VB6Y16DXAXXYh1Z/B1ThbVQcP1o7+AJvFTD7BDPcrczU9YvnUVKFluEmO2SNCRw== X-Received: by 2002:a5d:64e3:0:b0:3a5:271e:c684 with SMTP id ffacd0b85a97d-3a55142089emr1990623f8f.24.1749543023224; Tue, 10 Jun 2025 01:10:23 -0700 (PDT) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4526e055d2asm131752915e9.2.2025.06.10.01.10.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Jun 2025 01:10:22 -0700 (PDT) Message-ID: <2bec8b53-f788-493e-a76e-1f804ed3aa0c@redhat.com> Date: Tue, 10 Jun 2025 10:10:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 03/10] mm,memory_hotplug: Implement numa node notifier To: Oscar Salvador , Andrew Morton Cc: Vlastimil Babka , Jonathan Cameron , Harry Yoo , Rakie Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Joshua Hahn , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20250609092149.312114-1-osalvador@suse.de> <20250609092149.312114-4-osalvador@suse.de> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxwocmqaRr6UYmrtZmND89X0KigoFD/XSeVv jwBRNjPAubK9/k5NoRrYqztM9W6sJqrH8+UWZ1Idd/DdmogJh0gNC0+N42Za9yBRURfIdKSb B3JfpUqcWwE7vUaYrHG1nw54pLUoPG6sAA7Mehl3nd4pZUALHwARAQABzSREYXZpZCBIaWxk ZW5icmFuZCA8ZGF2aWRAcmVkaGF0LmNvbT7CwZgEEwEIAEICGwMGCwkIBwMCBhUIAg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veQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20250609092149.312114-4-osalvador@suse.de> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: rXvyRcqMWL1GEGdpholrsC2ARgLqN6TVIDHywuKN-e0_1749543024 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 9497E10000A X-Stat-Signature: u73omhipuwcco9477s3bahokirckbk35 X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1749543029-27617 X-HE-Meta: U2FsdGVkX1/ZvwZAJFu/yYlfXcM+WS/QDIVIC8dpefEDDCTT+dgNiKRgUqNXkAde3qZypbGDin8xGbaUUskNGXSSyp5gErry6GuiYXKM1F6SL4HKf4T5vrWQrVB7W0HEBTSvDYl47m0RaLvRsh8btN/Ghy91CYzFdfR8IZpFAsNHSAhkhMgvnu3dXQGe/uVCjAJDSUzuk/CxoqwpjQvDrOwd3wh7ZkiFU4ZGw9wF6vlpWuHthVs1eyRQYsVNFkCohf2uGC19lBbBJyAppEQSdB2ScXNhtd4lVXLsh8vcGGRCxZ7utNxrzYUkEgH9nLNAyUWCc9cllMYSys+VyNYE2o+UTNgnH0nNdaAPKFQFW3sNIW6C/gz1xqOVcorZ4UzIimcS6396iuZ3VA9Kq9tKCsMNfLQzUbtDoyIeT4D0PuDKn0dFzsc6DpXkfwhDCrfgm7NNy/La9eYI1SEoph/XcPwOFTKh7RZLgXQL5XiaFhAvTMk0TntD9aHxBN/HG0d/JxFSbjYJfjEm3FGpGzeYa1n1Cv42aY0Nh9cAhYsM9trqFAqCKIBHU92KF/5R0S93Xj/sHGlerFBqUPxXdyMn0BPAICFFSSyRa8JfRjSEzrytJRIocSTTNHVendNy9DWNrJcEdS1moAZP+qUi5yM5YkYolS8zdi12mr4hRg5wMEGCyhMjU+PFvPBYEgovR0KmDdG61pWi5CG8TwVCdWYi/eO+fOhOdk3zaVGKaLI6jGDzGrdHzNpaW15VkM5Zn8+3gnvUPmwtQM2QVGgC1rqlNcFjpE06Ss18xh9AFAl0bqEgp7MNtK8gRc13Z6cNVE1omgHKlUrDSqQsVzag8sv0tfYOHtzCeW02NHEFMRIHgOjoMQBI5VH2/sabgKi9J6oDwlvyw9lv0LL1X1Gn9mJmwdmWR1O8zMCJWxhKYs6PY0VBqwsza797RMB5//BNFVuWd7cb/UQUvLAZrcO8tyF oFHugPo9 aMZHrTFOpFauMluGwDbcreFSoDgjTNnVb3BqLesUGb3BF86Xd5emZulqvhWs9Tibsg43JEUDBHqjV+Yp/8qkc4GycXP7939VdfcYOsIO/p2tDBEo2OmEV6fSHGDBSZxo5B16XDs00sPmXGq2IbWdRmJAWu3oa4brWuPXRgKbexKekgllCayciRYSXanZPzLbKB82UXWNb4Bm5Q/GiZkC/GceKx6zRMgQXtWk/mhvcYAxFtHLzlylk0zR7BjPQ+dUD80Cl4jsKHbSqaq1/tJIH/ThMKszkMKITqG8VHUPiUN2Z0u/k/s0FcahCITHKmqCiOlYLmFu3AQ5rzytXXpFeC/UMw07NmL9of+eqhGOUPCE7diCspcwo3K2kiTd13b99Ip7/PfXaVBZjAGnHRa59ER4GJvnlp8/XpZrUS1kq3MqN4KUBSoaLKHbwFepOJXpqgK8oc5mtD+jO/Df1sGIp0DSjDRsY7MHfqQpQEBLv/GrdidHmKT7xBZVfzK+71ySBenXMNZ/E4a/V13VyqYuxGcNDCX+VwB8Kj6HEoyoSGwZ/JmfRqz/eX6QzTiIR22vrKDnfIrnVfoJtEU6xhoQ5YGxSrtS9nPnZLZQPtfxSxynujU7j8ZjaBgkuuQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 09.06.25 11:21, Oscar Salvador wrote: > 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: going > from having memory to not having memory and vice versa. > > Implement a specific notifier for numa nodes when their state gets changed, > which will later be used by those consumers that are only interested > in numa node state changes. > > Add documentation as well. > > Signed-off-by: Oscar Salvador > Reviewed-by: Jonathan Cameron > Reviewed-by: Harry Yoo > Reviewed-by: Vlastimil Babka > --- > Documentation/core-api/memory-hotplug.rst | 66 +++++++++ > drivers/base/node.c | 21 +++ > include/linux/node.h | 40 ++++++ > mm/memory_hotplug.c | 155 ++++++++++------------ > 4 files changed, 200 insertions(+), 82 deletions(-) > > diff --git a/Documentation/core-api/memory-hotplug.rst b/Documentation/core-api/memory-hotplug.rst > index d1b8eb9add8a..b19c3be7437d 100644 > --- a/Documentation/core-api/memory-hotplug.rst > +++ b/Documentation/core-api/memory-hotplug.rst > @@ -9,6 +9,9 @@ Memory hotplug event notifier > > Hotplugging events are sent to a notification queue. > > +Memory notifier > +---------------- > + > There are six types of notification defined in ``include/linux/memory.h``: > > MEM_GOING_ONLINE > @@ -80,6 +83,69 @@ further processing of the notification queue. > > NOTIFY_STOP stops further processing of the notification queue. > > +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 time. > + > +NODE_REMOVING_LAST_MEMORY > + Generated when the last memory available to this node is about to be offlined. > + > +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 callback > +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 block > +of the notifier chain that points to the callback function itself. > +The second argument (action) is one of the event types described above. > +The third argument (arg) passes a pointer of struct node_notify:: > + > + struct node_notify { > + int nid; > + } > + > +- nid is the node we are adding or removing memory to. > + > + If nid >= 0, callback should create/discard structures for the > + node if necessary. Likely that should be removed? It' probably worth mentioning that one might get notified about NODE_CANCEL_ADDING_FIRST_MEMORY even though never notified for NODE_ADDING_FIRST_MEMORY. (same for removing) I recall this can happen if one of the NODE_ADDING_FIRST_MEMORY notifiers fails. (same applies to MEM_CANCEL_*) Consequently, we might simplify the cancel_mem_notifier_on_err etc stuff, simply unconditionally calling the cancel counterparts. > + > +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. Should we docunment that failing NODE_ADDED_FIRST_MEMORY / NODE_REMOVED_FIRST_MEMORY is very bad? > + > Locking Internals > ================= > > 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[] = { > NULL, > }; > > +#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(int nid, unsigned long star > #endif > > 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 =\ > + { .notifier_call = fn, .priority = 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..0550f3061fc4 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -35,6 +35,7 @@ > #include > #include > #include > +#include > > #include > > @@ -699,24 +700,6 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages) > online_mem_sections(start_pfn, end_pfn); > } > > -/* 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 = zone_to_nid(zone); > - > - arg->status_change_nid = NUMA_NO_NODE; > - > - if (!node_state(nid, N_MEMORY)) > - arg->status_change_nid = nid; > -} > - > -static void node_states_set_node(int node, struct memory_notify *arg) > -{ > - if (arg->status_change_nid >= 0) > - node_set_state(node, N_MEMORY); > -} > - > static void __meminit resize_zone_range(struct zone *zone, unsigned long start_pfn, > unsigned long nr_pages) > { > @@ -1171,7 +1154,9 @@ int online_pages(unsigned long pfn, unsigned long nr_pages, > int need_zonelists_rebuild = 0; > const int nid = zone_to_nid(zone); > int ret; > - struct memory_notify arg; > + struct memory_notify mem_arg; > + struct node_notify node_arg; > + bool cancel_mem_notifier_on_err = false, cancel_node_notifier_on_err = false; Prefer reverse xmas tree ... :) [...] > - > static int count_system_ram_pages_cb(unsigned long start_pfn, > unsigned long nr_pages, void *data) > { > @@ -1937,13 +1899,17 @@ static int count_system_ram_pages_cb(unsigned long start_pfn, > int offline_pages(unsigned long start_pfn, unsigned long nr_pages, > struct zone *zone, struct memory_group *group) > { > - const unsigned long end_pfn = start_pfn + nr_pages; > - unsigned long pfn, managed_pages, system_ram_pages = 0; > - const int node = zone_to_nid(zone); > - unsigned long flags; > - struct memory_notify arg; > - char *reason; > int ret; > + char *reason; > + enum zone_type zt; > + unsigned long flags; > + struct memory_notify mem_arg; > + struct node_notify node_arg; > + const int node = zone_to_nid(zone); > + struct pglist_data *pgdat = zone->zone_pgdat; > + const unsigned long end_pfn = start_pfn + nr_pages; > + unsigned long pfn, managed_pages, system_ram_pages = 0, present_pages = 0; > + bool cancel_mem_notifier_on_err = false, cancel_node_notifier_on_err = false; You'r now reversing the reversed christmas tree :) > > /* > * {on,off}lining is constrained to full memory sections (or more > @@ -2000,11 +1966,30 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages, > goto failed_removal_pcplists_disabled; > } > > - arg.start_pfn = start_pfn; > - arg.nr_pages = nr_pages; > - node_states_check_changes_offline(nr_pages, zone, &arg); > + /* > + * Here we count the possible pages within the range [0..ZONE_MOVABLE]. > + * If after having accounted all the pages, we see that the nr_pages to > + * be offlined is greater or equal to the accounted pages, we know that the > + * node will become empty, and so, we will clear N_MEMORY for it. > + */ > + node_arg.nid = NUMA_NO_NODE; > + for (zt = 0; zt <= ZONE_MOVABLE; zt++) > + present_pages += pgdat->node_zones[zt].present_pages; Why can't we look at node_present_pages? -- Cheers, David / dhildenb