linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jonghyeon Kim <tome01@ajou.ac.kr>
To: dan.j.williams@intel.com
Cc: vishal.l.verma@intel.com, dave.jiang@intel.com,
	akpm@linux-foundation.org, nvdimm@lists.linux.dev,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Jonghyeon Kim <tome01@ajou.ac.kr>
Subject: [PATCH 2/2] dax/kmem: Update spanned page stat of origin device node
Date: Thu, 27 Jan 2022 02:00:02 +0900	[thread overview]
Message-ID: <20220126170002.19754-2-tome01@ajou.ac.kr> (raw)
In-Reply-To: <20220126170002.19754-1-tome01@ajou.ac.kr>

When device memory adds to the online NUMA node, the number of spanned
pages of the original device NUMA node should be updated.

By this patch, we can monitor the current spanned pages of each node
more accurately.

Signed-off-by: Jonghyeon Kim <tome01@ajou.ac.kr>
---
 drivers/dax/kmem.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
index a37622060fff..f63a739ac790 100644
--- a/drivers/dax/kmem.c
+++ b/drivers/dax/kmem.c
@@ -11,6 +11,7 @@
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
+#include <linux/memory_hotplug.h>
 #include "dax-private.h"
 #include "bus.h"
 
@@ -48,6 +49,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)
 	struct dax_kmem_data *data;
 	int i, rc, mapped = 0;
 	int numa_node;
+	int dev_node;
 
 	/*
 	 * Ensure good NUMA information for the persistent memory.
@@ -147,6 +149,18 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)
 
 	dev_set_drvdata(dev, data);
 
+	/* Update spanned_pages of the device numa node */
+	dev_node = dev_to_node(dev);
+	if (dev_node != numa_node && dev_node < numa_node) {
+		struct pglist_data *pgdat = NODE_DATA(dev_node);
+		struct zone *zone = &pgdat->node_zones[ZONE_DEVICE];
+		unsigned long start_pfn = zone->zone_start_pfn;
+		unsigned long nr_pages = NODE_DATA(numa_node)->node_spanned_pages;
+
+		shrink_zone_span(zone, start_pfn, start_pfn + nr_pages);
+		update_pgdat_span(pgdat);
+	}
+
 	return 0;
 
 err_request_mem:
-- 
2.17.1



  reply	other threads:[~2022-01-26 17:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-26 17:00 [PATCH 1/2] mm/memory_hotplug: Export shrink span functions for zone and node Jonghyeon Kim
2022-01-26 17:00 ` Jonghyeon Kim [this message]
2022-01-27  0:29   ` [PATCH 2/2] dax/kmem: Update spanned page stat of origin device node kernel test robot
2022-01-27  5:29   ` kernel test robot
2022-01-26 17:04 ` [PATCH 1/2] mm/memory_hotplug: Export shrink span functions for zone and node David Hildenbrand
2022-01-27  9:41   ` Jonghyeon Kim
2022-01-27  9:54     ` David Hildenbrand
2022-01-28  4:19       ` Jonghyeon Kim
2022-01-28  8:10         ` David Hildenbrand
2022-02-03  2:22           ` Jonghyeon Kim
2022-02-03  8:19             ` David Hildenbrand

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=20220126170002.19754-2-tome01@ajou.ac.kr \
    --to=tome01@ajou.ac.kr \
    --cc=akpm@linux-foundation.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=vishal.l.verma@intel.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;
as well as URLs for NNTP newsgroup(s).