From: Oscar Salvador <osalvador@suse.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@redhat.com>,
Michal Hocko <mhocko@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Oscar Salvador <osalvador@suse.de>
Subject: [PATCH v2 1/2] mm/page_alloc: Do not calculate node's total pages and memmap pages when empty
Date: Tue, 21 Jun 2022 06:17:16 +0200 [thread overview]
Message-ID: <20220621041717.6355-2-osalvador@suse.de> (raw)
In-Reply-To: <20220621041717.6355-1-osalvador@suse.de>
free_area_init_node() calls calculate_node_totalpages() and
free_area_init_core(). The former to get node's {spanned,present}_pages,
and the latter to calculate, among other things, how many pages per zone
we spent on memmap_pages, which is used to substract zone's free pages.
On memoryless-nodes, it is pointless to perform such a bunch of work, so
make sure we skip the calculations when having a node or empty zone.
Signed-off-by: Oscar Salvador <osalvador@suse.de>
---
mm/page_alloc.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e008a3df0485..2b9b2422ba32 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7361,6 +7361,10 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
unsigned long realtotalpages = 0, totalpages = 0;
enum zone_type i;
+ /* Skip calculation for memoryless nodes */
+ if (pgdat_is_empty(pgdat))
+ goto no_pages;
+
for (i = 0; i < MAX_NR_ZONES; i++) {
struct zone *zone = pgdat->node_zones + i;
unsigned long zone_start_pfn, zone_end_pfn;
@@ -7393,6 +7397,7 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
realtotalpages += real_size;
}
+no_pages:
pgdat->node_spanned_pages = totalpages;
pgdat->node_present_pages = realtotalpages;
pr_debug("On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages);
@@ -7610,6 +7615,12 @@ static void __init free_area_init_core(struct pglist_data *pgdat)
size = zone->spanned_pages;
freesize = zone->present_pages;
+ /* No pages? Nothing to calculate then. */
+ if (!size) {
+ zone_init_internals(zone, j, nid, 0);
+ continue;
+ }
+
/*
* Adjust freesize so that it accounts for how much memory
* is used by this zone for memmap. This affects the watermark
@@ -7647,9 +7658,6 @@ static void __init free_area_init_core(struct pglist_data *pgdat)
*/
zone_init_internals(zone, j, nid, freesize);
- if (!size)
- continue;
-
set_pageblock_order();
setup_usemap(zone);
init_currently_empty_zone(zone, zone->zone_start_pfn, size);
@@ -7730,7 +7738,7 @@ static void __init free_area_init_node(int nid)
pgdat->node_start_pfn = start_pfn;
pgdat->per_cpu_nodestats = NULL;
- if (start_pfn != end_pfn) {
+ if (!pgdat_is_empty(pgdat)) {
pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
(u64)start_pfn << PAGE_SHIFT,
end_pfn ? ((u64)end_pfn << PAGE_SHIFT) - 1 : 0);
--
2.35.3
next prev parent reply other threads:[~2022-06-21 4:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 4:17 [PATCH v2 0/2] Minor memoryhotplug refactoring Oscar Salvador
2022-06-21 4:17 ` Oscar Salvador [this message]
2022-06-21 7:44 ` [PATCH v2 1/2] mm/page_alloc: Do not calculate node's total pages and memmap pages when empty David Hildenbrand
2022-06-22 3:47 ` Oscar Salvador
2022-06-22 3:56 ` Muchun Song
2022-06-22 8:31 ` David Hildenbrand
2022-06-22 8:54 ` Muchun Song
2022-06-22 10:49 ` David Hildenbrand
2022-06-21 4:17 ` [PATCH v2 2/2] mm/memory_hotplug: Reset node's state when empty during offline Oscar Salvador
2022-06-21 7:59 ` David Hildenbrand
2022-06-22 4:25 ` Oscar Salvador
2022-06-22 8:44 ` 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=20220621041717.6355-2-osalvador@suse.de \
--to=osalvador@suse.de \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
/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