Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Cheng <icheng@nvidia.com>
To: "Gregory Price (Meta)" <gourry@gourry.net>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	kernel-team@meta.com,  linux-doc@vger.kernel.org,
	driver-core@lists.linux.dev, linux-serial@vger.kernel.org,
	 linux-pm@vger.kernel.org, damon@lists.linux.dev,
	linux-cxl@vger.kernel.org,  akpm@linux-foundation.org,
	david@kernel.org, liam@infradead.org, vbabka@kernel.org,
	 rppt@kernel.org, surenb@google.com, mhocko@suse.com,
	corbet@lwn.net,  skhan@linuxfoundation.org,
	rdunlap@infradead.org, gregkh@linuxfoundation.org,
	 rafael@kernel.org, dakr@kernel.org, johan@kernel.org,
	jirislaby@kernel.org,  kasong@tencent.com, qi.zheng@linux.dev,
	shakeel.butt@linux.dev, baohua@kernel.org,
	 axelrasmussen@google.com, yuanchu@google.com,
	weixugc@google.com, baoquan.he@linux.dev,
	 baolin.wang@linux.alibaba.com, yury.norov@gmail.com,
	linux@rasmusvillemoes.dk, pavel@kernel.org,  lenb@kernel.org,
	hannes@cmpxchg.org, brendan.jackman@linux.dev, ziy@nvidia.com,
	 sj@kernel.org, muchun.song@linux.dev, osalvador@suse.de,
	nico.pache@linux.dev,  ryan.roberts@arm.com, dev.jain@arm.com,
	lance.yang@linux.dev, usama.arif@linux.dev,  kas@kernel.org,
	xu.xin@linux.dev, chengming.zhou@linux.dev,
	 joshua.hahnjy@gmail.com, rakie.kim@sk.com,
	ying.huang@linux.alibaba.com,  matthew.brost@intel.com,
	byungchul@sk.com, apopple@nvidia.com, rientjes@google.com
Subject: Re: [PATCH 05/22] mm/mempolicy: keep interleave and tmpfs mount policies on common memory
Date: Wed, 18 Nov 2026 23:30:10 +0800	[thread overview]
Message-ID: <av3EGWuHX2JDdlrx@MWDK4CY14F> (raw)
In-Reply-To: <20261114070959.3490008-6-gourry@gourry.net>

On Sat, Nov 14, 2026 at 02:09:42AM +0800, Gregory Price (Meta) wrote:
> Use N_MEMORY_COMMON for boot mempolicy calculations and their per-node
> sysfs entries (weighted interleave weights). 
> 
> Restrict the node set mpol_set_nodemask() applies to set_mempolicy()
> and mbind() masks to N_MEMORY_COMMON nodes.
> 
> Later when an N_MEMORY node is omitted frmo the N_MEMORY_COMMON set,

nit: "from"

> they will be stripped from mempolicy nodemasks as they're not eligible
> (similar to memoryless nodes today).
> 
> All memory is common at this point, no behavior change at this point.
> 
> Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
> ---
>  mm/mempolicy.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index b10c098e9c2a3..662ab420fe03c 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -213,10 +213,10 @@ static void reduce_interleave_weights(unsigned int *bw, u8 *new_iw)
>  	int nid;
>  
>  	/*
> -	 * N_MEMORY can change while wi_state_lock is held. Remember the
> -	 * nodes contributing to sum_bw so all passes use the same set.
> +	 * N_MEMORY_COMMON can change while wi_state_lock is held. Remember
> +	 * the nodes contributing to sum_bw so all passes use the same set.
>  	 */
> -	for_each_node_state(nid, N_MEMORY) {
> +	for_each_node_state(nid, N_MEMORY_COMMON) {
>  		node_set(nid, nodes);
>  		sum_bw += bw[nid];
>  	}
> @@ -439,9 +439,9 @@ static int mpol_set_nodemask(struct mempolicy *pol,
>  	if (!pol || pol->mode == MPOL_LOCAL)
>  		return 0;
>  
> -	/* Check N_MEMORY */
> +	/* Check N_MEMORY_COMMON */
>  	nodes_and(nsc->mask1,
> -		  cpuset_current_mems_allowed, node_states[N_MEMORY]);
> +		  cpuset_current_mems_allowed, node_states[N_MEMORY_COMMON]);
>  
>  	VM_BUG_ON(!nodes);
>  
> @@ -3400,11 +3400,11 @@ void __init numa_policy_init(void)
>  
>  	/*
>  	 * Set interleaving policy for system init. Interleaving is only
> -	 * enabled across suitably sized nodes (default is >= 16MB), or
> -	 * fall back to the largest node if they're all smaller.
> +	 * enabled across suitably sized common memory nodes (default is
> +	 * >= 16MB), or fall back to the largest node if they're all smaller.
>  	 */
>  	nodes_clear(interleave_nodes);
> -	for_each_node_state(nid, N_MEMORY) {
> +	for_each_node_state(nid, N_MEMORY_COMMON) {
>  		unsigned long total_pages = node_present_pages(nid);
>  
>  		/* Preserve the largest node */
> @@ -3476,7 +3476,7 @@ int mpol_parse_str(char *str, struct mempolicy **mpol)
>  		*nodelist++ = '\0';
>  		if (nodelist_parse(nodelist, nodes))
>  			goto out;
> -		if (!nodes_subset(nodes, node_states[N_MEMORY]))
> +		if (!nodes_subset(nodes, node_states[N_MEMORY_COMMON]))
>  			goto out;
>  	} else
>  		nodes_clear(nodes);
> @@ -3508,7 +3508,7 @@ int mpol_parse_str(char *str, struct mempolicy **mpol)
>  		 * Default to online nodes with memory if no nodelist
>  		 */
>  		if (!nodelist)
> -			nodes = node_states[N_MEMORY];
> +			nodes = node_states[N_MEMORY_COMMON];
>  		break;
>  	case MPOL_LOCAL:
>  		/*
> @@ -3903,6 +3903,9 @@ static int wi_node_notifier(struct notifier_block *nb,
>  
>  	switch (action) {
>  	case NODE_ADDED_FIRST_MEMORY:
> +		/* Weighted interleave spans only common memory. */
> +		if (!node_state(nid, N_MEMORY_COMMON))
> +			break;
>  		err = sysfs_wi_node_add(nid);
>  		if (err)
>  			pr_err("failed to add sysfs for node%d during hotplug: %d\n",
> @@ -3934,10 +3937,7 @@ static int __init add_weighted_interleave_group(struct kobject *mempolicy_kobj)
>  	if (err)
>  		goto err_put_kobj;
>  
> -	for_each_online_node(nid) {
> -		if (!node_state(nid, N_MEMORY))
> -			continue;
> -
> +	for_each_node_state(nid, N_MEMORY_COMMON) {

Maybe I overlooked or somehow, but when do we have the assumption
that common memory is definitely onlined ?

Best regards,
Richard Cheng.

>  		err = sysfs_wi_node_add(nid);
>  		if (err) {
>  			pr_err("failed to add sysfs for node%d during init: %d\n",
> -- 
> 2.53.1-Meta
> 
> 


  reply	other threads:[~2026-11-18 15:31 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14  7:09 [PATCH 00/22] mm: introduce N_MEMORY_COMMON Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 01/22] mm: add node-state-filtered zone and node iterators Gregory Price (Meta)
2026-11-18  8:29   ` Richard Cheng
2026-11-18 15:17     ` Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 02/22] mm: publish and clear node memory states via helpers Gregory Price (Meta)
2026-11-18  7:53   ` Richard Cheng
2026-11-18 15:20     ` Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 03/22] mm: introduce the common-memory node state Gregory Price (Meta)
2026-11-18 15:24   ` Richard Cheng
2026-11-14  7:09 ` [PATCH 04/22] mm/page_alloc: build zonelists from common memory Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 05/22] mm/mempolicy: keep interleave and tmpfs mount policies on " Gregory Price (Meta)
2026-11-18 15:30   ` Richard Cheng [this message]
2026-11-14  7:09 ` [PATCH 06/22] mm: base hash distribution on common memory nodes Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 07/22] mm/memory_hotplug: migrate offlined pages to common memory Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 08/22] mm/memory-tiers: restrict demotion topology " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 09/22] mm/ksm: restrict merging " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 10/22] mm/khugepaged: restrict collapse " Gregory Price (Meta)
2026-11-14  7:21   ` sashiko-bot
2026-11-14  7:35     ` Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 11/22] mm/mempolicy: don't NUMA-hint folios outside " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 12/22] mm/damon: restrict DAMON-native folio operations to " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 13/22] mm/hugetlb: restrict pool growth " Gregory Price (Meta)
2026-11-18  7:32   ` Richard Cheng
2026-11-18 15:25     ` Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 14/22] mm/page_alloc: count common memory nodes for kswapd recovery Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 15/22] mm/oom_kill: compare OOM constraints against common memory Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 16/22] tty/sysrq: use common memory for the manual OOM zonelist Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 17/22] mm/vmscan: restrict reclaim to common memory Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 18/22] mm/compaction: restrict compaction " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 19/22] mm/migrate: restrict move_pages() destinations " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 20/22] PM: hibernate: size the image from " Gregory Price (Meta)
2026-11-14  7:34   ` sashiko-bot
2026-11-14  7:50     ` Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 21/22] mm/khugepaged: base the recommended min_free_kbytes on " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 22/22] nodemask: remove the now-unused first_memory_node/next_memory_node Gregory Price (Meta)
2026-11-18  7:01 ` [PATCH 00/22] mm: introduce N_MEMORY_COMMON Richard Cheng
2026-11-18 15:13   ` Gregory Price (Meta)

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=av3EGWuHX2JDdlrx@MWDK4CY14F \
    --to=icheng@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baoquan.he@linux.dev \
    --cc=brendan.jackman@linux.dev \
    --cc=byungchul@sk.com \
    --cc=chengming.zhou@linux.dev \
    --cc=corbet@lwn.net \
    --cc=dakr@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gourry@gourry.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=jirislaby@kernel.org \
    --cc=johan@kernel.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kas@kernel.org \
    --cc=kasong@tencent.com \
    --cc=kernel-team@meta.com \
    --cc=lance.yang@linux.dev \
    --cc=lenb@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=matthew.brost@intel.com \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nico.pache@linux.dev \
    --cc=osalvador@suse.de \
    --cc=pavel@kernel.org \
    --cc=qi.zheng@linux.dev \
    --cc=rafael@kernel.org \
    --cc=rakie.kim@sk.com \
    --cc=rdunlap@infradead.org \
    --cc=rientjes@google.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=shakeel.butt@linux.dev \
    --cc=sj@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=surenb@google.com \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=xu.xin@linux.dev \
    --cc=ying.huang@linux.alibaba.com \
    --cc=yuanchu@google.com \
    --cc=yury.norov@gmail.com \
    --cc=ziy@nvidia.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