From: Gregory Price <gourry@gourry.net>
To: Rakie Kim <rakie.kim@sk.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org,
joshua.hahnjy@gmail.com, dan.j.williams@intel.com,
ying.huang@linux.alibaba.com, kernel_team@skhynix.com,
honggyu.kim@sk.com, yunjeong.mun@sk.com, david@redhat.com
Subject: Re: [PATCH v2 2/4] mm/mempolicy: Support memory hotplug in weighted interleave
Date: Thu, 13 Mar 2025 12:23:19 -0400 [thread overview]
Message-ID: <Z9MGdwrgX8dYeHha@gourry-fedora-PF4VCD3F> (raw)
In-Reply-To: <20250313063351.692-1-rakie.kim@sk.com>
On Thu, Mar 13, 2025 at 03:33:37PM +0900, Rakie Kim wrote:
> > I'm fairly certain this logic is wrong. If I add two memory blocks and
> > then remove one, would this logic not remove the sysfs entries despite
> > there being a block remaining?
>
> Regarding the assumption about node configuration:
> Are you assuming that a node has two memory blocks and that
> MEM_OFFLINE is triggered when one of them is offlined? If so, then
> you are correct that this logic would need modification.
>
> I performed a simple test by offlining a single memory block:
> # echo 0 > /sys/devices/system/node/node2/memory100/online
>
> In this case, MEM_OFFLINE was not triggered. However, I need to
> conduct further analysis to confirm this behavior under different
> conditions. I will review this in more detail and share my
> findings, including the test methodology and results.
>
+David - might have a quick answer to this. I would have expected a
single memory block going offline to cause a notification.
I think the logic we care about is here:
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;
arg->status_change_nid_normal = NUMA_NO_NODE;
if (!node_state(nid, N_MEMORY))
arg->status_change_nid = nid;
if (zone_idx(zone) <= ZONE_NORMAL && !node_state(nid, N_NORMAL_MEMORY))
arg->status_change_nid_normal = nid;
}
static void node_states_set_node(int node, struct memory_notify *arg)
{
if (arg->status_change_nid_normal >= 0)
node_set_state(node, N_NORMAL_MEMORY);
if (arg->status_change_nid >= 0)
node_set_state(node, N_MEMORY);
}
int online_pages(unsigned long pfn, unsigned long nr_pages,
struct zone *zone, struct memory_group *group)
{
...
node_states_check_changes_online(nr_pages, zone, &arg);
...
node_states_set_node(nid, &arg);
...
memory_notify(MEM_ONLINE, &arg);
}
In the callback i think you want to check whether N_MEMORY is set
+ case MEM_OFFLINE:
++ if (node is !N_MEMORY)
++ sysfs_wi_node_release(node_attrs[nid], wi_kobj);
+ break;
+ }
Similar with online (don't want to double-add).
also from what I can tell, N_MEMORY implies N_ONLINE because N_ONLINE
occurs when memory blocks are added (regardless of state).
~Gregory
next prev parent reply other threads:[~2025-03-13 16:23 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 7:56 [PATCH v2 1/4] mm/mempolicy: Fix memory leaks in mempolicy_sysfs_init() Rakie Kim
2025-03-12 7:56 ` [PATCH v2 2/4] mm/mempolicy: Support memory hotplug in weighted interleave Rakie Kim
2025-03-12 16:03 ` Gregory Price
2025-03-13 6:33 ` Rakie Kim
2025-03-13 16:23 ` Gregory Price [this message]
2025-03-13 22:36 ` David Hildenbrand
2025-03-14 6:00 ` Rakie Kim
2025-03-14 9:17 ` David Hildenbrand
2025-03-17 8:23 ` Rakie Kim
2025-03-12 7:56 ` [PATCH v2 3/4] mm/mempolicy: Enable sysfs support for " Rakie Kim
2025-03-12 16:14 ` Gregory Price
2025-03-13 6:34 ` Rakie Kim
2025-03-13 16:40 ` Gregory Price
2025-03-14 6:35 ` Rakie Kim
2025-03-12 7:56 ` [PATCH v2 4/4] mm/mempolicy: Fix duplicate node addition in sysfs for " Rakie Kim
2025-03-12 15:04 ` Joshua Hahn
2025-03-13 6:34 ` Rakie Kim
2025-03-13 16:42 ` Gregory Price
2025-03-14 6:35 ` Rakie Kim
2025-03-12 15:49 ` [PATCH v2 1/4] mm/mempolicy: Fix memory leaks in mempolicy_sysfs_init() Gregory Price
2025-03-13 6:31 ` Rakie Kim
2025-03-13 15:52 ` Gregory Price
2025-03-14 7:44 ` Rakie Kim
2025-03-14 10:55 ` Jonathan Cameron
2025-03-14 13:42 ` Gregory Price
2025-03-17 8:24 ` Rakie Kim
2025-03-17 8:24 ` Rakie Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z9MGdwrgX8dYeHha@gourry-fedora-PF4VCD3F \
--to=gourry@gourry.net \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=david@redhat.com \
--cc=honggyu.kim@sk.com \
--cc=joshua.hahnjy@gmail.com \
--cc=kernel_team@skhynix.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rakie.kim@sk.com \
--cc=ying.huang@linux.alibaba.com \
--cc=yunjeong.mun@sk.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox