linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] drivers/base/node.c: get rid of get_nid_for_pfn()
@ 2019-11-27 17:41 David Hildenbrand
  2019-11-28 10:20 ` Michal Hocko
  0 siblings, 1 reply; 9+ messages in thread
From: David Hildenbrand @ 2019-11-27 17:41 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, David Hildenbrand, Greg Kroah-Hartman,
	Rafael J. Wysocki, Michal Hocko, Oscar Salvador, Andrew Morton

Since commit d84f2f5a7552 ("drivers/base/node.c: simplify
unregister_memory_block_under_nodes()") we only have a single user of
get_nid_for_pfn(). Let's just inline that code and get rid of
get_nid_for_pfn().

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 drivers/base/node.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 98a31bafc8a2..735073fd2926 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -744,17 +744,6 @@ int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
 }
 
 #ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
-static int __ref get_nid_for_pfn(unsigned long pfn)
-{
-	if (!pfn_valid_within(pfn))
-		return -1;
-#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
-	if (system_state < SYSTEM_RUNNING)
-		return early_pfn_to_nid(pfn);
-#endif
-	return pfn_to_nid(pfn);
-}
-
 /* register memory section under specified node if it spans that node */
 static int register_mem_sect_under_node(struct memory_block *mem_blk,
 					 void *arg)
@@ -766,8 +755,6 @@ static int register_mem_sect_under_node(struct memory_block *mem_blk,
 	unsigned long pfn;
 
 	for (pfn = start_pfn; pfn <= end_pfn; pfn++) {
-		int page_nid;
-
 		/*
 		 * memory block could have several absent sections from start.
 		 * skip pfn range from absent section
@@ -784,11 +771,15 @@ static int register_mem_sect_under_node(struct memory_block *mem_blk,
 		 * block belong to the same node.
 		 */
 		if (system_state == SYSTEM_BOOTING) {
-			page_nid = get_nid_for_pfn(pfn);
-			if (page_nid < 0)
+			if (!pfn_valid_within(pfn))
 				continue;
-			if (page_nid != nid)
+#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
+			if (early_pfn_to_nid(pfn) != nid)
 				continue;
+#else
+			if (pfn_to_nid(pfn) != nid)
+				continue;
+#endif
 		}
 
 		/*
-- 
2.21.0



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-11-28 14:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27 17:41 [PATCH v1] drivers/base/node.c: get rid of get_nid_for_pfn() David Hildenbrand
2019-11-28 10:20 ` Michal Hocko
2019-11-28 10:25   ` David Hildenbrand
2019-11-28 11:23     ` David Hildenbrand
2019-11-28 11:50       ` Michal Hocko
2019-11-28 11:52         ` David Hildenbrand
2019-11-28 12:01           ` Michal Hocko
2019-11-28 12:19             ` David Hildenbrand
2019-11-28 14:13               ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox